You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Justin Mason <jm...@jmason.org> on 2005/10/04 03:43:22 UTC

Re: Plus and minus scoring rule?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


scottn writes:
>
>I'm working on a plugin for the MX+ tests (Basically tests the senders
>address against the MX for their domain)
>
>The "right" thing IMO would be a negative score for passing,
>a positive score for failing, and a 0 if the test can't (or isn't) run.
>The only way I see to do that is two have two tests, one that checks
>for a pass, and one that checks for a fail.
>
>Ok, I can do that, (I can even cache the result so it doesn't have to
>do multiple DNS queries) but it doesn't feel clean to me.
>I was wondering if there was a better way to do it.

Take a look at the DomainKeys or SPF plugins for the "standard" way
to do it.  Basically, you have:

    sub check_state_a {
      my ($self, $scanner, ...) = @_;
      $self->_implementation(...);
      return $scanner->{hit_state_a};
    }

    sub check_state_b {
      my ($self, $scanner, ...) = @_;
      $self->_implementation(...);
      return $scanner->{hit_state_b};
    }

    sub _implementation {
      my ($self, $scanner, ...) = @_;

      return if ($scanner->{already_called_implementation});
      $scanner->{already_called_implementation} = 1;

      $scanner->{hit_state_a} = 0;
      $scanner->{hit_state_b} = 0;

      [.... do all the work and set those appropriately. ....]
    }

in other words you have one, "hidden" implementation function, and
multiple entrypoints that all that one same function to perform
the hard work, before returning just the single aspect they're
interested in.

- --j.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Exmh CVS

iD8DBQFDQd46MJF5cimLx9ARAn/RAJ0aWw1bPK2ie8xHmp8TgVaqhucJQwCgnP9Y
gU5z+9YmdXJtwlAJnFp+06s=
=ACzP
-----END PGP SIGNATURE-----