----- Original Message ----- 
From: "Yorkshire Dave" <[EMAIL PROTECTED]>
To: "spamassassin list" <[EMAIL PROTECTED]>
Sent: Wednesday, July 30, 2003 7:41 PM
Subject: RE: [SAtalk] [RD] rule discussion

At 7/30/03 10:29 AM , Yorkshire Dave wrote:

>I managed to figure how to write my own eval test by reading the source
>code. Anyone who isn't at a level where they can do that really
>shouldn't be trying to, or they're going to shoot themselves in the
>foot. I'm not trying to dissuade anyone from trying to learn, but
>there's a lot more involved in writing an eval than there is in writing
>a rule, a lot more ways to get it wrong.

Perl is not higher math. :) In fact, eval functions are so conceptually
trivial, that it is really as simple as returning either of two boolean
values: 0 (undef too, of course) for false, and 1 (or any positive value)
for true. :) What you do within the subroutine is no more difficult or hard
to understand than Perl itself. I have many custom eval functions, like:

full VALID_ASARIAN_HOST_PGP       eval:check_for_valid_asarian_host_pgp()
describe VALID_ASARIAN_HOST_PGP   Signed message from Asarian-host is OK
score VALID_ASARIAN_HOST_PGP      -100

Which, obviously, checks for a valid PGP sig from my own domain. :) (See?
there is use for "full"!) Or something like this:

header BLACKHOLED_RECIPIENTS      eval:check_for_blackholed_recipients()
describe BLACKHOLED_RECIPIENTS    Blackholed locals in recipient list
score BLACKHOLED_RECIPIENTS       5.000

Which checks a MySQL database for blackholed recipients (like games@, man@,
etc). To give you an example of the latter, the main sub calls the actual
MySQL checker, having all dequoted recipients in @_ as parameter:

sub check_for_blackholed_recipients {
    local $_;
    my ($self) = @_;
   ($_ = $self->get('ToCc')) =~ s/\(.*?\)//g;
    return (check_for_blackholes ((m/([EMAIL PROTECTED](?:[\w.-]+\.)+\w+)/g)));
}

And "check_for_blackholes" then returns 1 on a match, and 0 when not. The
existing source is, indeed, a welcome source of inspiration. ;)

Local eval tests are really very useful. The only thing I do not like, is
that you have to edit the existing source (EvalTests.pm). I had rather seen
something like "user_eval:", which is like "eval:", but only looks for the
subs in, say, UserEval.pm (initialized like EvalTests.pm, but essentially
empty at distribution). Or is there already a way to "localize" eval tests?

- Mark



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to