You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Jorge Valdes <jv...@intercom.com.sv> on 2004/08/21 17:02:40 UTC
Another Method for PerMsgStatus.PM
Hi all,
I use mimedefang to call SpamAssassin (v2.63) to check the contents for
SPAM, and wanted to modify the X-Spam-Status header, which I append to
*all* messages that get scanned with the scores of each test that hit.
This way I could check headers to see the scores in case a message
squeeked by below my required hits threshold.
Since there is no method to do this, I implemented the following method
in PerMsgStatus.pm:
---BEGIN---
###########################################################################
=item $list = $status->get_scores_of_tests_hit ()
After a mail message has been checked, this methid can be called. It will
return a comma-separated string, listing all the symbolic test names
of the tests which were trigged by the mail with the test score separated
by '='.
=cut
sub get_scores_of_tests_hit {
my ($self) = @_;
my $line = '';
foreach my $test (sort @{$self->{test_names_hit}}) {
$line .= ',' if ($line);
$line .= $test . "=" . $self->{conf}->{scores}->{$test};
}
return $line;
}
---END---
I have this in a production system and now get the following header:
X-Spam-Status: No, hits=0.6 required=7.5
tests=DATE_IN_PAST_12_24=0.385,FROM_ENDS_IN_NUMS=0.869,
SARE_HEAD_XBEEN=-0.628
version=2.63
Which gives me more information which I can log and generate nice stats
of the test *with* scores.
--
Jorge Valdes
Intercom El Salvador
jvaldes@intercom.com.sv
Re: Another Method for PerMsgStatus.PM
Posted by Ryan Thompson <ry...@sasknow.com>.
Jorge Valdes wrote to spamassassin-users@incubator.apache.org:
> Hi all,
>
> I use mimedefang to call SpamAssassin (v2.63) to check the contents
> for SPAM, and wanted to modify the X-Spam-Status header, which I
> append to *all* messages that get scanned with the scores of each test
> that hit. This way I could check headers to see the scores in case a
> message squeeked by below my required hits threshold.
>
> Since there is no method to do this, I implemented the following
> method in PerMsgStatus.pm:
We wanted the same thing. Since I didn't want to maintain local changes
to SpamAssassin code, I modified mimedefang-filter to parse the long SA
report from $status->get_report(). Since mimedefang-filter is part of
the local config, it won't get blown away when either SA or MD are
upgraded.
> $line .= $test . "=" . $self->{conf}->{scores}->{$test};
Also, your approach won't catch AWL scores, since they're scored
dynamically. Add this to filter-end. Assumes you've already fetched
$hits, $req, $autolearn, and $report.
# Catch everything before the rule details
my $ind = rindex($report, "Content analysis details:");
my $tempreport = ($ind > -1) ? substr($report, $ind) : "";
my $spamstatus = ($hits >= $req) ? 'Yes' : 'No';
my ($rulestats);
foreach my $line (split /\n/, $tempreport) {
next unless ($line =~ /^\s*(\-?\d+\.\d+)\s+(\S+)/);
$rulestats .= ",$2=$1";
}
$rulestats = substr($rulestats,1); # Remove leading comma
my $XSpamStatus = "$spamstatus, hits=$hits required=$req "
. "tests=$rulestats autolearn=$autolearn version="
. $Mail::SpamAssassin::VERSION . "-"
. $Mail::SpamAssassin::EXTRA_VERSION[0];
# Fold the header to 72 columns on commas or spaces
$XSpamStatus =~ s/([^\n\t]{32,64})([, ])/$1\n\t/g;
action_change_header("X-Spam-Status", $XSpamStatus);
This, as far as I can see, exactly duplicates the behavious of the SA
X-Spam-Status header when using _TESTSSCORES(,)_.
- Ryan
--
Ryan Thompson <ry...@sasknow.com>
SaskNow Technologies - http://www.sasknow.com
901-1st Avenue North - Saskatoon, SK - S7K 1Y4
Tel: 306-664-3600 Fax: 306-244-7037 Saskatoon
Toll-Free: 877-727-5669 (877-SASKNOW) North America