You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by "emailitis.com" <in...@emailitis.com> on 2014/04/24 12:12:57 UTC

Spamassassin Rule Scores

Can someone tell me how we can find out the Spamassassin rule scores?

Also, in the mailllog, I would like to see spamd show not just the tests,
but the scores of each.  At present we get just:

spamd[7403]: spamd: result: Y 4 -
DKIM_SIGNED,HTML_MESSAGE,MIME_HTML_ONLY,T_DKIM_INVALID,T_REMOTE_IMAGE
scantime=2.8,size=60575,user=qscand,uid=10002,required_score=4.0,rhost=local
host,raddr=127.0.0.1,rport=43670,mid=<0.0.15.ABC.1CF5F4E42D3972E.EDCA@vmta-d
-12.lstrk.net>,autolearn=disabled

 

I understand that adding a line to local.conf:

add_header all HP _TESTSSCORES(,)_

will add something to emails themselves but can anyone tell me where we can
show the scores in the maillog.  

 

Many thanks, in advance for any help,

Christoph

 


RE: Spamassassin Rule Scores

Posted by Benny Pedersen <me...@junc.eu>.
emailitis.com skrev den 2014-04-24 14:00:

> Can anyone help with how to get scores showing in the maillog as well?

this needs a patch to spamassassin to support syslog

but spampd does what you want

note not spamc/spamd

Re: Spamassassin Rule Scores

Posted by Axb <ax...@gmail.com>.
On 04/24/2014 02:00 PM, emailitis.com wrote:
> Thank you very much Antony,   I had been looking at
> http://spamassassin.apache.org/tests.html before which is where the "Tests"
> menu goes to from the page you gave me of
> https://spamassassin.apache.org/tests_3_3_x.html.  I'm not yet mad which is
> reassuring!
>
> Can anyone help with how to get scores showing in the maillog as well?

according to spamd.raw

   my $yorn = $status->is_spam() ? 'Y' : '.';
   my $score = $status->get_score();
   my $tests = join(",", 
sort(grep(length,$status->get_names_of_tests_hit())));

   my $log = sprintf("spamd: result: %s %2d - %s %s", $yorn, $score,
	       $tests, join(",", @extra));
   info($log);

It *seems* to me it's not possible without hacking spamd



RE: Spamassassin Rule Scores

Posted by "emailitis.com" <in...@emailitis.com>.
Thank you very much Antony,   I had been looking at
http://spamassassin.apache.org/tests.html before which is where the "Tests"
menu goes to from the page you gave me of
https://spamassassin.apache.org/tests_3_3_x.html.  I'm not yet mad which is
reassuring!

Can anyone help with how to get scores showing in the maillog as well?

Kind Regards,
Christoph 
-----Original Message-----
From: Antony Stone [mailto:Antony.Stone@spamassassin.open.source.it] 
Sent: 24 April 2014 11:27
To: users@spamassassin.apache.org
Subject: Re: Spamassassin Rule Scores

On Thursday 24 April 2014 at 11:12, emailitis.com wrote:

> Can someone tell me how we can find out the Spamassassin rule scores?

https://spamassassin.apache.org/tests_3_3_x.html

Antony

-- 
I want to build a machine that will be proud of me.

 - Danny Hillis, creator of The Connection Machine

                                                     Please reply to the
list;
                                                           please don't CC
me.


Re: Spamassassin Rule Scores

Posted by Antony Stone <An...@spamassassin.open.source.it>.
On Thursday 24 April 2014 at 11:12, emailitis.com wrote:

> Can someone tell me how we can find out the Spamassassin rule scores?

https://spamassassin.apache.org/tests_3_3_x.html

Antony

-- 
I want to build a machine that will be proud of me.

 - Danny Hillis, creator of The Connection Machine

                                                     Please reply to the list;
                                                           please don't CC me.

Re: Spamassassin Rule Scores

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>> >On 4/24/2014 6:12 AM, emailitis.com wrote:
>> >>Also, in the maillog, I would like to see spamd show not just the
>> >>tests, but the scores of each.

>On Sunday 27 April 2014 at 19:03, Matus UHLAR - fantomas wrote:
>> add_header all Report _REPORT_

On 27.04.14 19:10, Antony Stone wrote:
>Doesn't this just add it into the headers of the delivered email, though - not
>in the mail log file?

yes... I missed a word (again)

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Enter any 12-digit prime number to continue.

Re: Spamassassin Rule Scores

Posted by Antony Stone <An...@spamassassin.open.source.it>.
On Sunday 27 April 2014 at 19:03, Matus UHLAR - fantomas wrote:

> >On 4/24/2014 6:12 AM, emailitis.com wrote:
> >>Also, in the maillog, I would like to see spamd show not just the
> >>tests, but the scores of each.
> 
> I believe that
> 
> add_header all Report _REPORT_
> 
> in your user_prefs does what you want (the scores are rounded to 1
> decimal plave but is should be OK for most cases)

Doesn't this just add it into the headers of the delivered email, though - not 
in the mail log file?


Antony.

-- 
"There has always been an underlying argument that we should open up our 
source code more broadly. The fact is that we are learning from open source 
and we are opening our code more broadly through Shared Source.

Is there value to providing source code? The answer is unequivocally yes."

 - Jason Matusow, head of Microsoft's Shared Source Program, in response to 
leaks of Windows source code on the Internet.

                                                     Please reply to the list;
                                                           please don't CC me.

Re: Spamassassin Rule Scores

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>On 4/24/2014 6:12 AM, emailitis.com wrote:
>>Also, in the mailllog, I would like to see spamd show not just the 
>>tests, but the scores of each.  At present we get just:
>>
>>spamd[7403]: spamd: result: Y 4 - DKIM_SIGNED,HTML_MESSAGE,MIME_HTML_ONLY,T_DKIM_INVALID,T_REMOTE_IMAGE scantime=2.8,size=60575,user=qscand,uid=10002,required_score=4.0,rhost=localhost,raddr=127.0.0.1,rport=43670,mid=<0....@vmta-d-12.lstrk.net>,autolearn=disabled

On 24.04.14 10:50, Kevin A. McGrail wrote:
>I don't believe that functionality exists.  Feel free to submit a 
>patch to add the option, etc. though.  Always love people submitting 
>patches!

I believe that

add_header all Report _REPORT_

in your user_prefs does what you want (the scores are rounded to 1
decimal plave but is should be OK for most cases)


-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
"Where do you want to go to die?" [Microsoft]

Re: Spamassassin Rule Scores

Posted by "Kevin A. McGrail" <KM...@PCCC.com>.
On 4/24/2014 2:14 PM, Axb wrote:
> IMO this should be configurable as it could break stats/loggers/etc 

The change right now just adds additional API functions.  Nothing uses 
them.

spamd could be configured to use them and should be a configuration 
option, I agree.


Re: Spamassassin Rule Scores

Posted by Axb <ax...@gmail.com>.
On 04/24/2014 07:44 PM, Kevin A. McGrail wrote:
> On 4/24/2014 1:34 PM, David F. Skoll wrote:
>> On Thu, 24 Apr 2014 13:28:56 -0400
>> "Kevin A. McGrail" <KM...@PCCC.com> wrote:
>>
>>> Keeping more in the like and kind with the existing code in PMS,
>>> wouldn't this be closer to what you need?  Completely untested but
>>> passed tests.
>> Sure... I'm not picky about how it's implemented. ;)  Just so long as
>> there's an official API to get the test names and scores, I'm happy.
> It's in trunk if you want to test it and give feedback, that would be
> helpful.  From a quick basic print of output, looks sane.
>
> svn commit -m 'added get_names_of_tests_hit_with_scores_hash,
> get_names_of_tests_hit_with_scores functions to PMS along with trivial
> fixing of triggered being misspelled.'
> Sending        lib/Mail/SpamAssassin/PerMsgStatus.pm
> Transmitting file data .
> Committed revision 1589804.
>
> regards,
> KAM

IMO this should be configurable as it could break stats/loggers/etc

Re: Spamassassin Rule Scores

Posted by "Kevin A. McGrail" <KM...@PCCC.com>.
On 4/24/2014 1:34 PM, David F. Skoll wrote:
> On Thu, 24 Apr 2014 13:28:56 -0400
> "Kevin A. McGrail" <KM...@PCCC.com> wrote:
>
>> Keeping more in the like and kind with the existing code in PMS,
>> wouldn't this be closer to what you need?  Completely untested but
>> passed tests.
> Sure... I'm not picky about how it's implemented. ;)  Just so long as
> there's an official API to get the test names and scores, I'm happy.
It's in trunk if you want to test it and give feedback, that would be 
helpful.  From a quick basic print of output, looks sane.

svn commit -m 'added get_names_of_tests_hit_with_scores_hash, 
get_names_of_tests_hit_with_scores functions to PMS along with trivial 
fixing of triggered being misspelled.'
Sending        lib/Mail/SpamAssassin/PerMsgStatus.pm
Transmitting file data .
Committed revision 1589804.

regards,
KAM

Re: Spamassassin Rule Scores

Posted by "David F. Skoll" <df...@roaringpenguin.com>.
On Thu, 24 Apr 2014 13:28:56 -0400
"Kevin A. McGrail" <KM...@PCCC.com> wrote:

> Keeping more in the like and kind with the existing code in PMS, 
> wouldn't this be closer to what you need?  Completely untested but 
> passed tests.

Sure... I'm not picky about how it's implemented. ;)  Just so long as
there's an official API to get the test names and scores, I'm happy.

Regards,

David.

Re: Spamassassin Rule Scores

Posted by "Kevin A. McGrail" <KM...@PCCC.com>.
On 4/24/2014 11:04 AM, David F. Skoll wrote:
> We integrate with SpamAssassin at the Perl library level, and we reach
> into the innards to get at the test scores.  Here's our code:
>
> 	my $conf = $sa_status->{conf} || {};
> 	my $scores = $conf->{scores} || {};
> 	my $testnames = join(',', (map { (exists($scores->{$_}) && defined($scores->{$_})) ? $_ . ':' . $scores->{$_} : "$_:?" } (split(/\s*,\s*/, $sa_status->get_names_of_tests_hit()))));
>
> We end up getting output like this in our logs:
>
> HTML_IMAGE_ONLY_20:0.7;HTML_MESSAGE:0.001;MIME_HTML_ONLY:1.105;RDNS_NONE:1.274;TO_EQ_FM_DOM_HTML_ONLY:0.489;TO_EQ_FM_HTML_ONLY:0.036;TO_NO_BRKTS_NORDNS:0.001;T_REMOTE_IMAGE:0.01
>
> Could we make an official API call something like this?
Keeping more in the like and kind with the existing code in PMS, 
wouldn't this be closer to what you need?  Completely untested but 
passed tests.

I debated making the routine get_names_of_tests_hit_with_scores call 
get_names_of_tests_hit_with_scores to unify things a small bit but then 
I would need to convert to an array and sort.  Alternately, perhaps I 
could use wantarray and combine the two functions.

Once this is done, it lays the groundwork to put 
get_names_of_tests_hit_with_scores into spamd.

Index: lib/Mail/SpamAssassin/PerMsgStatus.pm
===================================================================
--- lib/Mail/SpamAssassin/PerMsgStatus.pm       (revision 1587672)
+++ lib/Mail/SpamAssassin/PerMsgStatus.pm       (working copy)
@@ -727,6 +727,55 @@
    return join(',', sort(@{$self->{test_names_hit}}));
  }

+=item $list = $status->get_names_of_tests_hit_with_scores_hash ()
+
+After a mail message has been checked, this method can be called. It will
+return a pointer to a hash for rule & score pairs for all the symbolic
+test names and individual scores of the tests which were trigged by the 
mail.
+
+=cut
+sub get_names_of_tests_hit_with_scores_hash {
+  my ($self) = @_;
+
+  my ($line, %testsscores);
+
+  #BASED ON CODE FOR TESTSSCORES TAG - KAM 2014-04-24
+  foreach my $test (@{$self->{test_names_hit}}) {
+    my $score = $self->{conf}->{scores}->{$test};
+    $score = '0'  if !defined $score;
+
+    $testsscores{$test} = $score;
+  }
+
+  return \%testsscores;
+}
+
+=item $list = $status->get_names_of_tests_hit_with_scores ()
+
+After a mail message has been checked, this method can be called. It will
+return a comma-separated string of rule=score pairs for all the symbolic
+test names and individual scores of the tests which were trigged by the 
mail.
+
+=cut
+sub get_names_of_tests_hit_with_scores {
+  my ($self) = @_;
+
+  my ($line, %testsscores);
+
+  #BASED ON CODE FOR TESTSSCORES TAG - KAM 2014-04-24
+  foreach my $test (sort @{$self->{test_names_hit}}) {
+    my $score = $self->{conf}->{scores}->{$test};
+    $score = '0'  if !defined $score;
+    $line .= ','  if $line ne '';
+    $line .= $test . '=' . $score;
+  }
+
+  $line ||= 'none';
+
+  return $line;
+}
+
+
  ###########################################################################

Regards,
KAM

Re: Spamassassin Rule Scores

Posted by "David F. Skoll" <df...@roaringpenguin.com>.
On Thu, 24 Apr 2014 10:50:25 -0400
"Kevin A. McGrail" <KM...@PCCC.com> wrote:

> I don't believe that functionality exists.  Feel free to submit a
> patch to add the option, etc. though.  Always love people submitting
> patches!

We integrate with SpamAssassin at the Perl library level, and we reach
into the innards to get at the test scores.  Here's our code:

	my $conf = $sa_status->{conf} || {};
	my $scores = $conf->{scores} || {};
	my $testnames = join(',', (map { (exists($scores->{$_}) && defined($scores->{$_})) ? $_ . ':' . $scores->{$_} : "$_:?" } (split(/\s*,\s*/, $sa_status->get_names_of_tests_hit()))));

We end up getting output like this in our logs:

HTML_IMAGE_ONLY_20:0.7;HTML_MESSAGE:0.001;MIME_HTML_ONLY:1.105;RDNS_NONE:1.274;TO_EQ_FM_DOM_HTML_ONLY:0.489;TO_EQ_FM_HTML_ONLY:0.036;TO_NO_BRKTS_NORDNS:0.001;T_REMOTE_IMAGE:0.01

Could we make an official API call something like this?

#==========================================
package Mail::SpamAssassin::PerMsgStatus;

sub get_hits_with_scores
{
	my ($self) = @_;
	my $conf = $self->{conf} || {};
	my $scores = $conf->{scores} || {};
	my $ans = {};
	foreach my $hit ($self->get_names_of_tests_hit()) {
		# Not really sure if defaulting to 0 is correct below...
		$ans->{$hit} = (exists($scores->{$hit}) && defined($scores->{$hit})) ? $scores->{$hit} : 0;
        }
	return $ans
}
#==========================================

which returns a hashref of testname => score

Regards,

David.


Re: Spamassassin Rule Scores

Posted by "Kevin A. McGrail" <KM...@PCCC.com>.
On 4/24/2014 11:37 AM, Benny Pedersen wrote:
> Kevin A. McGrail skrev den 2014-04-24 17:30:
>
>> Ahhh... Well not sure it warrants going on the list.   I like the idea
>> but need someone to step forward and implement it and I don't think
>> enough will care.
>
> replyed private
>
> lots of idears, no coders :(
Exactly.

-- 
*Kevin A. McGrail*
President

Peregrine Computer Consultants Corporation
3927 Old Lee Highway, Suite 102-C
Fairfax, VA 22030-2422

http://www.pccc.com/

703-359-9700 x50 / 800-823-8402 (Toll-Free)
703-359-8451 (fax)
KMcGrail@PCCC.com <ma...@pccc.com>


Re: Spamassassin Rule Scores

Posted by Benny Pedersen <me...@junc.eu>.
Kevin A. McGrail skrev den 2014-04-24 17:30:

> Ahhh... Well not sure it warrants going on the list.   I like the idea
> but need someone to step forward and implement it and I don't think
> enough will care.

replyed private

lots of idears, no coders :(

Re: Spamassassin Rule Scores

Posted by "Kevin A. McGrail" <KM...@PCCC.com>.
On 4/24/2014 11:28 AM, Benny Pedersen wrote:
> Kevin A. McGrail skrev den 2014-04-24 17:12:
>> Sounds like overkill without enough demand, personally...
>
> only thing i see here is that you writed to me personally
Ahhh... Well not sure it warrants going on the list.   I like the idea 
but need someone to step forward and implement it and I don't think 
enough will care.

Re: Spamassassin Rule Scores

Posted by Benny Pedersen <me...@junc.eu>.
Kevin A. McGrail skrev den 2014-04-24 17:12:
> Sounds like overkill without enough demand, personally...

only thing i see here is that you writed to me personally

Re: Spamassassin Rule Scores

Posted by "Kevin A. McGrail" <KM...@PCCC.com>.
On 4/24/2014 11:06 AM, Benny Pedersen wrote:
> Kevin A. McGrail skrev den 2014-04-24 16:50:
>> Always love people submitting
>> patches!
>
> or opensource with think like:
>
> make syslog plugin, make it basicly same options as in add_header just 
> for sysloging
>
> then each admin can make there own login format based on same tags as 
> in add_header
>
> i would love to see this happend aswell, i just cant make the perl 
> module :(
Sounds like overkill without enough demand, personally...

Re: Spamassassin Rule Scores

Posted by Benny Pedersen <me...@junc.eu>.
Kevin A. McGrail skrev den 2014-04-24 16:50:
> Always love people submitting
> patches!

or opensource with think like:

make syslog plugin, make it basicly same options as in add_header just 
for sysloging

then each admin can make there own login format based on same tags as in 
add_header

i would love to see this happend aswell, i just cant make the perl 
module :(

Re: Spamassassin Rule Scores

Posted by "Kevin A. McGrail" <KM...@PCCC.com>.
On 4/24/2014 6:12 AM, emailitis.com wrote:
>
> Can someone tell me how we can find out the Spamassassin rule scores?
>
Best way is to view the applicable 50_scores.cf directly, i.e. 
/var/lib/spamassassin/3.004000/updates_spamassassin_org/50_scores.cf for 
3.4.0 in the default location.

> Also, in the mailllog, I would like to see spamd show not just the 
> tests, but the scores of each.  At present we get just:
>
> spamd[7403]: spamd: result: Y 4 - 
> DKIM_SIGNED,HTML_MESSAGE,MIME_HTML_ONLY,T_DKIM_INVALID,T_REMOTE_IMAGE 
> scantime=2.8,size=60575,user=qscand,uid=10002,required_score=4.0,rhost=localhost,raddr=127.0.0.1,rport=43670,mid=<0....@vmta-d-12.lstrk.net>,autolearn=disabled
>
I don't believe that functionality exists.  Feel free to submit a patch 
to add the option, etc. though.  Always love people submitting patches!