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/08 08:35:36 UTC

svn commit: r1888502 - in /spamassassin/trunk: UPGRADE lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm t/uribl.t

Author: hege
Date: Thu Apr  8 08:35:35 2021
New Revision: 1888502

URL: http://svn.apache.org/viewvc?rev=1888502&view=rev
Log:
Bug 7835 - tflags notrim support for urirhsbl/urirhssub

Modified:
    spamassassin/trunk/UPGRADE
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
    spamassassin/trunk/t/uribl.t

Modified: spamassassin/trunk/UPGRADE
URL: http://svn.apache.org/viewvc/spamassassin/trunk/UPGRADE?rev=1888502&r1=1888501&r2=1888502&view=diff
==============================================================================
--- spamassassin/trunk/UPGRADE (original)
+++ spamassassin/trunk/UPGRADE Thu Apr  8 08:35:35 2021
@@ -135,6 +135,10 @@ Note for Users Upgrading to SpamAssassin
   $pms->clear_test_state(), not needed anymore.  $pms->test_log() accepts
   $rulename as second argument.
 
+- URIDNSBL: urirhsbl/urirhssub rules support "notrim" tflag, which
+  forces querying the full hostname, instead of trimmed domain.  This works
+  better if the specific uribl supports this mode. (Bug 7835)
+
 Note for Users Upgrading to SpamAssassin 3.4.4
 ----------------------------------------------
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm?rev=1888502&r1=1888501&r2=1888502&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm Thu Apr  8 08:35:35 2021
@@ -153,10 +153,11 @@ define a body-eval rule calling C<check_
 
 An RHSBL zone is one where the domain name is looked up, as a string; e.g. a
 URI using the domain C<foo.com> will cause a lookup of
-C<foo.com.uriblzone.net>.  Note that hostnames are stripped from the domain
-used in the URIBL lookup, so the domain C<foo.bar.com> will look up
+C<foo.com.uriblzone.net>.  Note that hostnames are trimmed to the domain
+portion in the URIBL lookup, so the domain C<foo.bar.com> will look up
 C<bar.com.uriblzone.net>, and C<foo.bar.co.uk> will look up
-C<bar.co.uk.uriblzone.net>.
+C<bar.co.uk.uriblzone.net>.  Using tflag C<notrim> will force full hostname
+lookup, but the specific uribl must support this method.
 
 If an URI consists of an IP address instead of a hostname, the IP address is
 looked up (using the standard reversed quads method) in each C<rhsbl_zone>.
@@ -186,8 +187,9 @@ for a single decimal or hex form the fol
 Some typical examples of a sub-test are: 127.0.1.2, 127.0.1.20-127.0.1.39,
 127.2.3.0/255.255.255.0, 0.0.0.16/0.0.0.16, 0x10/0x10, 16, 0x10 .
 
-Note that, as with C<urirhsbl>, you must also define a body-eval rule calling
-C<check_uridnsbl()> to use this.
+Note that, as with C<urirhsbl>, you must also define a body-eval rule
+calling C<check_uridnsbl()> to use this.  Hostname to domain trimming is
+also done similarly.
 
 Example:
 
@@ -270,6 +272,12 @@ directives. Host names from URLs will be
 will be sent to blocklists. When both 'ns' and 'a' flags are specified,
 both queries will be performed.
 
+=item tflags NAME_OF_RULE notrim
+
+The full hostname component will be matched against the named
+"urirhsbl"/"urirhssub" rule, instead of using the trimmed domain.
+This works better, but the specific uribl must support this method.
+
 =back
 
 =head1 ADMINISTRATOR SETTINGS
@@ -864,7 +872,9 @@ sub query_hosts_or_domains {
     # Launch RHSBL checks
     foreach my $rulename (@rhsblrules) {
       my $rulecf = $conf->{uridnsbls}->{$rulename};
-      $self->lookup_single_dnsbl($pms, $domain, $rulename,
+      # Check notrim tflag to query full hostname (Bug 7835)
+      my $query = ($conf->{tflags}->{$rulename}||'') =~ /\bnotrim\b/ ? $host : $domain;
+      $self->lookup_single_dnsbl($pms, $query, $rulename,
         $rulecf->{zone}, $rulecf->{type});
     }
   }
@@ -1142,5 +1152,6 @@ sub has_tflags_domains_only { 1 }
 sub has_subtest_for_ranges { 1 }
 sub has_uridnsbl_for_a { 1 }  # uridnsbl rules recognize tflags 'a' and 'ns'
 sub has_uridnsbl_a_ns { 1 }  # has an actually working 'a' flag, unlike above :-(
+sub has_tflags_notrim { 1 }
 
 1;

Modified: spamassassin/trunk/t/uribl.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/uribl.t?rev=1888502&r1=1888501&r2=1888502&view=diff
==============================================================================
--- spamassassin/trunk/t/uribl.t (original)
+++ spamassassin/trunk/t/uribl.t Thu Apr  8 08:35:35 2021
@@ -7,7 +7,7 @@ use Test::More;
 plan skip_all => "Long running tests disabled" unless conf_bool('run_long_tests');
 plan skip_all => "Net tests disabled"          unless conf_bool('run_net_tests');
 plan skip_all => "Can't use Net::DNS Safely"   unless can_use_net_dns_safely();
-plan tests => 7;
+plan tests => 8;
 
 # ---------------------------------------------------------------------------
 
@@ -17,6 +17,7 @@ plan tests => 7;
  q{ X_URIBL_NS } => 'NS',
  q{ X_URIBL_DOMSONLY } => 'X_URIBL_DOMSONLY',
  q{ META_URIBL_A } => 'META_URIBL_A',
+ q{ X_URIBL_NOTRIM } => 'X_URIBL_NOTRIM',
 );
 
 %anti_patterns = (
@@ -52,6 +53,11 @@ tstlocalrules(q{
   # Bug 7897 - test that meta rules depending on net rules hit
   meta META_URIBL_A X_URIBL_A
 
+  # Bug 7835 - tflags notrim
+  urirhssub  X_URIBL_NOTRIM  dnsbltest.spamassassin.org.    A 16
+  body       X_URIBL_NOTRIM  eval:check_uridnsbl('X_URIBL_NOTRIM')
+  tflags     X_URIBL_NOTRIM  net domains_only notrim
+
 });
 
 # note: don't leave -D here, it causes spurious passes