Milter/Module/VirusBounceSpew.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 68 MC/DCmcdc 0.0% 0 / 23 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 151 CC 3 SCAR 14.6
CC
3
Cov
0%
header_callback
12.0
VirusBounceSpew
2.0
new
2.0
CRAP 4.3
1 # $Id: VirusBounceSpew.pm,v 1.9 2004/09/23 15:11:13 tvierling Exp $
2 #
3 # Copyright (c) 2002-2004 Todd Vierling <tv@pobox.com> <tv@duh.org>
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 #
9 # 1. Redistributions of source code must retain the above copyright notice,
10 # this list of conditions and the following disclaimer.
11 #
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 #
16 # 3. Neither the name of the author nor the names of contributors may be used
17 # to endorse or promote products derived from this software without specific
18 # prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 # POSSIBILITY OF SUCH DAMAGE.
31  
32 package Mail::Milter::Module::VirusBounceSpew;
33  
34 use 5.006;
35 use base Exporter;
36 use base Mail::Milter::Object;
37  
38 use strict;
39 use warnings;
40  
41 use Carp;
42 use Sendmail::Milter 0.18; # get needed constants
43  
44 our $VERSION = '0.01';
45  
46 =pod
47  
48 =head1 NAME
49  
50 Mail::Milter::Module::VirusBounceSpew - milter to reject antivirus messages typically sent to forged "senders"
51  
52 =head1 SYNOPSIS
53  
54 use Mail::Milter::Module::VirusBounceSpew;
55  
56 my $milter = new Mail::Milter::Module::VirusBounceSpew;
57  
58 my $milter2 = &VirusBounceSpew; # convenience
59  
60 =head1 DESCRIPTION
61  
62 This module rejects messages at the DATA phase by searching for known
63 signs of misconfigured antivirus software. An increasing problem on the
64 Internet as of this writing is a tendency for viruses and trojans to send
65 mail with a forged envelope from address. This is triggering antivirus
66 warning messages back to these forged senders.
67  
68 =head1 METHODS
69  
70 =over 4
71  
72 =cut
73  
74 our @EXPORT = qw(&VirusBounceSpew);
75  
76 sub VirusBounceSpew {
77 new Mail::Milter::Module::VirusBounceSpew(@_);
78 }
79  
80 =pod
81  
82 =item new()
83  
84 Creates a VirusBounceSpew milter object. The match rules are internally
85 hardcoded and may be examined by reading the module source.
86  
87 =cut
88  
89 sub new ($$;@) {
90 my $this = Mail::Milter::Object::new(shift);
91  
92 $this->{_message} = 'Antivirus warning messages are not accepted here. Please configure your antivirus software not to send warning messages to forged senders!';
93  
94 $this;
95 }
96  
97 =pod
98  
99 =item set_message(MESSAGE)
100  
101 Sets the message used when rejecting messages.
102  
103 This method returns a reference to the object itself, allowing this method
104 call to be chained.
105  
106 =cut
107  
108 sub set_message ($$) {
109 my $this = shift;
110  
111 $this->{_message} = shift;
112  
113 $this;
114 }
115  
116 sub header_callback {
117 my $this = shift;
118 my $ctx = shift;
119 my $hname = shift;
120 my $header = "$hname: ".(shift);
121  
122 if (
123 $header =~ /^From: amavisd(?:-new)? <postmaster\@/i ||
124 $header =~ /^From: MailMarshal\@\s+$/ ||
125 $header =~ /^Subject: ACHTUNG! Sie haben eine mit einem Virus/ ||
126 $header =~ /^Subject: Antigen found VIRUS=/ ||
127 $header =~ /^Subject: AVISO DE VIRUS / ||
128 $header =~ /^Subject: Warning: antivirus system report$/ ||
129 $header =~ /^Subject: Disallowed attachment type found in sent message/ ||
130 $header =~ /^Subject: Email violation detected in an email you sent/ ||
131 $header =~ /^Subject: Failed to clean virus file/ ||
132 $header =~ /^Subject: Filter scan result notification from / ||
133 $header =~ /^Subject: Illegal attachment type found in sent message/ ||
134 $header =~ /^Subject: InterScan NT Alert$/ ||
135 $header =~ /^Subject: Mail delivery failed \(virus detected\)/ ||
136 $header =~ /^Subject: MDaemon (Notification -- Attachment Removed|Warning - Virus Found)/ ||
137 $header =~ /^Subject: Norton AntiVirus detected (and quarantined )?a virus/ ||
138 $header =~ /^Sublect: Panda Antivirus Platinum warning$/i ||
139 $header =~ /^Subject: Returned due to virus; was:/ ||
140 $header =~ /^Subject: Spam mail warning notification/ ||
141 $header =~ /^Subject: Virenwarnung$/ ||
142 $header =~ /^Subject: Virus detected$/ ||
143 $header =~ /^Subject: Virus Detected by Network Associates/ ||
144 $header =~ /^Subject: (?:MailMarshal|Symantec Mail Security) (?:has )?detected / ||
145 $header =~ /^Subject: (?:Warning *[:!-]* *)?(?:E-mail )?Virus(?:es)? (Alert|Detected|Found)/i ||
146 0) {
147 my $msg = $this->{_message};
148  
149 if (defined($msg)) {
150 $ctx->setreply('554', '5.7.1', $msg);
151 }
152  
153 return SMFIS_REJECT;
154 }
155  
156 SMFIS_CONTINUE;
157 }
158  
159 1;
160 __END__