You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Marc Perkel <ma...@perkel.com> on 2009/10/09 15:03:22 UTC
Rule and Rule
Starting to write some SA rules again. What is the syntax for a rule
where it's true if two other rules are both true? Need a small example.
Thanks in advance
Re: Rule and Rule
Posted by John Hardin <jh...@impsec.org>.
On Fri, 9 Oct 2009, Marc Perkel wrote:
> Would this be valid?
>
> meta NAME ((rule1 || rule2) && rule3)
Yes.
--
John Hardin KA7OHZ http://www.impsec.org/~jhardin/
jhardin@impsec.org FALaholic #11174 pgpk -a jhardin@impsec.org
key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
No representation without taxation!
-----------------------------------------------------------------------
8 days since a sunspot last seen - EPA blames CO2 emissions
Re: Rule and Rule
Posted by Marc Perkel <ma...@perkel.com>.
John Hardin wrote:
> On Fri, 9 Oct 2009, Marc Perkel wrote:
>
>> Starting to write some SA rules again. What is the syntax for a rule
>> where it's true if two other rules are both true? Need a small example.
>
> meta NAME (rule1 && rule2)
>
> It's essentially Perl logical expression syntax, and basic math
> expression syntax if you want to count:
>
> meta NAME rule1 && (rule2a + rule2b + rule2c + rule2d > 2)
>
>
Thanks John
Would this be valid?
meta NAME ((rule1 || rule2) && rule3)
Re: [SA] Rule and Rule
Posted by Adam Katz <an...@khopis.com>.
Mark Martinec wrote:
> Adam,
>
> Btw, channels only provide the khop-sc-neighbors.sa.khopesh.com for
> SA 3.3.0, but not the khop-bl.sa.khopesh.com,
> khop-blessed.sa.khopesh.com, and khop-general.sa.khopesh.com .
First: It's awesome to see interest in my channels!
Second: you are correct. I do not think it responsible to have
proposed changes to SA slated for 3.3.0 implemented in a channel aimed
at 3.3.0. It means that when something is slightly tweaked or renamed
(e.g. JMF), something might be scored twice. Many of my lists include
items discussed here and checked into SVN (some of them pre-dating
their discussions here or their presence in SVN, like PSBL).
khop-sc-neighbors won't be implemented in SA without my knowledge
since it is wholly my creation, so it has a 3.3.0 release. I guess
khop-blessed is pretty safe too, so I just tagged that for 3.3.0 too.
Another example: khop-lists contains KHOP_BUG5920_X_IP which should
be fixed in 3.3.0, and I'm not 100% confident in my ability to detect
and work around that (I check against __X_IP, a part of the fix).
Basically, I don't run a 3.3.0 pre-release code, I haven't seen it, I
haven't checked to see if my rules are too similar to existing new
rules, etc. When I see changelogs, I'll move my channels up.
Does 3.3.0 have prospective changelogs yet? (Will they even have the
level of detail I might need?)
Re: [SA] Rule and Rule
Posted by Mark Martinec <Ma...@ijs.si>.
Adam,
> That example may have been overly simplistic, but I thought it conveyed
> the idea. To see a real-world example, see KHOP_DNSBL_ADJ in
> http://khopesh.com/sa/khop-bl/khop-bl.cf (though please use the actual
> channel if you're going to use my rules, otherwise you won't get updates).
Btw, channels only provide the khop-sc-neighbors.sa.khopesh.com for SA 3.3.0,
but not the khop-bl.sa.khopesh.com, khop-blessed.sa.khopesh.com, and
khop-general.sa.khopesh.com .
Mark
Re: [SA] Rule and Rule
Posted by Adam Katz <an...@khopis.com>.
Karsten Bräckelmann wrote:
>> Here's my workaround. It involves some redundancy, but it does the trick:
>
> After some brief moment of head scratching...
>
> The "workaround" basically is just weighting sub-rules in the meta, and
> works regardless if it is meant to be the individual sub-rules' scores
> or not. It is useful, IFF one actually wants to weight sub-rules, which
> in practice is very uncommon.
I agree. I use it for my DNSBL overlap rule to essentially say: If
there are too many points from DNSBLs, subtract some. Uncommon, but
sometimes useful.
>> # supposing:
>> score rule2a 1.3
>> score rule2b 1.6
>> score rule2c 0.8
>> # you can compare score sums like this:
>> meta NAME rule 1 && (rule2a * 1.3 + rule2b * 1.6 + rule2c * 0.8 > 2)
>
> FWIW, the weights in this example are indeed redundant. Given the
> weights, any 2 sub-rule hits is greater than 2 -- dropping the weights
> from the equation and requiring >= 2 or > 1 instead does the same. :)
That example may have been overly simplistic, but I thought it conveyed
the idea. To see a real-world example, see KHOP_DNSBL_ADJ in
http://khopesh.com/sa/khop-bl/khop-bl.cf (though please use the actual
channel if you're going to use my rules, otherwise you won't get updates).
Re: Rule and Rule
Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Sat, 2009-10-10 at 18:14 -0400, Adam Katz wrote:
> > > > > meta NAME rule1 && (rule2a + rule2b + rule2c + rule2d > 2)
> > > > When adding rules is it a count of the number of rules or the rule scores?
> >
> > It is never the score.
> Here's my workaround. It involves some redundancy, but it does the trick:
After some brief moment of head scratching...
The "workaround" basically is just weighting sub-rules in the meta, and
works regardless if it is meant to be the individual sub-rules' scores
or not. It is useful, IFF one actually wants to weight sub-rules, which
in practice is very uncommon.
> # supposing:
> score rule2a 1.3
> score rule2b 1.6
> score rule2c 0.8
> # you can compare score sums like this:
> meta NAME rule 1 && (rule2a * 1.3 + rule2b * 1.6 + rule2c * 0.8 > 2)
FWIW, the weights in this example are indeed redundant. Given the
weights, any 2 sub-rule hits is greater than 2 -- dropping the weights
from the equation and requiring >= 2 or > 1 instead does the same. :)
> (huzzah for mixing logic with arithmetic.)
--
char *t="\10pse\0r\0dtu\0.@ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}
Re: Rule and Rule
Posted by Adam Katz <an...@khopis.com>.
>>>> It's essentially Perl logical expression syntax, and basic math
>>>> expression syntax if you want to count:
>>>>
>>>> meta NAME rule1 && (rule2a + rule2b + rule2c + rule2d > 2)
>>> When adding rules is it a count of the number of rules or the rule scores?
>
> It is never the score.
>
>> It's the number of times the rule hit (e.g. 0 or 1 for regular rules; 0
>> or more for rules with 'tflags multiple').
Here's my workaround. It involves some redundancy, but it does the trick:
# supposing:
score rule2a 1.3
score rule2b 1.6
score rule2c 0.8
# you can compare score sums like this:
meta NAME rule 1 && (rule2a * 1.3 + rule2b * 1.6 + rule2c * 0.8 > 2)
(huzzah for mixing logic with arithmetic.)
Re: Rule and Rule
Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Fri, 2009-10-09 at 15:34 +0100, Steve Freegard wrote:
> Marc Perkel wrote:
> > > It's essentially Perl logical expression syntax, and basic math
> > > expression syntax if you want to count:
> > >
> > > meta NAME rule1 && (rule2a + rule2b + rule2c + rule2d > 2)
> >
> > When adding rules is it a count of the number of rules or the rule scores?
It is never the score.
> It's the number of times the rule hit (e.g. 0 or 1 for regular rules; 0
> or more for rules with 'tflags multiple').
Also, meta and eval (sub-)rules may evaluate to non-Boolean values. Both
however, generally are actually Boolean.
The value of an eval rule is that returned by its function. The value of
a meta rule is that of its arithmetic expression.
meta BOOL ONE_A + ONE_B > 1
meta ARITH ONE_A + ONE_B
BOOL will always be either 0 or 1, while ARITH might be 2, the sum of
the sub-rules. While the latter generally is *not* used by SA stock
rules, but usually strictly the former, it is something to keep in mind
when using them in metas with arithmetic expressions.
Marc, may I suggest reading the M::SA::Conf docs for the meta rule
definition documentation?
guenther
--
char *t="\10pse\0r\0dtu\0.@ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}
Re: Rule and Rule
Posted by Steve Freegard <st...@fsl.com>.
Marc Perkel wrote:
>
>
> John Hardin wrote:
>> On Fri, 9 Oct 2009, Marc Perkel wrote:
>>
>> It's essentially Perl logical expression syntax, and basic math
>> expression syntax if you want to count:
>>
>> meta NAME rule1 && (rule2a + rule2b + rule2c + rule2d > 2)
>
> When adding rules is it a count of the number of rules or the rule scores?
It's the number of times the rule hit (e.g. 0 or 1 for regular rules; 0
or more for rules with 'tflags multiple').
Regards,
Steve.
Re: Rule and Rule
Posted by Marc Perkel <ma...@perkel.com>.
John Hardin wrote:
> On Fri, 9 Oct 2009, Marc Perkel wrote:
>
> It's essentially Perl logical expression syntax, and basic math
> expression syntax if you want to count:
>
> meta NAME rule1 && (rule2a + rule2b + rule2c + rule2d > 2)
When adding rules is it a count of the number of rules or the rule scores?
>
>
Re: Rule and Rule
Posted by John Hardin <jh...@impsec.org>.
On Fri, 9 Oct 2009, Marc Perkel wrote:
> Starting to write some SA rules again. What is the syntax for a rule where
> it's true if two other rules are both true? Need a small example.
meta NAME (rule1 && rule2)
It's essentially Perl logical expression syntax, and basic math expression
syntax if you want to count:
meta NAME rule1 && (rule2a + rule2b + rule2c + rule2d > 2)
--
John Hardin KA7OHZ http://www.impsec.org/~jhardin/
jhardin@impsec.org FALaholic #11174 pgpk -a jhardin@impsec.org
key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
No representation without taxation!
-----------------------------------------------------------------------
8 days since a sunspot last seen - EPA blames CO2 emissions
Re: Rule and Rule
Posted by John Hardin <jh...@impsec.org>.
On Sat, 10 Oct 2009, Benny Pedersen wrote:
> meta RFC_ABUSE_POST (__DNS_FROM_RFC_ABUSE && __DNS_FROM_RFC_POST)
> describe RFC_ABUSE_POST Meta: both abuse and postmaster missing on sender
> domain
> score RFC_ABUSE_POST 0.01
>
> please put into sandbox if one have access
Done.
--
John Hardin KA7OHZ http://www.impsec.org/~jhardin/
jhardin@impsec.org FALaholic #11174 pgpk -a jhardin@impsec.org
key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
Vista is at best mildly annoying and at worst makes you want to
rush to Redmond, Wash. and rip somebody's liver out. -- Forbes
-----------------------------------------------------------------------
8 days since a sunspot last seen - EPA blames CO2 emissions
Re: Rule and Rule
Posted by Benny Pedersen <me...@junc.org>.
On fre 09 okt 2009 15:03:22 CEST, Marc Perkel wrote
> Starting to write some SA rules again. What is the syntax for a rule
> where it's true if two other rules are both true? Need a small
> example.
>
> Thanks in advance
>
>
meta RFC_ABUSE_POST (__DNS_FROM_RFC_ABUSE && __DNS_FROM_RFC_POST)
describe RFC_ABUSE_POST Meta: both abuse and postmaster missing on
sender domain
score RFC_ABUSE_POST 0.01
please put into sandbox if one have access
--
xpoint
Re: Rule and Rule
Posted by Mike Cardwell <sp...@lists.grepular.com>.
Marc Perkel wrote:
> Starting to write some SA rules again. What is the syntax for a rule
> where it's true if two other rules are both true? Need a small example.
>
> Thanks in advance
Read: http://wiki.apache.org/spamassassin/WritingRules
About 2/3rds of the way down the page you'll see a description of "Meta
rules" with a good example.
--
Mike Cardwell - IT Consultant and LAMP developer
Cardwell IT Ltd. (UK Reg'd Company #06920226) http://cardwellit.com/
Technical Blog: https://secure.grepular.com/blog/