Mailing List Archive

svn commit: rev 6771 - in incubator/spamassassin/trunk: . lib/Mail/SpamAssassin rules
Author: jm
Date: Thu Feb 19 00:02:32 2004
New Revision: 6771

Added:
incubator/spamassassin/trunk/rules/10_plugins.cf
Modified:
incubator/spamassassin/trunk/MANIFEST
incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Received.pm
Log:
added plugin to look up IP address of relays with IP::Country (bug 2575)

Modified: incubator/spamassassin/trunk/MANIFEST
==============================================================================
--- incubator/spamassassin/trunk/MANIFEST (original)
+++ incubator/spamassassin/trunk/MANIFEST Thu Feb 19 00:02:32 2004
@@ -304,3 +304,4 @@
t/uri.t
masses/rule-dev/maildir-scan-headers
lib/Mail/SpamAssassin/MsgMetadata.pm
+rules/10_plugins.cf

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm (original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm Thu Feb 19 00:02:32 2004
@@ -671,7 +671,6 @@
}

$msg->extract_message_metadata ($self->{main});
-
my $body = $self->get_body_from_msg ($msg);
my $ret;

@@ -942,10 +941,12 @@
warn "msg not a ref: '$msg'";
return [ ];
}
+ $msg->extract_message_metadata ($self->{main});
my $permsgstatus =
Mail::SpamAssassin::PerMsgStatus->new($self->{main}, $msg);

- my $body = $permsgstatus->get_decoded_stripped_body_text_array();
+ my $body = $msg->{metadata}->get_rendered_body_text_array();
+ # TODO! also add URI extraction to {metadata}
push (@{$body}, $self->add_uris_for_permsgstatus($permsgstatus));
$permsgstatus->finish();


Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Received.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Received.pm (original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Received.pm Thu Feb 19 00:02:32 2004
@@ -81,6 +81,11 @@
sub parse_received_headers {
my ($self, $msg) = @_;

+ # argh. this is only used to perform DNS lookups.
+ # TODO! we need to get Dns.pm code into a class that is NOT
+ # part of Mail::SpamAssassin::PerMsgStatus to avoid this crap!
+ $self->{dns_pms} = Mail::SpamAssassin::PerMsgStatus->new($self->{main}, $msg);
+
$self->{relays} = [ ];

my $hdrs = $msg->get_header('Received');
@@ -191,7 +196,7 @@
# do we know what the IP addresses of the "by" host in the first
# header is? If not, set them from this header, since it's the
# first one. NOTE: this is a ref to an array, NOT a string.
- if (!defined $first_by && $self->is_dns_available()) {
+ if (!defined $first_by && $self->{dns_pms}->is_dns_available()) {
$first_by = [ $self->lookup_all_ips ($relay->{by}) ];
}

@@ -205,7 +210,7 @@
# can we use DNS? If not, we cannot use this algorithm, as we
# cannot lookup hostnames. :(
# Consider the first relay trusted, and all others untrusted.
- if (!$self->is_dns_available()) {
+ if (!$self->{dns_pms}->is_dns_available()) {
dbg ("received-header: cannot use DNS, do not trust any hosts from here on");
}

@@ -293,6 +298,7 @@
}
}
delete $self->{relays}; # tmp, no longer needed
+ delete $self->{dns_pms};

chop ($self->{relays_trusted_str}); # remove trailing ws
chop ($self->{relays_untrusted_str}); # remove trailing ws
@@ -328,7 +334,7 @@
my ($self, $hostname) = @_;

# cannot use gethostbyname without DNS :(
- if (!$self->is_dns_available()) {
+ if (!$self->{dns_pms}->is_dns_available()) {
return ();
}

@@ -1084,7 +1090,7 @@
# here may be movable too; no need to lookup trusted IPs all the time.
#
if ($rdns eq '') {
- if (!$self->is_dns_available()) {
+ if (!$self->{dns_pms}->is_dns_available()) {
if ($mta_looked_up_dns) {
# we know the MTA always does lookups, so this means the host
# really has no rDNS (rather than that the MTA didn't bother
@@ -1096,7 +1102,7 @@
}

} else {
- $rdns = $self->lookup_ptr ($ip);
+ $rdns = $self->{dns_pms}->lookup_ptr ($ip);

if (!$rdns) {
$relay->{no_reverse_dns} = 1;

Added: incubator/spamassassin/trunk/rules/10_plugins.cf
==============================================================================
--- (empty file)
+++ incubator/spamassassin/trunk/rules/10_plugins.cf Thu Feb 19 00:02:32 2004
@@ -0,0 +1,29 @@
+# SpamAssassin plugins
+#
+# Please don't modify this file as your changes will be overwritten with
+# the next update. Use @@LOCAL_RULES_DIR@@/local.cf instead.
+# See 'perldoc Mail::SpamAssassin::Conf' for details.
+#
+# <@LICENSE>
+# Copyright 2004 Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# </@LICENSE>
+#
+###########################################################################
+
+# RelayCountry - add metadata for Bayes learning, marking the countries
+# a message was relayed through
+#
+# loadplugin Mail::SpamAssassin::Plugin::RelayCountry
+