-------- Original-Nachricht --------
> Datum: Mon, 29 Mar 2010 17:12:58 +0200
> Von: "Steve" <steeeeev...@gmx.net>
> An: postfix-users@postfix.org
> Betreff: Re: max length of pcre rule?

> 
> -------- Original-Nachricht --------
> > Datum: Mon, 29 Mar 2010 16:44:58 +0200
> > Von: Louis-David Mitterrand <vindex+lists-postfix-us...@apartia.org>
> > An: postfix-users@postfix.org
> > Betreff: Re: max length of pcre rule?
> 
> > On Mon, Mar 29, 2010 at 04:38:17PM +0200, Steve wrote:
> > > 
> > > > 
> > > Ohhh boy. Now looking at the regexp I see an error. Every line
> > > starting with "/[^:]*.+" should be replaced by "/[^:]*:.+". Sorry for
> > > that.
> > > 
> > 
> > Hi Steve,
> > 
> Hello Louis-David,
> 
> 
> > You if/endif suggestion for the prefix is interesting.
> > 
> > For added safety, the individual rules should be anchored with ^ and the
> > bracketed atom plussed, no?
> > 
> > /^[^:]+:.+
> > 
> I have fixed some issues in your regexp and sorted the rules:
> if
> /^Received|^X\-((Origin(ating)?|Client|MDRemote|Sender)\-?IP|(Client|Remote_)Addr|PHP\-Script):/
> /\b(41\.1(6\d|7[0-5])\.\d+\.\d+)\b/                                           
> REJECT aviso.ci junk 2
> /\b(41\.138\.1([678]\d|9[01])\.\d+)\b/                                        
>         REJECT aviso.ci junk 2
> /\b(41\.184\.(1[6-9]|2\d|3[01])\.\d+)\b/                                      
> REJECT aviso.ci junk 2
> /\b(41\.184\.(3[2-9]|4[0-7])\.\d+)\b/                                         
> REJECT aviso.ci junk 2
> /\b(41\.189\.([1-3]?\d|4[0237]|5[0-6]|9[6-9]|1([01]\d|2[0-7]))\.\d+)\b/       
>         REJECT
> aviso.ci junk 2
> /\b(41\.191\.(6[89]|7[01]|8[4-7])\.\d+)\b/                                    
> REJECT aviso.ci junk 2
> /\b(41\.191\.1(0[89]|1[01])\.\d+)\b/                                          
> REJECT aviso.ci junk 2
> /\b(41\.19\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.202\.\d+\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(41\.203\.(6[4-9]|[78]\d|9[0-5]|2(2[4-9]|3[0-9]))\.\d+)\b/                 
> REJECT
> aviso.ci junk 2
> /\b(41\.204\.2(2[4-7]|[34]\d|5[0-5])\.\d+)\b/                                 
> REJECT aviso.ci junk 2
> /\b(41\.205\.1(6[57]|72)\.\d+)\b/                                             
> REJECT aviso.ci junk 2
> /\b(41\.207\.([0-9]|1[5-9]|2[0-9]|3[01]|1([6-9]\d)|2([01]\d|2[0-3]))\.\d+)\b/ 
> REJECT
> aviso.ci junk 2
> /\b(41\.208\.(1(2[89]|[3-9]\d)|2(0[0-7]))\.\d+)\b/                            
> REJECT aviso.ci junk
> 2
> /\b(41\.211\.([0-3]|19[2-9]|2([0-4]\d|5[0-5]))\.\d+)\b/                       
>         REJECT aviso.ci
> junk 2
> /\b(41\.213\.(\d?\d|1([01]\d|2[0-7]))\.\d+)\b/                                
>         REJECT aviso.ci junk 2
> /\b(41\.214\.(3[2-9]|4[0-7]|9[6-9])\.\d+)\b/                                  
> REJECT aviso.ci junk 2
> /\b(41\.215\.1(6\d|7[0-5])\.\d+)\b/                                           
> REJECT aviso.ci junk 2
> /\b(41\.216\.(3[2-9]|[45]\d|6[0-3])\.\d+)\b/                                  
> REJECT aviso.ci junk 2
> /\b(41\.217\.([1-9]?\d|1([01]\d|2[0-7]))\.\d+)\b/                             
> REJECT aviso.ci junk
> 2
> /\b(41\.218\.(19[2-9]|2([0-4]\d|5[0-5]))\.\d+)\b/                             
> REJECT aviso.ci junk
> 2
> /\b(41\.218\.(19[2-9]|2([01]\d|2[0-3]))\.\d+)\b/                              
> REJECT aviso.ci junk 2
> /\b(41\.219\.(1(2[89]|[3-8]\d|9[016])|24[24])\.\d+)\b/                        
>         REJECT aviso.ci
> junk 2
> /\b(41\.220\.(75|1(7[6-9]|8\d|9[01]))\.\d+)\b/                                
>         REJECT aviso.ci junk 2
> /\b(41\.221\.194\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(41\.222\.19[2-5]\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(41\.223\.2(48|51)\.\d+)\b/                                                
>         REJECT aviso.ci junk 2
> /\b(41\.232\.\d+\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(41\.245\.\d+\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(41\.25[2-5]\.\d+\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(41\.26\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.29\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.2[78]\.\d+\.\d+)\b/                                                   
> REJECT aviso.ci junk 2
> /\b(41\.30\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.31\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(58\.(4[89]|5[0-5])\.\d+\.\d+)\b/                                          
> REJECT aviso.ci junk 2
> /\b(58\.2(0[89]|1\d|2[0-3])\.\d+\.\d+)\b/                                     
> REJECT aviso.ci junk 2
> /\b(60\.1(6[6-9]|7[0-5])\.\d+\.\d+)\b/                                        
>         REJECT aviso.ci junk 2
> /\b(60\.2(0[89]1[0-7]|)\.\d+\.\d+)\b/                                         
> REJECT aviso.ci junk 2
> /\b(61\.134\.0\.\d+)\b/                                                       
>         REJECT aviso.ci junk 2
> /\b(61\.135\.\d+\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(61\.18[34]\.\d+\.\d+)\b/                                                  
> REJECT aviso.ci junk 2
> /\b(61\.54\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(62\.56\.(1(2[8-9]|[3-9]\d)|2([0-4]\d|5[0-5]))\.\d+)\b/                    
> REJECT
> aviso.ci junk 2
> /\b(72\.9\.(9[6-9]|1(0[0-9]|1[01]))\.\d+)\b/                                  
> REJECT aviso.ci junk 2
> /\b(74\.220\.(19[2-9]|2([01]\d|2[0-3]))\.\d+)\b/                              
> REJECT aviso.ci junk 2
> /\b(77\.211\.(6[4-9]|[7-9]\d|[12]\d\d)\.\d+)\b/                               
>         REJECT aviso.ci junk 2
> /\b(77\.70\.12[89]\.\d+)\b/                                                   
> REJECT aviso.ci junk 2
> /\b(78\.138\.3\.\d+)\b/                                                       
>         REJECT aviso.ci junk 2
> /\b(80\.255\.61\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(80\.89\.1(7[6-9]|8\d|9[01])\.\d+)\b/                                      
> REJECT aviso.ci junk 2
> /\b(81\.199\.\d+\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(81\.202\.\d+\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(81\.91\.2(2[4-9]|3[0-9])\.\d+)\b/                                         
> REJECT aviso.ci junk 2
> /\b(82\.128\.(\d?\d|1([01]\d|2[0-7]))\.\d+)\b/                                
>         REJECT aviso.ci junk 2
> /\b(82\.151\.131\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(83\.229\.48\.1(4[4-9]|5[01]))\b/                                          
> REJECT aviso.ci junk 2
> /\b(83\.229\.87\.24[0-7])\b/                                                  
> REJECT aviso.ci junk 2
> /\b(83\.234\.72\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(86\.62\.([0-5]?\d|6[0-3])\.\d+)\b/                                        
>         REJECT aviso.ci junk 2
> /\b(86\.96\.2(2[6-9]|3\d)\.\d+)\b/                                            
> REJECT aviso.ci junk 2
> /\b(87\.126\.(19[2-9]|2([0-4]\d|5[0-5]))\.\d+)\b/                             
> REJECT aviso.ci junk
> 2
> /\b(88\.208\.206\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(89\.248\.194\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(95\.1[67]\.\d+\.\d+)\b/                                                   
> REJECT aviso.ci junk 2
> /\b(112\.110\.(46|61|9[6-9]|1([01]\d|2[0-7]))\.\d+)\b/                        
>         REJECT aviso.ci
> junk 2
> /\b(112\.20[0-7]\.\d+\.\d+)\b/                                                
>         REJECT aviso.ci junk 2
> /\b(114\.12[0-7]\.\d+\.\d+)\b/                                                
>         REJECT aviso.ci junk 2
> /\b(115\.13[2-5]\.\d+\.\d+)\b/                                                
>         REJECT aviso.ci junk 2
> /\b(116\.206\.\d+\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(117\.(2[4-9]|3[01])\.\d+\.\d+)\b/                                         
> REJECT aviso.ci junk 2
> /\b(119\.(9[6-9]|10[0-3])\.\d+\.\d+)\b/                                       
>         REJECT aviso.ci junk 2
> /\b(120\.(9[6-9]|1([01]\d|2[0-7]))\.\d+\.\d+)\b/                              
> REJECT aviso.ci junk 2
> /\b(120\.14[01]\.\d+\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(121\.([89]|1[0-5])\.\d+\.\d+)\b/                                          
> REJECT aviso.ci junk 2
> /\b(121\.121\.\d+\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(121\.148\.199\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(121\.245\.116\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(123\.(6[4-9]|[78]\d|9[0-5])\.\d+\.\d+)\b/                                 
> REJECT aviso.ci junk 2
> /\b(123\.16[0-3]\.\d+\.\d+)\b/                                                
>         REJECT aviso.ci junk 2
> /\b(123\.5[2-5]\.\d+\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(124\.120\.1(2[89]|[3-8]\d|9[01])\.\d+)\b/                                 
> REJECT aviso.ci junk 2
> /\b(124\.122\.(1(2[89]|[3-9]\d)|2([0-4]\d|5[0-4]))\.\d+)\b/                   
> REJECT
> aviso.ci junk 2
> /\b(124\.23[6-9]\.\d+\.\d+)\b/                                                
>         REJECT aviso.ci junk 2
> /\b(165\.146\.([1-5]?\d|6[0-3])\.\d+)\b/                                      
> REJECT aviso.ci junk 2
> /\b(174\.143\.\d+\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(189\.127\.143\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(192\.83\.191\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(193\.227\.(3[2-9]|[45]\d|6[0-3])\.\d+)\b/                                 
> REJECT aviso.ci junk 2
> /\b(195\.78\.11[23]\.\d+)\b/                                                  
> REJECT aviso.ci junk 2
> /\b(196\.1\.17[6-9]\.\d+)\b/                                                  
> REJECT aviso.ci junk 2
> /\b(196\.201\.(64|72|8[34])\.\d+)\b/                                          
> REJECT aviso.ci junk 2
> /\b(196\.207\.218\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(196\.207\.254\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(196\.220\.1[0-4]\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(196\.28\.2(4\d|5[0-2])\.\d+)\b/                                           
> REJECT aviso.ci junk 2
> /\b(196\.3\.1(6[4-9]|7\d|8[13])\.\d+)\b/                                      
> REJECT aviso.ci junk 2
> /\b(196\.46\.24[0-7]\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(202\.112\.([0-2]?\d|3[01])\.\d+)\b/                                       
>         REJECT aviso.ci junk 2
> /\b(202\.96\.1(2[89]|[3-8]\d|9[01])\.\d+)\b/                                  
> REJECT aviso.ci junk 2
> /\b(203\.79\.224\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(207\.235\.61\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(211\.144\.(6[4-9]|[78]\d|9[0-5])\.\d+)\b/                                 
> REJECT aviso.ci junk 2
> /\b(212\.100\.(6[4-9]|[78]\d|9[0-5])\.\d+)\b/                                 
> REJECT aviso.ci junk 2
> /\b(212\.116\.2(1[5-9]|2[0-3])\.\d+)\b/                                       
>         REJECT aviso.ci junk 2
> /\b(212\.52\.1(2[89]|[34][0-9]|5[0-9])\.\d+)\b/                               
>         REJECT aviso.ci junk 2
> /\b(212\.92\.(19[2-9]|2([01]\d|2[0-3]))\.\d+)\b/                              
> REJECT aviso.ci junk 2
> /\b(213\.136\.(9[6-9]|1([01]\d|2[0-7]))\.\d+)\b/                              
> REJECT aviso.ci junk 2
> /\b(213\.152\.(6[4-9]|[78]\d|9[0-5])\.\d+)\b/                                 
> REJECT aviso.ci junk 2
> /\b(213\.209\.162\.\d+)\b/                                                    
> REJECT aviso.ci junk 2
> /\b(213\.255\.1(2[89]|[3-5]\d)\.\d+)\b/                                       
>         REJECT aviso.ci junk 2
> /\b(217\.20\.8[0-6]\.\d+)\b/                                                  
> REJECT aviso.ci junk 2
> /\b(217\.21\.(6[4-9]|[78]\d|9[0-5])\.\d+)\b/                                  
> REJECT aviso.ci junk 2
> /\b(218\.1[3-8]\.\d+\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(218\.2[89]\.\d+\.\d+)\b/                                                  
> REJECT aviso.ci junk 2
> /\b(219\.151\.(1(2[89]|[3-9]\d)|2([0-4]\d|5[0-5]))\.\d+)\b/                   
> REJECT
> aviso.ci junk 2
> /\b(219\.15[23]\.\d+\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(219\.23[67]\.\d+\.\d+)\b/                                                 
> REJECT aviso.ci junk 2
> /\b(220\.22[4-7]\.\d+\.\d+)\b/                                                
>         REJECT aviso.ci junk 2
> /\b(220\.249\.1([6-8]\d|9[01])\.\d+)\b/                                       
>         REJECT aviso.ci junk 2
> /\b(222\.16[0-3]\.\d+\.\d+)\b/                                                
>         REJECT aviso.ci junk 2
> /\b(222\.8[89]\.\d+\.\d+)\b/                                                  
> REJECT aviso.ci junk 2
> endif
> 
> 
> After sort I see a bunch of rules that you could shorten/combine:
> /\b(41\.232\.\d+\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> /\b(41\.245\.\d+\.\d+)\b/                                                     
> REJECT aviso.ci junk 2
> 
> Could be:
> /\b(41\.23[25]\.\d+\.\d+)\b/                                                  
> REJECT aviso.ci junk 2
> 
> 
> /\b(41\.26\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.29\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.2[78]\.\d+\.\d+)\b/                                                   
> REJECT aviso.ci junk 2
> /\b(41\.30\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.31\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> 
> 
> 
> /\b(41\.26\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.29\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.2[78]\.\d+\.\d+)\b/                                                   
> REJECT aviso.ci junk 2
> /\b(41\.30\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> /\b(41\.31\.\d+\.\d+)\b/                                                      
> REJECT aviso.ci junk 2
> 
> Could be shortened to:
> /\b(41\.(2[6-9]|3[01])\.\d+\.\d+)\b/                          REJECT aviso.ci 
> junk 2
> 
Ach. Again. I made errors. Sorry. It's hard to write here in such a small edit 
box in a web interface. The above is not 100% correct. What I wanted to write 
is:
------------------------------
/\b(41\.26\.\d+\.\d+)\b/              REJECT aviso.ci junk 2
/\b(41\.29\.\d+\.\d+)\b/              REJECT aviso.ci junk 2
/\b(41\.2[78]\.\d+\.\d+)\b/           REJECT aviso.ci junk 2
/\b(41\.30\.\d+\.\d+)\b/              REJECT aviso.ci junk 2
/\b(41\.31\.\d+\.\d+)\b/              REJECT aviso.ci junk 2

Could be shortened to:
/\b(41\.(2[6-9]|3[01])\.\d+\.\d+)\b/  REJECT aviso.ci junk 2
------------------------------


> 
> etc... I think you see yourself which rules could be combined. IMHO using
> an if/endif is much more clearer to read and easier to spot errors then the
> ultra long PCRE that you originally had.
> 
> 
> > Thanks,
> >
> // Steve
> -- 
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

-- 
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser

Reply via email to