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

(-)MANIFEST (+5 lines)
Lines 530-532 Link Here
530
t/whitelist_to.t
530
t/whitelist_to.t
531
t/zz_cleanup.t
531
t/zz_cleanup.t
532
t/spamc_bug6176.t
532
t/spamc_bug6176.t
533
t/data/spam/dnsbl_domsonly.eml
534
t/uribl_domains_only.t
535
t/data/spam/dnsbl_ipsonly.eml
536
t/uribl_all_types.t
537
t/uribl_ips_only.t
(-)lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (-2 / +25 lines)
Lines 187-192 Link Here
187
Note that, as with C<urirhsbl>, you must also define a body-eval rule calling
187
Note that, as with C<urirhsbl>, you must also define a body-eval rule calling
188
C<check_uridnsbl()> to use this.
188
C<check_uridnsbl()> to use this.
189
189
190
=item tflags NAME_OF_RULE ips_only
191
192
Only URIs containing IP addresses as the "host" component will be matched
193
against the named rule.
194
195
=item tflags NAME_OF_RULE domains_only
196
197
Only URIs containing a non-IP-address "host" component will be matched against
198
the named rule.
199
190
=back
200
=back
191
201
192
=head1 ADMINISTRATOR SETTINGS
202
=head1 ADMINISTRATOR SETTINGS
Lines 370-376 Link Here
370
    }
380
    }
371
    else {
381
    else {
372
      # trim down to a limited number - pick randomly
382
      # trim down to a limited number - pick randomly
373
      my $i;
374
      while (@domains && keys %domlist < $umd) {
383
      while (@domains && keys %domlist < $umd) {
375
        my $r = int rand (scalar @domains);
384
        my $r = int rand (scalar @domains);
376
        $domlist{splice (@domains, $r, 1)} = 1;
385
        $domlist{splice (@domains, $r, 1)} = 1;
Lines 644-651 Link Here
644
653
645
  my $obj = { dom => $dom };
654
  my $obj = { dom => $dom };
646
655
656
  my $tflags = $scanner->{conf}->{tflags};
657
  my $cf = $scanner->{uridnsbl_active_rules_revipbl};
658
  my $dnsbl_lookup_ips = 0;
659
  foreach my $rulename (keys %{$cf}) {
660
    if ($tflags->{$rulename} !~ /\bdomains_only\b/) {
661
      $dnsbl_lookup_ips++;
662
    }
663
  }
664
665
  my $is_ip = 0;
647
  my $single_dnsbl = 0;
666
  my $single_dnsbl = 0;
648
  if ($dom =~ /^\d+\.\d+\.\d+\.\d+$/) {
667
  if ($dnsbl_lookup_ips && $dom =~ /^\d+\.\d+\.\d+\.\d+$/) {
649
    my $IPV4_ADDRESS = IPV4_ADDRESS;
668
    my $IPV4_ADDRESS = IPV4_ADDRESS;
650
    my $IP_PRIVATE = IP_PRIVATE;
669
    my $IP_PRIVATE = IP_PRIVATE;
651
    # only look up the IP if it is public and valid
670
    # only look up the IP if it is public and valid
Lines 655-660 Link Here
655
      if ($dom =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {
674
      if ($dom =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {
656
	$dom = "$4.$3.$2.$1";
675
	$dom = "$4.$3.$2.$1";
657
	$single_dnsbl = 1;
676
	$single_dnsbl = 1;
677
        $is_ip = 1;
658
      }
678
      }
659
    }
679
    }
660
  }
680
  }
Lines 670-675 Link Here
670
  if ($single_dnsbl) {
690
  if ($single_dnsbl) {
671
    # look up the domain in the RHSBL subset
691
    # look up the domain in the RHSBL subset
672
    foreach my $rulename (keys %{$rhsblrules}) {
692
    foreach my $rulename (keys %{$rhsblrules}) {
693
      next if ($is_ip && $tflags->{$rulename} =~ /\bdomains_only\b/);
694
      next if (!$is_ip && $tflags->{$rulename} =~ /\bips_only\b/);
695
673
      my $rulecf = $scanner->{conf}->{uridnsbls}->{$rulename};
696
      my $rulecf = $scanner->{conf}->{uridnsbls}->{$rulename};
674
      $self->lookup_single_dnsbl($scanner, $obj, $rulename,
697
      $self->lookup_single_dnsbl($scanner, $obj, $rulename,
675
				 $dom, $rulecf->{zone}, $rulecf->{type});
698
				 $dom, $rulecf->{zone}, $rulecf->{type});
(-)rules/50_scores.cf (+1 lines)
Lines 1021-1026 Link Here
1021
score URIBL_WS_SURBL 0 1.659 0 1.608 # n=0 n=2
1021
score URIBL_WS_SURBL 0 1.659 0 1.608 # n=0 n=2
1022
score URIBL_BLACK 0 1.775 0 1.725 # n=0 n=2
1022
score URIBL_BLACK 0 1.775 0 1.725 # n=0 n=2
1023
score URIBL_GREY 0 1.084 0 0.424 # n=0 n=2
1023
score URIBL_GREY 0 1.084 0 0.424 # n=0 n=2
1024
score URIBL_DBL 0 1.7 0 1.7
1024
# </gen:mutable>
1025
# </gen:mutable>
1025
# score URIBL_GREY 0.25
1026
# score URIBL_GREY 0.25
1026
score URIBL_RED 0.001
1027
score URIBL_RED 0.001
(-)rules/25_uribl.cf (-1 / +8 lines)
Lines 31-37 Link Here
31
ifplugin Mail::SpamAssassin::Plugin::URIDNSBL
31
ifplugin Mail::SpamAssassin::Plugin::URIDNSBL
32
32
33
###########################################################################
33
###########################################################################
34
## SBL
34
## Spamhaus
35
35
36
uridnssub       URIBL_SBL       zen.spamhaus.org.       A   127.0.0.2
36
uridnssub       URIBL_SBL       zen.spamhaus.org.       A   127.0.0.2
37
body            URIBL_SBL       eval:check_uridnsbl('URIBL_SBL')
37
body            URIBL_SBL       eval:check_uridnsbl('URIBL_SBL')
Lines 39-44 Link Here
39
tflags          URIBL_SBL       net
39
tflags          URIBL_SBL       net
40
reuse           URIBL_SBL
40
reuse           URIBL_SBL
41
41
42
# DBL, http://www.spamhaus.org/dbl/ .  Note that hits return 127.0.1.x
43
# A records, so we use a 32-bit mask to match that /24 range.
44
uridnssub       URIBL_DBL       dbl.spamhaus.org.       A   2130706688
45
body            URIBL_DBL       eval:check_uridnsbl('URIBL_DBL')
46
describe        URIBL_DBL       Contains an URL listed in the DBL blocklist
47
tflags          URIBL_DBL       net domains_only
48
42
###########################################################################
49
###########################################################################
43
## SURBL
50
## SURBL
44
51
(-)t/uribl_all_types.t (+46 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
# bug 6335: ensure that both domains_only and ips_only URIDNSBL rules can coexist
4
5
use lib '.'; use lib 't';
6
use SATest; sa_t_init("uribl_all_types");
7
8
use constant TEST_ENABLED => conf_bool('run_net_tests') && conf_bool('run_long_tests');
9
use constant DO_RUN => TEST_ENABLED && can_use_net_dns_safely();
10
use Test;
11
12
BEGIN {
13
  plan tests => (DO_RUN ? 3 : 0),
14
};
15
16
exit unless (DO_RUN);
17
18
# ---------------------------------------------------------------------------
19
20
%patterns = (
21
22
   q{ X_URIBL_IPSONLY [URIs: 144.137.3.98] } => 'X_URIBL_IPSONLY',
23
   q{ X_URIBL_DOMSONLY [URIs: uribl-example-c.com] } => 'X_URIBL_DOMSONLY',
24
25
);
26
27
tstlocalrules(q{
28
29
  rbl_timeout 30
30
31
  urirhssub  X_URIBL_IPSONLY  dnsbltest.spamassassin.org.    A 2
32
  body       X_URIBL_IPSONLY  eval:check_uridnsbl('X_URIBL_IPSONLY')
33
  tflags     X_URIBL_IPSONLY  net ips_only
34
35
  urirhssub  X_URIBL_DOMSONLY  dnsbltest.spamassassin.org.    A 4
36
  body       X_URIBL_DOMSONLY  eval:check_uridnsbl('X_URIBL_DOMSONLY')
37
  tflags     X_URIBL_DOMSONLY  net domains_only
38
39
  add_header all RBL _RBL_
40
41
});
42
43
# note: don't leave -D here, it causes spurious passes
44
ok sarun ("-t < data/spam/dnsbl.eml 2>&1", \&patterns_run_cb);
45
ok_all_patterns();
46
(-)t/uribl_ips_only.t (+38 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
# bug 6335: ips_only URIDNSBL rules
3
4
use lib '.'; use lib 't';
5
use SATest; sa_t_init("uribl_ips_only");
6
7
use constant TEST_ENABLED => conf_bool('run_net_tests') && conf_bool('run_long_tests');
8
use constant DO_RUN => TEST_ENABLED && can_use_net_dns_safely();
9
use Test;
10
11
BEGIN {
12
  plan tests => (DO_RUN ? 2 : 0),
13
};
14
15
exit unless (DO_RUN);
16
17
# ---------------------------------------------------------------------------
18
19
%anti_patterns = (
20
 q{ X_URIBL_IPSONLY } => 'A',
21
);
22
23
tstlocalrules(q{
24
25
  rbl_timeout 30
26
27
  urirhssub  X_URIBL_IPSONLY  dnsbltest.spamassassin.org.    A 2
28
  body       X_URIBL_IPSONLY  eval:check_uridnsbl('X_URIBL_IPSONLY')
29
  tflags     X_URIBL_IPSONLY  net ips_only
30
31
  add_header all RBL _RBL_
32
33
});
34
35
# note: don't leave -D here, it causes spurious passes
36
ok sarun ("-t < data/spam/dnsbl_ipsonly.eml 2>&1", \&patterns_run_cb);
37
ok_all_patterns();
38
(-)t/uribl_domains_only.t (+38 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
# bug 6335: domains_only URIDNSBL rules
3
4
use lib '.'; use lib 't';
5
use SATest; sa_t_init("uribl_domains_only");
6
7
use constant TEST_ENABLED => conf_bool('run_net_tests') && conf_bool('run_long_tests');
8
use constant DO_RUN => TEST_ENABLED && can_use_net_dns_safely();
9
use Test;
10
11
BEGIN {
12
  plan tests => (DO_RUN ? 2 : 0),
13
};
14
15
exit unless (DO_RUN);
16
17
# ---------------------------------------------------------------------------
18
19
%anti_patterns = (
20
 q{ X_URIBL_DOMSONLY } => 'A',
21
);
22
23
tstlocalrules(q{
24
25
  rbl_timeout 30
26
27
  urirhssub  X_URIBL_DOMSONLY  dnsbltest.spamassassin.org.    A 2
28
  body       X_URIBL_DOMSONLY  eval:check_uridnsbl('X_URIBL_DOMSONLY')
29
  tflags     X_URIBL_DOMSONLY  net domains_only
30
31
  add_header all RBL _RBL_
32
33
});
34
35
# note: don't leave -D here, it causes spurious passes
36
ok sarun ("-t < data/spam/dnsbl_domsonly.eml 2>&1", \&patterns_run_cb);
37
ok_all_patterns();
38
(-)t/dnsbl.t (-15 / +1 lines)
Lines 4-24 Link Here
4
use SATest; sa_t_init("dns");
4
use SATest; sa_t_init("dns");
5
5
6
use constant TEST_ENABLED => conf_bool('run_net_tests') && conf_bool('run_long_tests');
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; };
7
use constant DO_RUN => TEST_ENABLED && can_use_net_dns_safely();
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;
8
use Test;
23
9
24
BEGIN {
10
BEGIN {
(-)t/SATest.pm (+15 lines)
Lines 21-26 Link Here
21
  our $SKIP_SPAMC_TESTS;
21
  our $SKIP_SPAMC_TESTS;
22
  our $SSL_AVAILABLE;
22
  our $SSL_AVAILABLE;
23
  our $SKIP_SETUID_NOBODY_TESTS = 0;
23
  our $SKIP_SETUID_NOBODY_TESTS = 0;
24
  our $SKIP_DNSBL_TESTS = 0;
24
}
25
}
25
26
26
# Set up for testing. Exports (as global vars):
27
# Set up for testing. Exports (as global vars):
Lines 961-964 Link Here
961
962
962
sub dbgprint { print STDOUT "[".time()."] ".$_[0]; }
963
sub dbgprint { print STDOUT "[".time()."] ".$_[0]; }
963
964
965
sub can_use_net_dns_safely {
966
  return unless eval { require Net::DNS; };
967
968
  # bug 3806:
969
  # Do not run this test with version of Sys::Hostname::Long older than 1.4
970
  # on non-Linux unices as root, due to a bug in Sys::Hostname::Long
971
  # (which is used by Net::DNS)
972
973
  return 1 if eval { require Sys::Hostname::Long; Sys::Hostname::Long->VERSION(1.4) };
974
  return 1 if ($< != 0);
975
  return 1 if ($^O =~ /^(linux|mswin|dos|os2)/oi);
976
  return;
977
}
978
964
1;
979
1;
(-)t/uribl.t (-16 / +7 lines)
Lines 4-28 Link Here
4
use SATest; sa_t_init("uribl");
4
use SATest; sa_t_init("uribl");
5
5
6
use constant TEST_ENABLED => conf_bool('run_net_tests') && conf_bool('run_long_tests');
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; };
7
use constant DO_RUN => TEST_ENABLED && can_use_net_dns_safely();
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;
8
use Test;
23
9
24
BEGIN {
10
BEGIN {
25
  plan tests => (DO_RUN ? 5 : 0),
11
  plan tests => (DO_RUN ? 6 : 0),
26
};
12
};
27
13
28
exit unless (DO_RUN);
14
exit unless (DO_RUN);
Lines 34-39 Link Here
34
 q{ X_URIBL_B } => 'B',
20
 q{ X_URIBL_B } => 'B',
35
 q{ X_URIBL_NS } => 'NS',
21
 q{ X_URIBL_NS } => 'NS',
36
 q{ X_URIBL_FULL_NS } => 'FULL_NS',
22
 q{ X_URIBL_FULL_NS } => 'FULL_NS',
23
 q{ X_URIBL_DOMSONLY } => 'X_URIBL_DOMSONLY',
37
);
24
);
38
25
39
tstlocalrules(q{
26
tstlocalrules(q{
Lines 56-61 Link Here
56
  body       X_URIBL_FULL_NS  eval:check_uridnsbl('X_URIBL_FULL_NS')
43
  body       X_URIBL_FULL_NS  eval:check_uridnsbl('X_URIBL_FULL_NS')
57
  tflags     X_URIBL_FULL_NS  net
44
  tflags     X_URIBL_FULL_NS  net
58
45
46
  urirhssub  X_URIBL_DOMSONLY  dnsbltest.spamassassin.org.    A 2
47
  body       X_URIBL_DOMSONLY  eval:check_uridnsbl('X_URIBL_DOMSONLY')
48
  tflags     X_URIBL_DOMSONLY  net domains_only
49
59
  add_header all RBL _RBL_
50
  add_header all RBL _RBL_
60
51
61
});
52
});
(-)t/dnsbl_sc_meta.t (-15 / +1 lines)
Lines 4-24 Link Here
4
use SATest; sa_t_init("dnsbl_sc_meta");
4
use SATest; sa_t_init("dnsbl_sc_meta");
5
5
6
use constant TEST_ENABLED => conf_bool('run_net_tests');
6
use constant TEST_ENABLED => conf_bool('run_net_tests');
7
use constant HAS_NET_DNS => eval { require Net::DNS; };
7
use constant DO_RUN => TEST_ENABLED && can_use_net_dns_safely();
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;
8
use Test;
23
9
24
BEGIN {
10
BEGIN {
(-)t/data/spam/dnsbl_ipsonly.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://foo.bar.baz.uribl-example-a.com/
11
(-)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
(-)t/data/spam/dnsbl.eml (+1 lines)
Lines 24-27 Link Here
24
me too: http://uribl-example-c.com/
24
me too: http://uribl-example-c.com/
25
25
26
Also -- http://spamassassin.org/
26
Also -- http://spamassassin.org/
27
And -- http://144.137.3.98/blah
27
28

Return to bug 6335