On Thu, 2009-07-23 at 09:05 -0400, Dan Schaefer wrote:
> I don't have a test server to try this, so maybe someone could test it 
> for me or maybe someone has tried this before...

You don't need a dedicated test server for that. Access to SA is
sufficient. You *do* however need some sort of testing your rules before
pushing them live. Can't outsource that to us.

> I want to create a rule that counts the number of rules that have a 
> score and add my score. I don't want to count the total score. Can I use 
> !! instead of the rule name.
> 
> I may not have explained it well, so here's an example. I want at least 
> 3 out of 5 rules to pass before adding my 5 points.
> 
> #(!!1.25) = true = 1? in SA
> meta   MY_RULE   (!!RULE_ONE + !!RULE_TWO + !!RULE_THREE + !!RULE_FOUR + 
> !!RULE_FIVE >= 3)
> score   MY_RULE   5

Creative. ;)  I didn't try it, but I guess that should work. Anyway...

> instead of the following, because the total score would be counted

This is wrong.

> meta   MY_RULE   (RULE_ONE + RULE_TWO + RULE_THREE + RULE_FOUR + 
> RULE_FIVE >= 3)

This simple rule already does exactly what you want. SA does *not* use
the rule's scores when adding. See the Conf docs on meta rules.

You can verify this easily yourself (output snipped).

$ echo -e "\n" | spamassassin --cf="meta FOO (MISSING_MID + MISSING_DATE > 1)"
        *  0.0 MISSING_MID Missing Message-Id: header
        *  0.0 MISSING_DATE Missing Date: header
        *  1.0 FOO FOO


Note though, that meta and eval rules in your expression *might* have a
value other than 0 or 1. I believe, however, that eval rules generally
do return a boolean value. Also, meta rules are most likely coded to
return a boolean value, too. (Like your rule does, e.g.)

And of course, tflags multiple rules will return the number they hit.
Other than these caveats, in that expression above, any rule will indeed
evaluate to a boolean value. *Not* the rule's score, in no case.


Actually looking at other folks rules might proof enlightening, too.
Like this example, that does what you are asking for.

$ grep '^meta DIGEST_MULTIPLE' 20_net_tests.cf 
meta DIGEST_MULTIPLE            RAZOR2_CHECK + DCC_CHECK + PYZOR_CHECK > 1


-- 
char *t="\10pse\0r\0dtu...@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; }}}

  • rule counter Dan Schaefer
    • Re: rule counter Karsten Bräckelmann

Reply via email to