You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/11/02 19:35:58 UTC

svn commit: r591423 - in /spamassassin/trunk: lib/Mail/SpamAssassin/Message/Metadata/Received.pm t/trust_path.t

Author: jm
Date: Fri Nov  2 11:35:57 2007
New Revision: 591423

URL: http://svn.apache.org/viewvc?rev=591423&view=rev
Log:
bug 5680: ALL_TRUSTED fires even if X-Originating-IP appears in headers; add IP addresses from the 'X-Yahoo-Post-IP', 'X-Originating-IP', 'X-Apparently-From', 'X-SenderIP' headers to the relays list in order to fix this

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
    spamassassin/trunk/t/trust_path.t

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm?rev=591423&r1=591422&r2=591423&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Metadata/Received.pm Fri Nov  2 11:35:57 2007
@@ -107,10 +107,24 @@
     }
   }
 
+  my $IP_ADDRESS = IP_ADDRESS;
   my $IP_PRIVATE = IP_PRIVATE;
   my $LOCALHOST = LOCALHOST;
 
-  foreach my $line ( $msg->get_header('Received') ) {
+  my @hdrs = $msg->get_header('Received');
+
+  # Now add the single line headers like X-Originating-IP. (bug 5680)
+  # we convert them into synthetic "Received" headers so we can share
+  # code below.
+  for my $header ('X-Yahoo-Post-IP', 'X-Originating-IP',
+                    'X-Apparently-From', 'X-SenderIP')
+  {
+    my $str = $msg->get_header($header);
+    next unless ($str && $str =~ m/($IP_ADDRESS)/);
+    push @hdrs, "from X-Originating-IP: $1\n";
+  }
+
+  foreach my $line ( @hdrs ) {
 
     # qmail-scanner support hack: we may have had one of these set from the
     # previous (read: more recent) Received header.   if so, add it on to this
@@ -1022,6 +1036,12 @@
 	$rdns = $1;
       }
       goto enough;
+    }
+
+    # a synthetic header, generated internally:
+    # Received: X-Originating-IP: 1.2.3.4
+    if (/^X-Originating-IP: (\S+)$/) {
+      $ip = $1; $by = ''; goto enough;
     }
 
     ## STUFF TO IGNORE ##

Modified: spamassassin/trunk/t/trust_path.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/trust_path.t?rev=591423&r1=591422&r2=591423&view=diff
==============================================================================
--- spamassassin/trunk/t/trust_path.t (original)
+++ spamassassin/trunk/t/trust_path.t Fri Nov  2 11:35:57 2007
@@ -18,7 +18,7 @@
 
 use lib '.'; use lib 't';
 use SATest; sa_t_init("trust_path");
-use Test; BEGIN { plan tests => 69 };
+use Test; BEGIN { plan tests => 81 };
 use IO::File;
 
 use strict;
@@ -425,6 +425,77 @@
 
 # ---------------------------------------------------------------------------
 
+# bug 5680: 'X-Originating-IP'
+q{
+
+  trusted_networks 1/8
+  Received: from sender.net (1.1.1.1) by receiver.net
+              with SMTP; 10 Nov 2005 00:00:00 -0000
+  X-Originating-IP: 2.2.2.2
+
+} => q{
+
+Trusted: [ ip=1.1.1.1 rdns=sender.net helo=sender.net by=receiver.net ident= envfrom= intl=1 id= auth= msa=0 ]
+Untrusted: [ ip=2.2.2.2 rdns= helo= by= ident= envfrom= intl=0 id= auth= msa=0 ]
+
+},
+
+# ---------------------------------------------------------------------------
+
+# bug 5680: 'X-Originating-IP', trusted
+q{
+
+  trusted_networks 1/8 2/8
+  internal_networks 1/8
+  Received: from sender.net (1.1.1.1) by receiver.net
+              with SMTP; 10 Nov 2005 00:00:00 -0000
+  X-Originating-IP: 2.2.2.2
+
+} => q{
+
+Trusted: [ ip=1.1.1.1 rdns=sender.net helo=sender.net by=receiver.net ident= envfrom= intl=1 id= auth= msa=0 ] [ ip=2.2.2.2 rdns= helo= by= ident= envfrom= intl=0 id= auth= msa=0 ]
+Untrusted: 
+
+},
+
+# ---------------------------------------------------------------------------
+
+# bug 5680: 'X-Originating-IP', msa
+q{
+
+  trusted_networks 1/8
+  msa_networks 1/8
+  Received: from sender.net (1.1.1.1) by receiver.net
+              with SMTP; 10 Nov 2005 00:00:00 -0000
+  X-Originating-IP: 2.2.2.2
+
+} => q{
+
+Trusted: [ ip=1.1.1.1 rdns=sender.net helo=sender.net by=receiver.net ident= envfrom= intl=1 id= auth= msa=1 ] [ ip=2.2.2.2 rdns= helo= by= ident= envfrom= intl=1 id= auth= msa=0 ]
+Untrusted: 
+
+},
+
+# ---------------------------------------------------------------------------
+
+# bug 5680: 'X-Originating-IP', internal
+q{
+
+  trusted_networks 1/8 2/8
+  internal_networks 1/8 2/8
+  Received: from sender.net (1.1.1.1) by receiver.net
+              with SMTP; 10 Nov 2005 00:00:00 -0000
+  X-Originating-IP: 2.2.2.2
+
+} => q{
+
+Trusted: [ ip=1.1.1.1 rdns=sender.net helo=sender.net by=receiver.net ident= envfrom= intl=1 id= auth= msa=0 ] [ ip=2.2.2.2 rdns= helo= by= ident= envfrom= intl=1 id= auth= msa=0 ]
+Untrusted: 
+
+},
+
+# ---------------------------------------------------------------------------
+
 # test to make sure netset is detecting overlap correctly when using short CIDR notations
 q{
 
@@ -497,7 +568,7 @@
   }
 
   my $msg = $hdrs."\n\n[no body]\n";
-  $msg =~ s/^\s+Received: /Received: /gm;
+  $msg =~ s/^\s+(Received|X-\S+): /$1: /gm;
   my $status = $sa->check_message_text ($msg);
   my $result = $status->rewrite_mail();