Index: lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm =================================================================== --- lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (revision 911214) +++ lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (working copy) @@ -370,7 +370,6 @@ } else { # trim down to a limited number - pick randomly - my $i; while (@domains && keys %domlist < $umd) { my $r = int rand (scalar @domains); $domlist{splice (@domains, $r, 1)} = 1; @@ -644,8 +643,17 @@ my $obj = { dom => $dom }; + my $cf = $scanner->{uridnsbl_active_rules_revipbl}; + my $dnsbl_lookup_ips = 0; + foreach my $rulename (keys %{$cf}) { + if ($scanner->{conf}->{tflags}->{$rulename} !~ /\bdomains_only\b/) { + $dnsbl_lookup_ips++; + } + } + + my $is_ip = 0; my $single_dnsbl = 0; - if ($dom =~ /^\d+\.\d+\.\d+\.\d+$/) { + if ($dnsbl_lookup_ips && $dom =~ /^\d+\.\d+\.\d+\.\d+$/) { my $IPV4_ADDRESS = IPV4_ADDRESS; my $IP_PRIVATE = IP_PRIVATE; # only look up the IP if it is public and valid @@ -655,6 +663,7 @@ if ($dom =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { $dom = "$4.$3.$2.$1"; $single_dnsbl = 1; + $is_ip = 1; } } } @@ -670,6 +679,9 @@ if ($single_dnsbl) { # look up the domain in the RHSBL subset foreach my $rulename (keys %{$rhsblrules}) { + next if ($is_ip && + $scanner->{conf}->{tflags}->{$rulename} =~ /\bdomains_only\b/); + my $rulecf = $scanner->{conf}->{uridnsbls}->{$rulename}; $self->lookup_single_dnsbl($scanner, $obj, $rulename, $dom, $rulecf->{zone}, $rulecf->{type}); Index: t/uribl_domains_only.t =================================================================== --- t/uribl_domains_only.t (revision 0) +++ t/uribl_domains_only.t (revision 0) @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +use lib '.'; use lib 't'; +use SATest; sa_t_init("uribl_domains_only"); + +use constant TEST_ENABLED => conf_bool('run_net_tests') && conf_bool('run_long_tests'); +use constant HAS_NET_DNS => eval { require Net::DNS; }; +# bug 3806: +# Do not run this test with version of Sys::Hostname::Long older than 1.4 +# on non-Linux unices as root, due to a bug in Sys::Hostname::Long +# (which is used by Net::DNS) +use constant IS_LINUX => $^O eq 'linux'; +use constant IS_WINDOWS => ($^O =~ /^(mswin|dos|os2)/oi); +use constant AM_ROOT => $< == 0; +use constant HAS_SAFE_HOSTNAME => + eval { require Sys::Hostname::Long; Sys::Hostname::Long->VERSION(1.4) }; + +use constant DO_RUN => + TEST_ENABLED && HAS_NET_DNS && + (HAS_SAFE_HOSTNAME || !AM_ROOT || IS_LINUX || IS_WINDOWS); + +use Test; + +BEGIN { + plan tests => (DO_RUN ? 2 : 0), +}; + +exit unless (DO_RUN); + +# --------------------------------------------------------------------------- + +%anti_patterns = ( + q{ X_URIBL_DOMSONLY } => 'A', +); + +tstlocalrules(q{ + + rbl_timeout 30 + + urirhssub X_URIBL_DOMSONLY dnsbltest.spamassassin.org. A 2 + body X_URIBL_DOMSONLY eval:check_uridnsbl('X_URIBL_DOMSONLY') + tflags X_URIBL_DOMSONLY net domains_only + + add_header all RBL _RBL_ + +}); + +# note: don't leave -D here, it causes spurious passes +ok sarun ("-t < data/spam/dnsbl_domsonly.eml 2>&1", \&patterns_run_cb); +ok_all_patterns(); + Property changes on: t/uribl_domains_only.t ___________________________________________________________________ Added: svn:executable + * Index: t/uribl.t =================================================================== --- t/uribl.t (revision 911214) +++ t/uribl.t (working copy) @@ -22,7 +22,7 @@ use Test; BEGIN { - plan tests => (DO_RUN ? 5 : 0), + plan tests => (DO_RUN ? 6 : 0), }; exit unless (DO_RUN); @@ -34,6 +34,7 @@ q{ X_URIBL_B } => 'B', q{ X_URIBL_NS } => 'NS', q{ X_URIBL_FULL_NS } => 'FULL_NS', + q{ X_URIBL_DOMSONLY } => 'X_URIBL_DOMSONLY', ); tstlocalrules(q{ @@ -56,6 +57,10 @@ body X_URIBL_FULL_NS eval:check_uridnsbl('X_URIBL_FULL_NS') tflags X_URIBL_FULL_NS net + urirhssub X_URIBL_DOMSONLY dnsbltest.spamassassin.org. A 2 + body X_URIBL_DOMSONLY eval:check_uridnsbl('X_URIBL_DOMSONLY') + tflags X_URIBL_DOMSONLY net domains_only + add_header all RBL _RBL_ }); Index: t/data/spam/dnsbl_domsonly.eml =================================================================== --- t/data/spam/dnsbl_domsonly.eml (revision 0) +++ t/data/spam/dnsbl_domsonly.eml (revision 0) @@ -0,0 +1,11 @@ +From spammer@example.net Fri Dec 7 11:07:10 2001 +Received: from evil.example.net [144.137.3.98] by chaos.example.net + for someone@example.com; Fri, 07 Dec 2001 11:07:15 +1100 (EST) +From: "DNSBL Testing" +To: someone@example.com +Subject: no subject needed +Date: Fri, 7 Dec 2001 07:01:03 +Message-Id: <20011206235802.4FD6F1143D6@mail.netnoteinc.com> + +I should not be listed: http://144.137.3.98/blah +