View | Details | Raw Unified | Return to bug 6335
Collapse All | Expand All

(-)lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (-2 / +14 lines)
Lines 370-376 Link Here
370
    }
370
    }
371
    else {
371
    else {
372
      # trim down to a limited number - pick randomly
372
      # trim down to a limited number - pick randomly
373
      my $i;
374
      while (@domains && keys %domlist < $umd) {
373
      while (@domains && keys %domlist < $umd) {
375
        my $r = int rand (scalar @domains);
374
        my $r = int rand (scalar @domains);
376
        $domlist{splice (@domains, $r, 1)} = 1;
375
        $domlist{splice (@domains, $r, 1)} = 1;
Lines 644-651 Link Here
644
643
645
  my $obj = { dom => $dom };
644
  my $obj = { dom => $dom };
646
645
646
  my $cf = $scanner->{uridnsbl_active_rules_revipbl};
647
  my $dnsbl_lookup_ips = 0;
648
  foreach my $rulename (keys %{$cf}) {
649
    if ($scanner->{conf}->{tflags}->{$rulename} !~ /\bdomains_only\b/) {
650
      $dnsbl_lookup_ips++;
651
    }
652
  }
653
654
  my $is_ip = 0;
647
  my $single_dnsbl = 0;
655
  my $single_dnsbl = 0;
648
  if ($dom =~ /^\d+\.\d+\.\d+\.\d+$/) {
656
  if ($dnsbl_lookup_ips && $dom =~ /^\d+\.\d+\.\d+\.\d+$/) {
649
    my $IPV4_ADDRESS = IPV4_ADDRESS;
657
    my $IPV4_ADDRESS = IPV4_ADDRESS;
650
    my $IP_PRIVATE = IP_PRIVATE;
658
    my $IP_PRIVATE = IP_PRIVATE;
651
    # only look up the IP if it is public and valid
659
    # only look up the IP if it is public and valid
Lines 655-660 Link Here
655
      if ($dom =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {
663
      if ($dom =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {
656
	$dom = "$4.$3.$2.$1";
664
	$dom = "$4.$3.$2.$1";
657
	$single_dnsbl = 1;
665
	$single_dnsbl = 1;
666
        $is_ip = 1;
658
      }
667
      }
659
    }
668
    }
660
  }
669
  }
Lines 670-675 Link Here
670
  if ($single_dnsbl) {
679
  if ($single_dnsbl) {
671
    # look up the domain in the RHSBL subset
680
    # look up the domain in the RHSBL subset
672
    foreach my $rulename (keys %{$rhsblrules}) {
681
    foreach my $rulename (keys %{$rhsblrules}) {
682
      next if ($is_ip &&
683
              $scanner->{conf}->{tflags}->{$rulename} =~ /\bdomains_only\b/);
684
673
      my $rulecf = $scanner->{conf}->{uridnsbls}->{$rulename};
685
      my $rulecf = $scanner->{conf}->{uridnsbls}->{$rulename};
674
      $self->lookup_single_dnsbl($scanner, $obj, $rulename,
686
      $self->lookup_single_dnsbl($scanner, $obj, $rulename,
675
				 $dom, $rulecf->{zone}, $rulecf->{type});
687
				 $dom, $rulecf->{zone}, $rulecf->{type});
(-)t/uribl_domains_only.t (+51 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use lib '.'; use lib 't';
4
use SATest; sa_t_init("uribl_domains_only");
5
6
use constant TEST_ENABLED => conf_bool('run_net_tests') && conf_bool('run_long_tests');
7
use constant HAS_NET_DNS => eval { require Net::DNS; };
8
# bug 3806:
9
# Do not run this test with version of Sys::Hostname::Long older than 1.4
10
# on non-Linux unices as root, due to a bug in Sys::Hostname::Long
11
# (which is used by Net::DNS)
12
use constant IS_LINUX   => $^O eq 'linux';
13
use constant IS_WINDOWS => ($^O =~ /^(mswin|dos|os2)/oi);
14
use constant AM_ROOT    => $< == 0;
15
use constant HAS_SAFE_HOSTNAME =>
16
  eval { require Sys::Hostname::Long; Sys::Hostname::Long->VERSION(1.4) };
17
18
use constant DO_RUN =>
19
  TEST_ENABLED && HAS_NET_DNS &&
20
  (HAS_SAFE_HOSTNAME || !AM_ROOT || IS_LINUX || IS_WINDOWS);
21
22
use Test;
23
24
BEGIN {
25
  plan tests => (DO_RUN ? 2 : 0),
26
};
27
28
exit unless (DO_RUN);
29
30
# ---------------------------------------------------------------------------
31
32
%anti_patterns = (
33
 q{ X_URIBL_DOMSONLY } => 'A',
34
);
35
36
tstlocalrules(q{
37
38
  rbl_timeout 30
39
40
  urirhssub  X_URIBL_DOMSONLY  dnsbltest.spamassassin.org.    A 2
41
  body       X_URIBL_DOMSONLY  eval:check_uridnsbl('X_URIBL_DOMSONLY')
42
  tflags     X_URIBL_DOMSONLY  net domains_only
43
44
  add_header all RBL _RBL_
45
46
});
47
48
# note: don't leave -D here, it causes spurious passes
49
ok sarun ("-t < data/spam/dnsbl_domsonly.eml 2>&1", \&patterns_run_cb);
50
ok_all_patterns();
51
0
  + *
52
  + *
(-)t/uribl.t (-1 / +6 lines)
Lines 22-28 Link Here
22
use Test;
22
use Test;
23
23
24
BEGIN {
24
BEGIN {
25
  plan tests => (DO_RUN ? 5 : 0),
25
  plan tests => (DO_RUN ? 6 : 0),
26
};
26
};
27
27
28
exit unless (DO_RUN);
28
exit unless (DO_RUN);
Lines 34-39 Link Here
34
 q{ X_URIBL_B } => 'B',
34
 q{ X_URIBL_B } => 'B',
35
 q{ X_URIBL_NS } => 'NS',
35
 q{ X_URIBL_NS } => 'NS',
36
 q{ X_URIBL_FULL_NS } => 'FULL_NS',
36
 q{ X_URIBL_FULL_NS } => 'FULL_NS',
37
 q{ X_URIBL_DOMSONLY } => 'X_URIBL_DOMSONLY',
37
);
38
);
38
39
39
tstlocalrules(q{
40
tstlocalrules(q{
Lines 56-61 Link Here
56
  body       X_URIBL_FULL_NS  eval:check_uridnsbl('X_URIBL_FULL_NS')
57
  body       X_URIBL_FULL_NS  eval:check_uridnsbl('X_URIBL_FULL_NS')
57
  tflags     X_URIBL_FULL_NS  net
58
  tflags     X_URIBL_FULL_NS  net
58
59
60
  urirhssub  X_URIBL_DOMSONLY  dnsbltest.spamassassin.org.    A 2
61
  body       X_URIBL_DOMSONLY  eval:check_uridnsbl('X_URIBL_DOMSONLY')
62
  tflags     X_URIBL_DOMSONLY  net domains_only
63
59
  add_header all RBL _RBL_
64
  add_header all RBL _RBL_
60
65
61
});
66
});
(-)t/data/spam/dnsbl_domsonly.eml (+11 lines)
Line 0 Link Here
1
From spammer@example.net  Fri Dec  7 11:07:10 2001
2
Received: from evil.example.net [144.137.3.98] by chaos.example.net
3
    for someone@example.com; Fri, 07 Dec 2001 11:07:15 +1100 (EST)
4
From: "DNSBL Testing" <spammer@example.com>
5
To: someone@example.com
6
Subject: no subject needed
7
Date: Fri, 7 Dec 2001 07:01:03
8
Message-Id: <20011206235802.4FD6F1143D6@mail.netnoteinc.com>
9
10
I should not be listed: http://144.137.3.98/blah
11

Return to bug 6335