| 119 |
urirhssub URIBL_RHSBL_4 rhsbl.example.org. A 127.0.0.4 |
urirhssub URIBL_RHSBL_4 rhsbl.example.org. A 127.0.0.4 |
| 120 |
urirhssub URIBL_RHSBL_8 rhsbl.example.org. A 8 |
urirhssub URIBL_RHSBL_8 rhsbl.example.org. A 8 |
| 121 |
|
|
| 122 |
|
=item urinsrhsbl NAME_OF_RULE rhsbl_zone lookuptype |
| 123 |
|
|
| 124 |
|
Perform a RHSBL-style domain lookup against the contents of the NS records |
| 125 |
|
for each URI. In other words, a URI using the domain C<foo.com> will cause |
| 126 |
|
an NS lookup to take place; assuming that domain has an NS of C<ns0.bar.com>, |
| 127 |
|
that will cause a lookup of C<bar.com.uriblzone.net>. Note that hostnames |
| 128 |
|
are stripped from both the domain used in the URI, and the domain in the |
| 129 |
|
lookup. |
| 130 |
|
|
| 131 |
|
C<NAME_OF_RULE> is the name of the rule to be used, C<rhsbl_zone> is the zone |
| 132 |
|
to look up domain names in, and C<lookuptype> is the type of lookup (B<TXT> or |
| 133 |
|
B<A>). |
| 134 |
|
|
| 135 |
|
Note that, as with C<urirhsbl>, you must also define a body-eval rule calling |
| 136 |
|
C<check_uridnsbl()> to use this. |
| 137 |
|
|
| 138 |
|
=item urinsrhssub NAME_OF_RULE rhsbl_zone lookuptype subtest |
| 139 |
|
|
| 140 |
|
Specify a RHSBL-style domain-NS lookup, as above, with a sub-test. |
| 141 |
|
C<NAME_OF_RULE> is the name of the rule to be used, C<rhsbl_zone> is the zone |
| 142 |
|
to look up domain names in, and C<lookuptype> is the type of lookup (B<TXT> or |
| 143 |
|
B<A>). C<subtest> is the sub-test to run against the returned data; see |
| 144 |
|
<urirhssub>. |
| 145 |
|
|
| 146 |
|
Note that, as with C<urirhsbl>, you must also define a body-eval rule calling |
| 147 |
|
C<check_uridnsbl()> to use this. |
| 148 |
|
|
| 149 |
=back |
=back |
| 150 |
|
|
| 151 |
=head1 ADMINISTRATOR SETTINGS |
=head1 ADMINISTRATOR SETTINGS |
| 170 |
use Mail::SpamAssassin::Plugin; |
use Mail::SpamAssassin::Plugin; |
| 171 |
use Mail::SpamAssassin::Constants qw(:ip); |
use Mail::SpamAssassin::Constants qw(:ip); |
| 172 |
use Mail::SpamAssassin::Util; |
use Mail::SpamAssassin::Util; |
| 173 |
|
use Mail::SpamAssassin::Util::RegistrarBoundaries; |
| 174 |
use Mail::SpamAssassin::Logger; |
use Mail::SpamAssassin::Logger; |
| 175 |
use strict; |
use strict; |
| 176 |
use warnings; |
use warnings; |
| 230 |
|
|
| 231 |
# only hit DNSBLs for active rules (defined and score != 0) |
# only hit DNSBLs for active rules (defined and score != 0) |
| 232 |
$scanner->{'uridnsbl_active_rules_rhsbl'} = { }; |
$scanner->{'uridnsbl_active_rules_rhsbl'} = { }; |
| 233 |
|
$scanner->{'uridnsbl_active_rules_nsrhsbl'} = { }; |
| 234 |
$scanner->{'uridnsbl_active_rules_revipbl'} = { }; |
$scanner->{'uridnsbl_active_rules_revipbl'} = { }; |
| 235 |
|
|
| 236 |
foreach my $rulename (keys %{$scanner->{conf}->{uridnsbls}}) { |
foreach my $rulename (keys %{$scanner->{conf}->{uridnsbls}}) { |
| 239 |
my $rulecf = $scanner->{conf}->{uridnsbls}->{$rulename}; |
my $rulecf = $scanner->{conf}->{uridnsbls}->{$rulename}; |
| 240 |
if ($rulecf->{is_rhsbl}) { |
if ($rulecf->{is_rhsbl}) { |
| 241 |
$scanner->{uridnsbl_active_rules_rhsbl}->{$rulename} = 1; |
$scanner->{uridnsbl_active_rules_rhsbl}->{$rulename} = 1; |
| 242 |
|
} elsif ($rulecf->{is_nsrhsbl}) { |
| 243 |
|
$scanner->{uridnsbl_active_rules_nsrhsbl}->{$rulename} = 1; |
| 244 |
} else { |
} else { |
| 245 |
$scanner->{uridnsbl_active_rules_revipbl}->{$rulename} = 1; |
$scanner->{uridnsbl_active_rules_revipbl}->{$rulename} = 1; |
| 246 |
} |
} |
| 451 |
}); |
}); |
| 452 |
|
|
| 453 |
push (@cmds, { |
push (@cmds, { |
| 454 |
|
setting => 'urinsrhsbl', |
| 455 |
|
is_priv => 1, |
| 456 |
|
code => sub { |
| 457 |
|
my ($self, $key, $value, $line) = @_; |
| 458 |
|
if ($value =~ /^(\S+)\s+(\S+)\s+(\S+)$/) { |
| 459 |
|
my $rulename = $1; |
| 460 |
|
my $zone = $2; |
| 461 |
|
my $type = $3; |
| 462 |
|
$self->{uridnsbls}->{$rulename} = { |
| 463 |
|
zone => $zone, type => $type, |
| 464 |
|
is_nsrhsbl => 1 |
| 465 |
|
}; |
| 466 |
|
} |
| 467 |
|
elsif ($value =~ /^$/) { |
| 468 |
|
return $Mail::SpamAssassin::Conf::MISSING_REQUIRED_VALUE; |
| 469 |
|
} |
| 470 |
|
else { |
| 471 |
|
return $Mail::SpamAssassin::Conf::INVALID_VALUE; |
| 472 |
|
} |
| 473 |
|
} |
| 474 |
|
}); |
| 475 |
|
|
| 476 |
|
push (@cmds, { |
| 477 |
|
setting => 'urinsrhssub', |
| 478 |
|
is_priv => 1, |
| 479 |
|
code => sub { |
| 480 |
|
my ($self, $key, $value, $line) = @_; |
| 481 |
|
if ($value =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\d{1,10}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) { |
| 482 |
|
my $rulename = $1; |
| 483 |
|
my $zone = $2; |
| 484 |
|
my $type = $3; |
| 485 |
|
my $subrule = $4; |
| 486 |
|
$self->{uridnsbls}->{$rulename} = { |
| 487 |
|
zone => $zone, type => $type, |
| 488 |
|
is_nsrhsbl => 1, is_subrule => 1 |
| 489 |
|
}; |
| 490 |
|
$self->{uridnsbl_subs}->{$zone} ||= { }; |
| 491 |
|
push (@{$self->{uridnsbl_subs}->{$zone}->{$subrule}->{rulenames}}, $rulename); |
| 492 |
|
} |
| 493 |
|
elsif ($value =~ /^$/) { |
| 494 |
|
return $Mail::SpamAssassin::Conf::MISSING_REQUIRED_VALUE; |
| 495 |
|
} |
| 496 |
|
else { |
| 497 |
|
return $Mail::SpamAssassin::Conf::INVALID_VALUE; |
| 498 |
|
} |
| 499 |
|
} |
| 500 |
|
}); |
| 501 |
|
|
| 502 |
|
push (@cmds, { |
| 503 |
setting => 'uridnsbl_skip_domain', |
setting => 'uridnsbl_skip_domain', |
| 504 |
default => {}, |
default => {}, |
| 505 |
code => sub { |
code => sub { |
| 561 |
} |
} |
| 562 |
|
|
| 563 |
my $rhsblrules = $scanner->{uridnsbl_active_rules_rhsbl}; |
my $rhsblrules = $scanner->{uridnsbl_active_rules_rhsbl}; |
| 564 |
|
my $nsrhsblrules = $scanner->{uridnsbl_active_rules_nsrhsbl}; |
| 565 |
my $reviprules = $scanner->{uridnsbl_active_rules_revipbl}; |
my $reviprules = $scanner->{uridnsbl_active_rules_revipbl}; |
| 566 |
|
|
| 567 |
if ($single_dnsbl) { |
if ($single_dnsbl) { |
| 613 |
|
|
| 614 |
my $IPV4_ADDRESS = IPV4_ADDRESS; |
my $IPV4_ADDRESS = IPV4_ADDRESS; |
| 615 |
my $IP_PRIVATE = IP_PRIVATE; |
my $IP_PRIVATE = IP_PRIVATE; |
| 616 |
|
my $nsrhsblrules = $scanner->{uridnsbl_active_rules_nsrhsbl}; |
| 617 |
|
|
| 618 |
foreach my $rr (@answer) { |
foreach my $rr (@answer) { |
| 619 |
my $str = $rr->string; |
my $str = $rr->string; |
| 622 |
|
|
| 623 |
if ($str =~ /IN\s+NS\s+(\S+)/) { |
if ($str =~ /IN\s+NS\s+(\S+)/) { |
| 624 |
my $nsmatch = $1; |
my $nsmatch = $1; |
| 625 |
|
my $nsrhblstr = $nsmatch; |
| 626 |
|
|
| 627 |
if ($nsmatch =~ /^\d+\.\d+\.\d+\.\d+\.?$/) { |
if ($nsmatch =~ /^\d+\.\d+\.\d+\.\d+\.?$/) { |
| 628 |
$nsmatch =~ s/\.$//; |
$nsmatch =~ s/\.$//; |
| 630 |
if ($nsmatch =~ /^$IPV4_ADDRESS$/ && $nsmatch !~ /^$IP_PRIVATE$/) { |
if ($nsmatch =~ /^$IPV4_ADDRESS$/ && $nsmatch !~ /^$IP_PRIVATE$/) { |
| 631 |
$self->lookup_dnsbl_for_ip($scanner, $ent->{obj}, $nsmatch); |
$self->lookup_dnsbl_for_ip($scanner, $ent->{obj}, $nsmatch); |
| 632 |
} |
} |
| 633 |
|
$nsrhblstr = $nsmatch; |
| 634 |
} |
} |
| 635 |
else { |
else { |
| 636 |
$self->lookup_a_record($scanner, $ent->{obj}, $nsmatch); |
$self->lookup_a_record($scanner, $ent->{obj}, $nsmatch); |
| 637 |
|
$nsrhblstr = Mail::SpamAssassin::Util::RegistrarBoundaries::trim_domain($nsmatch); |
| 638 |
|
} |
| 639 |
|
|
| 640 |
|
foreach my $rulename (keys %{$nsrhsblrules}) { |
| 641 |
|
my $rulecf = $scanner->{conf}->{uridnsbls}->{$rulename}; |
| 642 |
|
$self->lookup_single_dnsbl($scanner, $ent->{obj}, $rulename, |
| 643 |
|
$nsrhblstr, $rulecf->{zone}, $rulecf->{type}); |
| 644 |
|
|
| 645 |
|
$scanner->register_async_rule_start($rulename); |
| 646 |
} |
} |
| 647 |
} |
} |
| 648 |
} |
} |
| 774 |
$scanner->{uridnsbl_hits}->{$rulename}->{$dom} = 1; |
$scanner->{uridnsbl_hits}->{$rulename}->{$dom} = 1; |
| 775 |
|
|
| 776 |
if ($scanner->{uridnsbl_active_rules_revipbl}->{$rulename} |
if ($scanner->{uridnsbl_active_rules_revipbl}->{$rulename} |
| 777 |
|
|| $scanner->{uridnsbl_active_rules_nsrhsbl}->{$rulename} |
| 778 |
|| $scanner->{uridnsbl_active_rules_rhsbl}->{$rulename}) |
|| $scanner->{uridnsbl_active_rules_rhsbl}->{$rulename}) |
| 779 |
{ |
{ |
| 780 |
# TODO: this needs to handle multiple domain hits per rule |
# TODO: this needs to handle multiple domain hits per rule |