Subject: | new spam detection case |
New spam detection case.
patch attached and on gitorious in repo http://gitorious.org/mail-
deliverystatus-bounceparser-fork/mail-deliverystatus-bounceparser-fork
Subject: | 0001-New-spam-detection-case.patch |
From 1d220ded89c0ba12acd312d09255e4fd72dda1a7 Mon Sep 17 00:00:00 2001
From: Michael Stevens <mstevens@etla.org>
Date: Mon, 7 Feb 2011 14:49:31 +0000
Subject: [PATCH] New spam detection case.
---
MANIFEST | 2 +
lib/Mail/DeliveryStatus/BounceParser.pm | 4 +-
t/corpus/spam-rejection-uribl.msg | 86 +++++++++++++++++++++++++++++++
t/spam-rejection-uribl.t | 31 +++++++++++
4 files changed, 121 insertions(+), 2 deletions(-)
create mode 100644 t/corpus/spam-rejection-uribl.msg
create mode 100644 t/spam-rejection-uribl.t
diff --git a/MANIFEST b/MANIFEST
index 6b094a2..3f805a4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -78,6 +78,7 @@ t/corpus/spam-rejection6.msg
t/corpus/spam-rejection7.msg
t/corpus/spam-rejection8.msg
t/corpus/spam-rejection9.msg
+t/corpus/spam-rejection-uribl.msg
t/corpus/spam-with-badly-parsed-email.msg
t/corpus/spam-with-image.msg
t/corpus/spamassassin.msg
@@ -139,6 +140,7 @@ t/spam-rejection6.t
t/spam-rejection7.t
t/spam-rejection8.t
t/spam-rejection9.t
+t/spam-rejection-uribl.t
t/spam-with-image.t
t/spamassassin.t
t/spambouncer.t
diff --git a/lib/Mail/DeliveryStatus/BounceParser.pm b/lib/Mail/DeliveryStatus/BounceParser.pm
index e51ffa5..50054b4 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -1025,8 +1025,8 @@ sub _std_reason {
/Spam\s+detected/i or
/Message\s+looks\s+like\s+spam/i or
/Message\s+content\s+rejected,\s+UBE/i or
- /Blocked\s+using\s+spam\s+pattern/i
-
+ /Blocked\s+using\s+spam\s+pattern/i or
+ /breaches\s+local\s+URIBL\s+policy/i
) {
return "spam";
}
diff --git a/t/corpus/spam-rejection-uribl.msg b/t/corpus/spam-rejection-uribl.msg
new file mode 100644
index 0000000..39cea5d
--- /dev/null
+++ b/t/corpus/spam-rejection-uribl.msg
@@ -0,0 +1,86 @@
+Delivered-To: automated-bounces+dbd27190-3092-11e0-a323-f8a354c7e16d@email.example.com
+Received: by 10.100.190.1 with SMTP id n1cs31640anf;
+ Fri, 4 Feb 2011 11:38:46 -0800 (PST)
+Received: by 10.227.156.5 with SMTP id u5mr7408286wbw.28.1296848324426;
+ Fri, 04 Feb 2011 11:38:44 -0800 (PST)
+Return-Path: <>
+Received: from admin1.example.co.uk (admin1.example.co.uk [94.236.45.212])
+ by mx.google.com with ESMTP id d17si1961351wbd.43.2011.02.04.11.38.44;
+ Fri, 04 Feb 2011 11:38:44 -0800 (PST)
+Received-SPF: pass (google.com: best guess record for domain of admin1.example.co.uk designates 94.236.45.212 as permitted sender) client-ip=94.236.45.212;
+Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of admin1.example.co.uk designates 94.236.45.212 as permitted sender) smtp.mail=
+Received: by admin1.example.co.uk (Postfix)
+ id E04031548255; Fri, 4 Feb 2011 19:38:43 +0000 (GMT)
+Date: Fri, 4 Feb 2011 19:38:43 +0000 (GMT)
+From: MAILER-DAEMON@admin1.example.co.uk (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+To: automated-bounces+DBD27190-3092-11E0-A323-F8A354C7E16D@email.example.com
+Auto-Submitted: auto-replied
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status;
+ boundary="574881548263.1296848323/admin1.example.co.uk"
+Message-Id: <20110204193843.E04031548255@admin1.example.co.uk>
+
+This is a MIME-encapsulated message.
+
+--574881548263.1296848323/admin1.example.co.uk
+Content-Description: Notification
+Content-Type: text/plain; charset=us-ascii
+
+This is the mail system at host admin1.example.co.uk.
+
+I'm sorry to have to inform you that your message could not
+be delivered to one or more recipients. It's attached below.
+
+For further assistance, please send mail to <postmaster>
+
+If you do so, please include this problem report. You can
+delete your own text from the attached returned message.
+
+ The mail system
+
+<fred.bloggs@example2.co.uk>: host
+ mailgate.example3.co.uk[62.49.248.250] said: 550 5.7.1 Your email
+ breaches local URIBL policy. (in reply to end of DATA command)
+
+--574881548263.1296848323/admin1.example.co.uk
+Content-Description: Delivery report
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; admin1.example.co.uk
+X-Postfix-Queue-ID: 574881548263
+X-Postfix-Sender: rfc822; automated-bounces+DBD27190-3092-11E0-A323-F8A354C7E16D@email.example.com
+Arrival-Date: Fri, 4 Feb 2011 19:13:33 +0000 (GMT)
+
+Final-Recipient: rfc822; fred.bloggs@example2.co.uk
+Action: failed
+Status: 5.7.1
+Remote-MTA: dns; mailgate.example3.co.uk
+Diagnostic-Code: smtp; 550 5.7.1 Your email breaches local URIBL policy.
+
+--574881548263.1296848323/admin1.example.co.uk
+Content-Description: Undelivered Message Headers
+Content-Type: text/rfc822-headers
+
+Received: by admin1.example.co.uk (Postfix, from userid 507)
+ id 574881548263; Fri, 4 Feb 2011 19:13:33 +0000 (GMT)
+DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=email.example.com;
+ s=default10; t=1296846813;
+ bh=B+QkZsMeyuaBQ6+nOjRUtP8GhqMMtgpAzrZpmNu5Ihk=;
+ h=MIME-Version:Content-Transfer-Encoding:Content-Type:Date:From:
+ Subject:List-Unsubscribe:To:Message-Id;
+ b=xtSQk5Gu+BCQUcnNtlW3KReQlaMV9/vb/IoKEFwoF4Qkf5fDKPuwYikxgXyFfEgPO
+ fCX+3KwR4lWMjcbonNkKtpV8a64pNVbE3uXBzgGt3UGhkAfUQ82rrfOt8c9V1uLuas
+ qupQ2NJ+d4mZJDg2H27GIJT9VFc1cngsUBVfttL0=
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/related; boundary="_----------=_12968468137131270"
+X-Mailer: MIME::Lite 3.027 (F2.78; T1.31; A2.07; B3.13; Q3.13)
+Date: Fri, 4 Feb 2011 19:13:33 +0000
+From: Julia Stevens <julia.stevens@email.example.com>
+Subject: foo
+List-Unsubscribe: <http://www.exampleoffers.co.uk/unsubscribe.epl?uuid=DBD27190-3092-11E0-A323-F8A354C7E16D>
+To: Fred Bloggs <fred.bloggs@example2.co.uk>
+Message-Id: <20110204191333.574881548263@admin1.example.co.uk>
+
+--574881548263.1296848323/admin1.example.co.uk--
diff --git a/t/spam-rejection-uribl.t b/t/spam-rejection-uribl.t
new file mode 100644
index 0000000..dcc03d6
--- /dev/null
+++ b/t/spam-rejection-uribl.t
@@ -0,0 +1,31 @@
+#!perl -wT
+use strict;
+
+use Test::More tests => 3;
+
+use Mail::DeliveryStatus::BounceParser;
+
+# Test we can spot being blocked by spamassassin.
+
+# FH because we're being backcompat to pre-lexical
+sub readfile {
+ my $fn = shift;
+ open FH, "$fn" or die $!;
+ local $/;
+ my $text = <FH>;
+ close FH;
+ return $text;
+}
+
+my $message = readfile('t/corpus/spam-rejection-uribl.msg');
+
+my $bounce = Mail::DeliveryStatus::BounceParser->new($message);
+
+isa_ok($bounce, 'Mail::DeliveryStatus::BounceParser');
+ok($bounce->is_bounce, "This is a bounce");
+
+my ($report) = $bounce->reports;
+
+my $std_reason = $report->get("std_reason");
+
+is($std_reason, "spam", "std reason is spam");
--
1.7.1