You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by gb...@apache.org on 2019/11/24 18:22:17 UTC

svn commit: r1870328 - in /spamassassin: branches/3.4/lib/Mail/SpamAssassin/Conf.pm branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm trunk/lib/Mail/SpamAssassin/Conf.pm trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm

Author: gbechis
Date: Sun Nov 24 18:22:17 2019
New Revision: 1870328

URL: http://svn.apache.org/viewvc?rev=1870328&view=rev
Log:
Add a new SUBTESTSCOLLAPSED template tag
with subtests collapsed similar to what printed
in log file

Modified:
    spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm

Modified: spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm?rev=1870328&r1=1870327&r2=1870328&view=diff
==============================================================================
--- spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm Sun Nov 24 18:22:17 2019
@@ -4318,6 +4318,8 @@ optional, and the default is shown below
  _TESTSSCORES(,)_  as above, except with scores appended (eg. AWL=-3.0,...)
  _SUBTESTS(,)_     subtests (start with "__") hit separated by ","
                    (or other separator)
+ _SUBTESTSCOLLAPSED(,)_ subtests (start with "__") hit separated by ","
+                   (or other separator) with duplicated rules collapsed
  _DCCB_            DCC's "Brand"
  _DCCR_            DCC's results
  _PYZOR_           Pyzor results

Modified: spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1870328&r1=1870327&r2=1870328&view=diff
==============================================================================
--- spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm Sun Nov 24 18:22:17 2019
@@ -195,6 +195,13 @@ BEGIN {
       join($arg, sort @{$pms->{subtest_names_hit}}) || "none";
     },
 
+    SUBTESTSCOLLAPSED => sub {
+      my $pms = shift;
+      my $arg = (shift || ',');
+      my ($total_hits, $deduplicated_hits, @subtests) = $pms->get_array_names_of_subtests_hit("dbg");
+      join($arg, sort @subtests) || "none";
+    },
+
     TESTSSCORES => sub {
       my $pms = shift;
       my $arg = (shift || ",");
@@ -783,9 +790,33 @@ sub get_names_of_subtests_hit {
 
   if (defined $mode && $mode eq 'dbg') {
     # This routine prints only one instance of a subrule hit with a count of how many times it hit if greater than 1
+    my ($total_hits, $deduplicated_hits, @result) = $self->get_array_names_of_subtests_hit($mode);
+
+    return join(',', @result)." (Total Subtest Hits: $total_hits / Deduplicated Total Hits: $deduplicated_hits)";
+  } else {
+    # Return the simpler string with duplicates and commas
+    return join(',', sort @{$self->{subtest_names_hit}});
+  }
+}
+
+=item $list = $status->get_array_names_of_subtests_hit ()
+
+After a mail message has been checked, this method can be called.  It will
+return an array, listing all the symbolic test names of the
+meta-rule sub-tests which were triggered by the mail.  Sub-tests are the
+normally-hidden rules, which score 0 and have names beginning with two
+underscores, used in meta rules.
+
+=cut
+
+sub get_array_names_of_subtests_hit {
+  my ($self, $mode) = @_;
+
+  if (defined $mode && $mode eq 'dbg') {
+    # This routine prints only one instance of a subrule hit with a count of how many times it hit if greater than 1
     my $total_hits = scalar(@{$self->{subtest_names_hit}});
     return '' if !$total_hits;
-  
+
     my %subtest_names_hit;
     $subtest_names_hit{$_}++ foreach @{$self->{subtest_names_hit}};
 
@@ -800,11 +831,11 @@ sub get_names_of_subtests_hit {
         push @result, $rule;
       }
     }
-  
-    return join(',', @result)." (Total Subtest Hits: $total_hits / Deduplicated Total Hits: $deduplicated_hits)";
+
+    return ($total_hits, $deduplicated_hits, @result);
   } else {
     # Return the simpler string with duplicates and commas
-    return join(',', sort @{$self->{subtest_names_hit}});
+    return (scalar(@{$self->{subtest_names_hit}}), scalar(@{$self->{subtest_names_hit}}), @{$self->{subtest_names_hit}});
   }
 }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1870328&r1=1870327&r2=1870328&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Sun Nov 24 18:22:17 2019
@@ -4567,6 +4567,8 @@ optional, and the default is shown below
  _TESTSSCORES(,)_  as above, except with scores appended (eg. AWL=-3.0,...)
  _SUBTESTS(,)_     subtests (start with "__") hit separated by ","
                    (or other separator)
+ _SUBTESTSCOLLAPSED(,)_ subtests (start with "__") hit separated by ","
+                   (or other separator) with duplicated rules collapsed
  _DCCB_            DCC's "Brand"
  _DCCR_            DCC's results
  _PYZOR_           Pyzor results

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1870328&r1=1870327&r2=1870328&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Sun Nov 24 18:22:17 2019
@@ -198,6 +198,13 @@ BEGIN {
       join($arg, sort @{$pms->{subtest_names_hit}}) || "none";
     },
 
+    SUBTESTSCOLLAPSED => sub {
+      my $pms = shift;
+      my $arg = (shift || ',');
+      my ($total_hits, $deduplicated_hits, @subtests) = $pms->get_array_names_of_subtests_hit("dbg");
+      join($arg, sort @subtests) || "none";
+    },
+
     TESTSSCORES => sub {
       my $pms = shift;
       my $arg = (shift || ",");
@@ -798,9 +805,33 @@ sub get_names_of_subtests_hit {
 
   if (defined $mode && $mode eq 'dbg') {
     # This routine prints only one instance of a subrule hit with a count of how many times it hit if greater than 1
+    my ($total_hits, $deduplicated_hits, @result) = $self->get_array_names_of_subtests_hit($mode);
+
+    return join(',', @result)." (Total Subtest Hits: $total_hits / Deduplicated Total Hits: $deduplicated_hits)";
+  } else {
+    # Return the simpler string with duplicates and commas
+    return join(',', sort @{$self->{subtest_names_hit}});
+  }
+}
+
+=item $list = $status->get_array_names_of_subtests_hit ()
+
+After a mail message has been checked, this method can be called.  It will
+return an array, listing all the symbolic test names of the
+meta-rule sub-tests which were triggered by the mail.  Sub-tests are the
+normally-hidden rules, which score 0 and have names beginning with two
+underscores, used in meta rules.
+
+=cut
+
+sub get_array_names_of_subtests_hit {
+  my ($self, $mode) = @_;
+
+  if (defined $mode && $mode eq 'dbg') {
+    # This routine prints only one instance of a subrule hit with a count of how many times it hit if greater than 1
     my $total_hits = scalar(@{$self->{subtest_names_hit}});
     return '' if !$total_hits;
-  
+
     my %subtest_names_hit;
     $subtest_names_hit{$_}++ foreach @{$self->{subtest_names_hit}};
 
@@ -815,11 +846,11 @@ sub get_names_of_subtests_hit {
         push @result, $rule;
       }
     }
-  
-    return join(',', @result)." (Total Subtest Hits: $total_hits / Deduplicated Total Hits: $deduplicated_hits)";
+
+    return ($total_hits, $deduplicated_hits, @result);
   } else {
     # Return the simpler string with duplicates and commas
-    return join(',', sort @{$self->{subtest_names_hit}});
+    return (scalar(@{$self->{subtest_names_hit}}), scalar(@{$self->{subtest_names_hit}}), @{$self->{subtest_names_hit}});
   }
 }