You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2012/12/07 15:04:24 UTC
svn commit: r1418317 - in /spamassassin/trunk: lib/Mail/SpamAssassin/Dns.pm
lib/Mail/SpamAssassin/DnsResolver.pm lib/Mail/SpamAssassin/Plugin/AskDNS.pm
sa-update.raw
Author: mmartinec
Date: Fri Dec 7 14:04:22 2012
New Revision: 1418317
URL: http://svn.apache.org/viewvc?rev=1418317&view=rev
Log:
Net::DNS 0.69 $rr->rdatastr no longer quotes returned TXT ([rt.cpan.org #81760]); some other DNS-related cosmetics; more RR types in AskDNS.pm
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm
spamassassin/trunk/sa-update.raw
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm?rev=1418317&r1=1418316&r2=1418317&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm Fri Dec 7 14:04:22 2012
@@ -187,8 +187,8 @@ sub dnsbl_hit {
} elsif ($answer->type eq 'TXT') {
local $1;
$log = $answer->rdatastr;
- $log =~ s/^"(.*)"$/$1/;
- $log =~ s/(?<![<([])(https?:\/\/\S+)/<$1>/gi;
+ $log =~ s/^"(.*)"\z/$1/s;
+ $log =~ s{ (?<! [<(\[] ) (https? : // \S+)}{<$1>}xgi;
} else { # assuming $answer->type eq 'A'
local($1,$2,$3,$4,$5);
if ($question->string =~ m/^((?:[0-9a-fA-F]\.){32})(\S+\w)/) {
@@ -269,10 +269,11 @@ sub process_dnsbl_result {
next if !defined $answer;
# track all responses
$self->dnsbl_uri($question, $answer);
+ my $answ_type = $answer->type;
# TODO: there are some CNAME returns that might be useful
- next if ($answer->type ne 'A' && $answer->type ne 'TXT');
+ next if ($answ_type ne 'A' && $answ_type ne 'TXT');
# skip any A record that isn't on 127/8
- next if ($answer->type eq 'A' && $answer->rdatastr !~ /^127\./);
+ next if ($answ_type eq 'A' && $answer->rdatastr !~ /^127\./);
for my $rule (@{$rules}) {
$self->dnsbl_hit($rule, $question, $answer);
}
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm?rev=1418317&r1=1418316&r2=1418317&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm Fri Dec 7 14:04:22 2012
@@ -723,15 +723,17 @@ sub poll_responses {
last if $nfound == 0;
my $packet = $self->{res}->bgread($self->{sock});
- my $err = $self->{res}->errorstring;
- if (defined $packet &&
- defined $packet->header &&
- defined $packet->question &&
- defined $packet->answer)
- {
+ if (!$packet) {
+ dbg("dns: no packet! err: %s", $self->{res}->errorstring);
+ } elsif (!$packet->header) {
+ dbg("dns: dns response is missing a header section");
+ } elsif (!$packet->answer) {
+ dbg("dns: dns response is missing an answer section");
+ } elsif (!$packet->question) {
+ dbg("dns: dns response is missing a question section");
+ } else {
my $id = $self->_packet_id($packet);
-
my $cb = delete $self->{id_to_callback}->{$id};
if (!$cb) {
info("dns: no callback for id: %s, ignored; packet: %s",
@@ -741,10 +743,6 @@ sub poll_responses {
$cnt++;
}
}
- else {
- dbg("dns: no packet! err=%s packet=%s",
- $err, $packet ? $packet->string : "undef" );
- }
}
return $cnt;
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm?rev=1418317&r1=1418316&r2=1418317&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm Fri Dec 7 14:04:22 2012
@@ -108,12 +108,15 @@ record type. An empty DNS answer section
The rr_type parameter not only provides a filter for RR types found in
the DNS answer, but also determines the DNS query type. If only a single
RR type is specified in the parameter (e.g. TXT), than this is also the RR
-type of a query. When more than one RR type is specified (e.g. A,AAAA,TXT)
+type of a query. When more than one RR type is specified (e.g. A, AAAA, TXT)
or if ANY is specified, then the DNS query type will be ANY and the rr_type
parameter will only act as a filter on a result.
-Currently allowed RR types in the rr_type parameter are: ANY, A, AAAA, MX,
-TXT, PTR, NS, SOA, CNAME, HINFO, MINFO, WKS, SRV, SPF.
+Currently recognized RR types in the rr_type parameter are: ANY, A, AAAA,
+MX, TXT, PTR, NAPTR, NS, SOA, CERT, CNAME, DNAME, DHCID, HINFO, MINFO,
+RP, HIP, IPSECKEY, KX, LOC, SRV, SSHFP, SPF.
+
+http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
The last optional parameter of a rule is a filtering expression, a.k.a. a
subrule. Its function is much like the subrule in URIDNSBL plugin rules,
@@ -192,7 +195,7 @@ use Mail::SpamAssassin::Logger;
use vars qw(@ISA %rcode_value);
@ISA = qw(Mail::SpamAssassin::Plugin);
-%rcode_value = ( # http://www.iana.org/assignments/dns-parameters
+%rcode_value = ( # http://www.iana.org/assignments/dns-parameters, RFC 6195
NOERROR => 0, FORMERR => 1, SERVFAIL => 2, NXDOMAIN => 3, NOTIMP => 4,
REFUSED => 5, YXDOMAIN => 6, YXRRSET => 7, NXRRSET => 8, NOTAUTH => 9,
NOTZONE => 10, BADVERS => 16, BADSIG => 16, BADKEY => 17, BADTIME => 18,
@@ -244,18 +247,19 @@ sub parse_and_canonicalize_subtest {
my $result;
local($1,$2,$3);
- # modifiers /a, /d, /l, /u in suffix form were added with perl 5.13.10
- if ( $subtest =~ m{^ / (.+) / ([msixoadlu]*) \z}xs) {
+ # modifiers /a, /d, /l, /u in suffix form were added with perl 5.13.10 (5.14)
+ # currently known modifiers are [msixoadlu], but let's not be too picky here
+ if ( $subtest =~ m{^ / (.+) / ([a-z]*) \z}xs) {
$result = $2 ne '' ? qr{(?$2)$1} : qr{$1};
- } elsif ($subtest =~ m{^ m \s* \( (.+) \) ([msixoadlu]*) \z}xs) {
+ } elsif ($subtest =~ m{^ m \s* \( (.+) \) ([a-z]*) \z}xs) {
$result = $2 ne '' ? qr{(?$2)$1} : qr{$1};
- } elsif ($subtest =~ m{^ m \s* \[ (.+) \] ([msixoadlu]*) \z}xs) {
+ } elsif ($subtest =~ m{^ m \s* \[ (.+) \] ([a-z]*) \z}xs) {
$result = $2 ne '' ? qr{(?$2)$1} : qr{$1};
- } elsif ($subtest =~ m{^ m \s* \{ (.+) \} ([msixoadlu]*) \z}xs) {
+ } elsif ($subtest =~ m{^ m \s* \{ (.+) \} ([a-z]*) \z}xs) {
$result = $2 ne '' ? qr{(?$2)$1} : qr{$1};
- } elsif ($subtest =~ m{^ m \s* < (.+) > ([msixoadlu]*) \z}xs) {
+ } elsif ($subtest =~ m{^ m \s* < (.+) > ([a-z]*) \z}xs) {
$result = $2 ne '' ? qr{(?$2)$1} : qr{$1};
- } elsif ($subtest =~ m{^ m \s* (\S) (.+) \1 ([msixoadlu]*) \z}xs) {
+ } elsif ($subtest =~ m{^ m \s* (\S) (.+) \1 ([a-z]*) \z}xs) {
$result = $2 ne '' ? qr{(?$2)$1} : qr{$1};
} elsif ($subtest =~ m{^ (["']) (.*) \1 \z}xs) { # quoted string
$result = $2;
@@ -312,8 +316,10 @@ sub set_config {
$query_type = 'A' if !defined $query_type;
$query_type = uc $query_type;
my @answer_types = split(/,/, $query_type);
- if (grep(!/^(?:ANY|A|AAAA|MX|TXT|PTR|NS|SOA|CNAME|
- HINFO|MINFO|WKS|SRV|SPF)\z/x, @answer_types)) {
+ # http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
+ if (grep(!/^(?:ANY|A|AAAA|MX|TXT|PTR|NAPTR|NS|SOA|CERT|CNAME|DNAME|
+ DHCID|HINFO|MINFO|RP|HIP|IPSECKEY|KX|LOC|SRV|
+ SSHFP|SPF)\z/x, @answer_types)) {
return $Mail::SpamAssassin::Conf::INVALID_VALUE;
}
$query_type = 'ANY' if @answer_types > 1 || $answer_types[0] eq 'ANY';
Modified: spamassassin/trunk/sa-update.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/sa-update.raw?rev=1418317&r1=1418316&r2=1418317&view=diff
==============================================================================
--- spamassassin/trunk/sa-update.raw (original)
+++ spamassassin/trunk/sa-update.raw Fri Dec 7 14:04:22 2012
@@ -1248,8 +1248,11 @@ sub do_dns_query {
next if !$rr; # no answer records, only rcode
next if $rr->type ne $rr_type;
my $text = $rr->rdatastr;
- local($1);
- push(@result,$1) if $text =~ /^"(.*)"$/;
+ if (defined $text && $text ne '') {
+ local($1);
+ $text =~ s/^"(.*)"\z/$1/s;
+ push(@result,$text);
+ }
}
printf("DNS %s query: %s -> %s\n", $rr_type, $query, join(", ",@result))
if $opt{'verbose'} && $opt{'verbose'} > 1;