You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2021/04/07 09:20:57 UTC

svn commit: r1888466 - in /spamassassin/trunk: ./ lib/Mail/SpamAssassin/ lib/Mail/SpamAssassin/Plugin/ t/

Author: hege
Date: Wed Apr  7 09:20:57 2021
New Revision: 1888466

URL: http://svn.apache.org/viewvc?rev=1888466&view=rev
Log:
Bug 7824 - Improve test_log() for multiple rule hits.
Now supports multiple calls of $pms->test_log() for rules:
- add $pms->check_cleanup() to finalize tags/reports etc, called from Check.pm after Plugins check_cleanup
- deprecate $pms->{test_log_msgs}, rename to $pms->{test_logs} because old plugins might call %{$self->{test_log_msgs}} = ();
- deprecate $pms->clear_test_state() since it's not needed anymore
- $pms->test_log() accepts $rulename as second argument (if missing, tries get_current_eval_rule_name())


Modified:
    spamassassin/trunk/UPGRADE
    spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Esp.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HashBL.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm
    spamassassin/trunk/t/uribl_all_types.t

Modified: spamassassin/trunk/UPGRADE
URL: http://svn.apache.org/viewvc/spamassassin/trunk/UPGRADE?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/UPGRADE (original)
+++ spamassassin/trunk/UPGRADE Wed Apr  7 09:20:57 2021
@@ -129,6 +129,12 @@ Note for Users Upgrading to SpamAssassin
 - BodyEval: plaintext_body_sig_ratio: eval rules for the (first text/plain
   MIME part's) body and signature lengths and ratio
 
+- API: Now supports multiple calls of $pms->test_log() for rules.  Add
+  $pms->check_cleanup() to finalize tags/reports etc.  Deprecate internal
+  $pms->{test_log_msgs}, rename to $pms->{test_logs}.  Deprecate
+  $pms->clear_test_state(), not needed anymore.  $pms->test_log() accepts
+  $rulename as second argument.
+
 Note for Users Upgrading to SpamAssassin 3.4.4
 ----------------------------------------------
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm Wed Apr  7 09:20:57 2021
@@ -171,17 +171,8 @@ sub dnsbl_hit {
     }
   }
 
-  # TODO: this may result in some log messages appearing under the
-  # wrong rules, since we could see this sequence: { test one hits,
-  # test one's message is logged, test two hits, test one fires again
-  # on another IP, test one's message is logged for that other IP --
-  # but under test two's heading }.   Right now though it's better
-  # than just not logging at all.
-
-  $self->{already_logged} ||= { };
-  if ($log && !$self->{already_logged}->{$log}) {
-    $self->test_log($log);
-    $self->{already_logged}->{$log} = 1;
+  if ($log) {
+    $self->test_log($log, $rule);
   }
 
   if (!$self->{tests_already_hit}->{$rule}) {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Wed Apr  7 09:20:57 2021
@@ -288,7 +288,8 @@ sub new {
     'main'              => $main,
     'msg'               => $msg,
     'score'             => 0,
-    'test_log_msgs'     => { },
+    'test_log_msgs'     => { }, # deprecated since 4.0, renamed to test_logs to prevent conflicts
+    'test_logs'         => { },
     'test_names_hit'    => [ ],
     'subtest_names_hit' => [ ],
     'spamd_result_log_items' => [ ],
@@ -454,6 +455,75 @@ sub check_timed {
   1;
 }
 
+# Called from Check.pm after Plugins check_cleanup calls
+# Cleanup and finish things before learning/rewrites etc
+# TODO: document?
+sub check_cleanup {
+  my ($self) = shift;
+
+  # Create subjprefix
+  if (defined $self->{subjprefix}) {
+    $self->{tag_data}->{SUBJPREFIX} = $self->{subjprefix};
+  }
+
+  # Create reports
+  $self->{tag_data}->{REPORT} = '';
+  $self->{tag_data}->{SUMMARY} = '';
+  my $test_logs = $self->{test_logs};
+  my $scores = $self->{conf}->{scores};
+  foreach my $rule (@{$self->{test_names_hit}}) {
+    my $score = $scores->{$rule};
+    my $area = $test_logs->{$rule}->{area} || '';
+    my $desc = $test_logs->{$rule}->{desc} || '';
+
+    if ($score >= 10 || $score <= -10) {
+      $score = sprintf("%4.0f", $score);
+    } else {
+      $score = sprintf("%4.1f", $score);
+    }
+
+    my $terse = '';
+    my $long = '';
+    if (defined $test_logs->{$rule}->{msg}) {
+      my @msgs;
+      if (($self->{conf}->{tflags}->{$rule}||'') =~ /\bnolog\b/) {
+        @msgs = ['*REDACTED*'];
+      } else {
+        @msgs = @{$test_logs->{$rule}->{msg}};
+      }
+      local $1;
+      foreach my $msg (@msgs) {
+        while ($msg =~ s/^(.{30,48})\s//) {
+          $terse .= sprintf ("[%s]\n", $1);
+          if (length($1) > 47) {
+            $long .= sprintf ("%78s\n", "[$1]");
+          } else {
+            $long .= sprintf ("%27s [%s]\n", "", $1);
+          }
+        }
+        $terse .= sprintf ("[%s]\n", $msg);
+        if (length($msg) > 47) {
+          $long .= sprintf ("%78s\n", "[$msg]");
+        } else {
+          $long .= sprintf ("%27s [%s]\n", "", $msg);
+        }
+      }
+    }
+
+    $self->{tag_data}->{REPORT} .= sprintf ("* %s %s %s%s\n%s",
+        $score, $rule, $area,
+        $self->_wrap_desc($desc,
+            4+length($rule)+length($score)+length($area), "*      "),
+        ($terse ? "*      " . $terse : ''));
+
+    $self->{tag_data}->{SUMMARY} .= sprintf ("%s %-22s %s%s\n%s",
+        $score, $rule, $area,
+        $self->_wrap_desc($desc,
+            3+length($rule)+length($score)+length($area), " " x 28),
+        $long);
+  }
+}
+
 ###########################################################################
 
 =item $status->learn()
@@ -2809,25 +2879,15 @@ ENDOFEVAL
 
 ###########################################################################
 
-# note: only eval tests should store state in $self->{test_log_msgs};
-# pattern tests do not.
-#
-# the clearing of the test state is now inlined as:
-#
-# %{$self->{test_log_msgs}} = ();        # clear test state
-#
-# except for this public API for plugin use:
-
 =item $status->clear_test_state()
 
-Clear test state, including test log messages from C<$status-E<gt>test_log()>.
+DEPRECATED, UNNEEDED SINCE 4.0
 
 =cut
 
-sub clear_test_state {
-    my ($self) = @_;
-    %{$self->{test_log_msgs}} = ();
-}
+sub clear_test_state {}
+
+###########################################################################
 
 # internal API, called only by got_hit()
 # TODO: refactor and merge this into that function
@@ -2860,36 +2920,10 @@ sub _handle_hit {
     $self->{score} += $score;
 
     push(@{$self->{test_names_hit}}, $rule);
-    $area ||= '';
-
-    if ($score >= 10 || $score <= -10) {
-      $score = sprintf("%4.0f", $score);
-    }
-    else {
-      $score = sprintf("%4.1f", $score);
-    }
-
-    # save both summaries
-    # TODO: this is slower than necessary, if we only need one
-    if (($self->{conf}->{tflags}->{$rule}||'') =~ /\bnolog\b/) {
-      $self->{test_log_msgs}->{TERSE} = sprintf ("[%s]\n", "*REDACTED*");
-      $self->{test_log_msgs}->{LONG} =  sprintf ("%27s [%s]\n", "", "*REDACTED*");
-    }
-    $self->{tag_data}->{REPORT} .= sprintf ("* %s %s %s%s\n%s",
-              $score, $rule, $area,
-              $self->_wrap_desc($desc,
-                  4+length($rule)+length($score)+length($area), "*      "),
-              ($self->{test_log_msgs}->{TERSE} ?
-              "*      " . $self->{test_log_msgs}->{TERSE} : ''));
 
-    $self->{tag_data}->{SUMMARY} .= sprintf ("%s %-22s %s%s\n%s",
-              $score, $rule, $area,
-              $self->_wrap_desc($desc,
-                  3+length($rule)+length($score)+length($area), " " x 28),
-              ($self->{test_log_msgs}->{LONG} || ''));
-    if (defined $self->{subjprefix}) {
-      $self->{tag_data}->{SUBJPREFIX} = $self->{subjprefix};
-    }
+    # Save for report processing
+    $self->{test_logs}->{$rule}->{area} = $area;
+    $self->{test_logs}->{$rule}->{desc} = $desc;
 }
 
 sub _wrap_desc {
@@ -2977,7 +3011,6 @@ sub got_hit {
   # adding a hit does nothing if we don't have a score -- we probably
   # shouldn't have run it in the first place
   if (!$score) {
-    %{$self->{test_log_msgs}} = ();
     return;
   }
 
@@ -2996,7 +3029,6 @@ sub got_hit {
   my $already_hit = $self->{tests_already_hit}->{$rule} || 0;
   # don't count hits multiple times, unless 'tflags multiple' is on
   if ($already_hit && ($tflags_ref->{$rule}||'') !~ /\bmultiple\b/) {
-    %{$self->{test_log_msgs}} = ();
     return;
   }
 
@@ -3045,31 +3077,29 @@ sub got_hit {
     }
   }
 
-  %{$self->{test_log_msgs}} = ();  # clear test logs
   return 1;
 }
 
 ###########################################################################
 
-# TODO: this needs API doc
-sub test_log {
-  my ($self, $msg) = @_;
-  local $1;
-  while ($msg =~ s/^(.{30,48})\s//) {
-    $self->_test_log_line ($1);
-  }
-  $self->_test_log_line ($msg);
-}
+=item $status->test_log ($text [, $rulename])
 
-sub _test_log_line {
-  my ($self, $msg) = @_;
+Add $text log entry for a hit rule in final message REPORT/SUMMARY.
 
-  $self->{test_log_msgs}->{TERSE} .= sprintf ("[%s]\n", $msg);
-  if (length($msg) > 47) {
-    $self->{test_log_msgs}->{LONG} .= sprintf ("%78s\n", "[$msg]");
-  } else {
-    $self->{test_log_msgs}->{LONG} .= sprintf ("%27s [%s]\n", "", $msg);
-  }
+Usually called just before got_hit(), to describe for example what URI the
+rule matched on.  Optional <$rulename> argument is recommended to make sure
+log is written to correct rule.  If rulename is not provided,
+get_current_eval_rule_name() is used as fallback.
+
+Can be called multiple times per rule for additional entries.
+
+=cut
+
+sub test_log {
+  my ($self, $msg, $rulename) = @_;
+  $rulename ||= $self->get_current_eval_rule_name();
+  return if !defined $rulename;
+  push @{$self->{test_logs}->{$rulename}->{msg}}, $msg;
 }
 
 ###########################################################################

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ASN.pm Wed Apr  7 09:20:57 2021
@@ -612,7 +612,7 @@ sub _check_asn {
   return if !defined $asn;
 
   if ($asn =~ $rec) {
-    $pms->test_log("ASN: $asn");
+    $pms->test_log("ASN: $asn", $rulename);
     $pms->got_hit($rulename, "");
   }
 }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm Wed Apr  7 09:20:57 2021
@@ -588,8 +588,7 @@ sub askdns_hit {
 
   # only the first hit will show in the test log report, even if
   # an answer section matches more than once - got_hit() handles this
-  $pms->clear_test_state();
-  $pms->test_log(sprintf("%s %s:%s", $query_domain,$qtype,$rr_rdatastr));
+  $pms->test_log(sprintf("%s %s:%s", $query_domain,$qtype,$rr_rdatastr), $rulename);
   $pms->got_hit($rulename, 'ASKDNS: ', ruletype => 'askdns');  # score=>$score
 }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm Wed Apr  7 09:20:57 2021
@@ -224,6 +224,7 @@ sub check_main {
 
   # last chance to handle left callbacks, make rule hits etc
   $self->{main}->call_plugins ("check_cleanup", { permsgstatus => $pms });
+  $pms->check_cleanup();
 
   if ($pms->{deadline_exceeded}) {
   # dbg("check: exceeded time limit, skipping auto-learning");
@@ -269,8 +270,6 @@ sub run_rbl_eval_tests {
     my $score = $pms->{conf}->{scores}->{$rulename};
     next unless $score;
 
-    %{$pms->{test_log_msgs}} = ();        # clear test state
-
     my $function = $test->[0];
     if (!exists $pms->{conf}->{eval_plugins}->{$function}) {
       warn("rules: unknown eval '$function' for $rulename, ignoring RBL eval\n");
@@ -311,7 +310,6 @@ sub run_generic_tests {
 
   my $ruletype = $opts{type};
   dbg("rules: running $ruletype tests; score so far=".$pms->{score});
-  %{$pms->{test_log_msgs}} = ();        # clear test state
 
   my $conf = $pms->{conf};
   my $doing_user_rules = $conf->{want_rebuild_for_type}->{$opts{consttype}};
@@ -1196,7 +1194,6 @@ sub run_eval_tests {
     $evalstr .= '
     if ($scoresptr->{q{'.$rulename.'}}) {
       $rulename = q#'.$rulename.'#;
-      %{$self->{test_log_msgs}} = ();
 ';
  
     # only need to set current_rule_name for plugin evals

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Esp.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Esp.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Esp.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Esp.pm Wed Apr  7 09:20:57 2021
@@ -310,7 +310,7 @@ sub esp_sendgrid_check_domain {
       $pms->set_tag('SENDGRIDDOM', $sendgrid_domain);
       if ( exists $self->{ESP}->{SENDGRID_DOMAIN}->{$sendgrid_domain} ) {
         dbg("HIT! $sendgrid_domain domain found in Sendgrid Invaluement feed");
-        $pms->test_log("Sendgrid domain: $sendgrid_domain");
+        $pms->test_log("Sendgrid domain: $sendgrid_domain", $rulename);
         $pms->got_hit($rulename, "", ruletype => 'eval');
         return 1;
       }
@@ -339,7 +339,7 @@ sub esp_sendgrid_check_id {
       $pms->set_tag('SENDGRIDID', $sendgrid_id);
       if ( exists $self->{ESP}->{SENDGRID}->{$sendgrid_id} ) {
         dbg("HIT! $sendgrid_id customer id found in Sendgrid Invaluement feed");
-        $pms->test_log("Sendgrid id: $sendgrid_id");
+        $pms->test_log("Sendgrid id: $sendgrid_id", $rulename);
         $pms->got_hit($rulename, "", ruletype => 'eval');
         return 1;
       }
@@ -378,7 +378,7 @@ sub esp_sendinblue_check {
     if ( exists $self->{ESP}->{SENDINBLUE}->{$sendinblue_id} ) {
       $pms->set_tag('SENDINBLUEID', $sendinblue_id);
       dbg("HIT! $sendinblue_id ID found in Sendinblue feed");
-      $pms->test_log("Sendinblue id: $sendinblue_id");
+      $pms->test_log("Sendinblue id: $sendinblue_id", $rulename);
       $pms->got_hit($rulename, "", ruletype => 'eval');
       return 1;
     }
@@ -409,7 +409,7 @@ sub esp_mailup_check {
     if ( exists $self->{ESP}->{MAILUP}->{$mailup_id} ) {
       $pms->set_tag('MAILUPID', $mailup_id);
       dbg("HIT! $mailup_id customer found in Mailup feed");
-      $pms->test_log("Mailup id: $mailup_id");
+      $pms->test_log("Mailup id: $mailup_id", $rulename);
       $pms->got_hit($rulename, "", ruletype => 'eval');
       return 1;
     }
@@ -442,7 +442,7 @@ sub esp_maildome_check {
     if ( exists $self->{ESP}->{MAILDOME}->{$maildome_id} ) {
       $pms->set_tag('MAILDOMEID', $maildome_id);
       dbg("HIT! $maildome_id customer found in Maildome feed");
-      $pms->test_log("Maildome id: $maildome_id");
+      $pms->test_log("Maildome id: $maildome_id", $rulename);
       $pms->got_hit($rulename, "", ruletype => 'eval');
       return 1;
     }
@@ -471,7 +471,7 @@ sub esp_mailchimp_check {
     if ( exists $self->{ESP}->{MAILCHIMP}->{$mailchimp_id} ) {
       $pms->set_tag('MAILCHIMPID', $mailchimp_id);
       dbg("HIT! $mailchimp_id customer found in Mailchimp feed");
-      $pms->test_log("Mailchimp id: $mailchimp_id");
+      $pms->test_log("Mailchimp id: $mailchimp_id", $rulename);
       $pms->got_hit($rulename, "", ruletype => 'eval');
       return 1;
     }
@@ -504,7 +504,7 @@ sub esp_constantcontact_check {
     if ( exists $self->{ESP}->{CONSTANTCONTACT}->{$contact_id} ) {
       $pms->set_tag('CONSTANTCONTACTID', $contact_id);
       dbg("HIT! $contact_id customer found in Constant Contact feed");
-      $pms->test_log("Constant Contact id: $contact_id");
+      $pms->test_log("Constant Contact id: $contact_id", $rulename);
       $pms->got_hit($rulename, "", ruletype => 'eval');
       return 1;
     }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/FreeMail.pm Wed Apr  7 09:20:57 2021
@@ -435,7 +435,7 @@ sub _got_hit {
 
     if ($pms->{main}->{conf}->{freemail_add_describe_email}) {
         $email =~ s/\@/[at]/g;
-        $pms->test_log($email);
+        $pms->test_log($email, $rulename);
     }
 
     $pms->got_hit($rulename, "", description => $desc, ruletype => 'eval');

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HashBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HashBL.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HashBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/HashBL.pm Wed Apr  7 09:20:57 2021
@@ -677,7 +677,7 @@ sub _finish_query {
     if ($rr->address =~ $dnsmatch) {
       dbg("$rulename: $ent->{zone} hit '$ent->{value}'");
       $ent->{value} =~ s/\@/[at]/g;
-      $pms->test_log($ent->{value});
+      $pms->test_log($ent->{value}, $rulename);
       $pms->got_hit($rulename, '', ruletype => 'eval');
       return;
     }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm Wed Apr  7 09:20:57 2021
@@ -312,7 +312,7 @@ sub check_phishing {
           $domain = $self->{main}->{registryboundaries}->uri_to_domain($cluri);
           $feedname = $self->{PHISHING}->{$stripped_cluri}->{phishinfo}->{$domain}[0];
           dbg("HIT! $domain [$stripped_cluri] found in $feedname feed");
-          $pms->test_log("$feedname ($domain)");
+          $pms->test_log("$feedname ($domain)", $rulename);
           $pms->got_hit($rulename, "", ruletype => 'eval');
           return 1;
         }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Razor2.pm Wed Apr  7 09:20:57 2021
@@ -675,7 +675,7 @@ sub check_razor2_range {
 
   if ($cf >= $min && $cf <= $max) {
     my $cf_str = sprintf("cf: %3d", $cf);
-    $pms->test_log($cf_str);
+    $pms->test_log($cf_str, $rulename);
     if ($self->{main}->{conf}->{razor_fork}) {
       $pms->got_hit($rulename, "", ruletype => 'eval');
     }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm Wed Apr  7 09:20:57 2021
@@ -1126,13 +1126,10 @@ sub got_dnsbl_hit {
 
   $pms->{uridnsbl_hits}->{$rulename}->{$ent->{domain}} = 1;
 
-  # TODO: this needs to handle multiple domain hits per rule
-  $pms->clear_test_state();
-  #my $uris = join(' ', keys %{$pms->{uridnsbl_hits}->{$rulename}});
   if (defined $ent->{orig_domain}) {
-    $pms->test_log("URIs: $ent->{orig_domain}/$ent->{domain}");
+    $pms->test_log("URI: $ent->{orig_domain}/$ent->{domain}", $rulename);
   } else {
-    $pms->test_log("URIs: $ent->{domain}");
+    $pms->test_log("URI: $ent->{domain}", $rulename);
   }
   $pms->got_hit($rulename, '', ruletype => 'eval');
 }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm Wed Apr  7 09:20:57 2021
@@ -474,7 +474,7 @@ sub _check_host {
       if ( (!$neg && defined $ruleconf->{countries}{$cc}) ||
            ($neg && !defined $ruleconf->{countries}{$cc}) ) {
         dbg("$host ($ip) country $cc - HIT");
-        $pms->test_log("Host: $host in country $cc");
+        $pms->test_log("Host: $host in country $cc", $rulename);
         $pms->got_hit($rulename, "");
         return 1;
       } else {
@@ -496,7 +496,7 @@ sub _check_host {
       if ( (!$neg && defined $ruleconf->{continents}{$cc}) ||
            ($neg && !defined $ruleconf->{continents}{$cc}) ) {
         dbg("$host ($ip) continent $cc - HIT");
-        $pms->test_log("Host: $host in continent $cc");
+        $pms->test_log("Host: $host in continent $cc", $rulename);
         $pms->got_hit($rulename, "");
         return 1;
       } else {
@@ -516,7 +516,7 @@ sub _check_host {
         my $ispkey = uc($isp); $ispkey =~ s/\s+//gs;
         if (defined $ruleconf->{isps}{$ispkey}) {
           dbg("$host ($ip) isp \"$isp\" - HIT");
-          $pms->test_log("Host: $host in isp $isp");
+          $pms->test_log("Host: $host in isp $isp", $rulename);
           $pms->got_hit($rulename, "");
           return 1;
         } else {
@@ -532,7 +532,7 @@ sub _check_host {
     foreach my $ip (@$addrs) {
       if ($ruleconf->{netset}->contains_ip($ip)) {
         dbg("$host ($ip) matches cidr - HIT");
-        $pms->test_log("Host: $host in cidr");
+        $pms->test_log("Host: $host in cidr", $rulename);
         $pms->got_hit($rulename, "");
         return 1;
       } else {

Modified: spamassassin/trunk/t/uribl_all_types.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/uribl_all_types.t?rev=1888466&r1=1888465&r2=1888466&view=diff
==============================================================================
--- spamassassin/trunk/t/uribl_all_types.t (original)
+++ spamassassin/trunk/t/uribl_all_types.t Wed Apr  7 09:20:57 2021
@@ -15,10 +15,10 @@ plan tests => 3;
 
 %patterns = (
 
-   q{ X_URIBL_IPSONLY [URIs: 144.137.3.98] } => 'X_URIBL_IPSONLY',
+   q{ X_URIBL_IPSONLY [URI: 144.137.3.98] } => 'X_URIBL_IPSONLY',
 
    # can be either uribl-example-b.com or uribl-example-c.com
-   q{ X_URIBL_DOMSONLY [URIs: uribl-example} => 'X_URIBL_DOMSONLY',
+   q{ X_URIBL_DOMSONLY [URI: uribl-example} => 'X_URIBL_DOMSONLY',
 
 );