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 2020/06/08 05:18:37 UTC

svn commit: r1878575 - in /spamassassin: branches/3.4/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm

Author: hege
Date: Mon Jun  8 05:18:37 2020
New Revision: 1878575

URL: http://svn.apache.org/viewvc?rev=1878575&view=rev
Log:
Log all URIBL hit domains in report

Modified:
    spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm

Modified: spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm?rev=1878575&r1=1878574&r2=1878575&view=diff
==============================================================================
--- spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (original)
+++ spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm Mon Jun  8 05:18:37 2020
@@ -1159,11 +1159,6 @@ sub got_dnsbl_hit {
   $str =~ s/\s+/  /gs;	# long whitespace => short
   dbg("uridnsbl: domain \"$dom\" listed ($rulename): $str");
 
-  if (!defined $pms->{uridnsbl_hits}->{$rulename}) {
-    $pms->{uridnsbl_hits}->{$rulename} = { };
-  };
-  $pms->{uridnsbl_hits}->{$rulename}->{$dom} = 1;
-
   if ( $pms->{uridnsbl_active_rules_nsrevipbl}->{$rulename}
     || $pms->{uridnsbl_active_rules_arevipbl}->{$rulename}
     || $pms->{uridnsbl_active_rules_nsrhsbl}->{$rulename}
@@ -1172,14 +1167,20 @@ sub got_dnsbl_hit {
     || $pms->{uridnsbl_active_rules_rhsbl_ipsonly}->{$rulename}
     || $pms->{uridnsbl_active_rules_rhsbl_domsonly}->{$rulename})
   {
-    # TODO: this needs to handle multiple domain hits per rule
-    $pms->clear_test_state();
-    my $uris = join (' ', keys %{$pms->{uridnsbl_hits}->{$rulename}});
-    $pms->test_log ("URIs: $uris");
-    $pms->got_hit ($rulename, "");
+    # Hits are saved and called in check_cleanup
+    $pms->{uridnsbl_hits}->{$rulename}->{$dom} = 1;
+  }
+}
+
+sub check_cleanup {
+  my ($self, $opts) = @_;
+
+  my $pms = $opts->{permsgstatus};
 
-    # note that this rule has completed (since it got at least 1 hit)
-    $pms->register_async_rule_finish($rulename);
+  # Call any remaining hits
+  foreach my $rulename (keys %{$pms->{uridnsbl_hits}}) {
+    $pms->test_log("URIs: ".join(', ', sort keys %{$pms->{uridnsbl_hits}->{$rulename}}));
+    $pms->got_hit($rulename, '');
   }
 }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm?rev=1878575&r1=1878574&r2=1878575&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm Mon Jun  8 05:18:37 2020
@@ -1124,17 +1124,24 @@ sub got_dnsbl_hit {
   $str =~ s/\s+/  /gs;	# long whitespace => short
   dbg("uridnsbl: domain \"$ent->{domain}\" listed ($rulename): $str");
 
-  $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}});
+  # Hits are saved and called in check_cleanup
   if (defined $ent->{orig_domain}) {
-    $pms->test_log("URIs: $ent->{orig_domain}/$ent->{domain}");
+    $pms->{uridnsbl_hits}->{$rulename}->{"$ent->{orig_domain}/$ent->{domain}"} = 1;
   } else {
-    $pms->test_log("URIs: $ent->{domain}");
+    $pms->{uridnsbl_hits}->{$rulename}->{"$ent->{domain}"} = 1;
+  }
+}
+
+sub check_cleanup {
+  my ($self, $opts) = @_;
+
+  my $pms = $opts->{permsgstatus};
+
+  # Call any remaining hits
+  foreach my $rulename (keys %{$pms->{uridnsbl_hits}}) {
+    $pms->test_log("URIs: ".join(', ', sort keys %{$pms->{uridnsbl_hits}->{$rulename}}));
+    $pms->got_hit($rulename, '', ruletype => 'eval');
   }
-  $pms->got_hit($rulename, '', ruletype => 'eval');
 }
 
 # ---------------------------------------------------------------------------