line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sisimai::Lhost::InterScanMSS; |
2
|
22
|
|
|
22
|
|
5287
|
use parent 'Sisimai::Lhost'; |
|
22
|
|
|
|
|
98
|
|
|
22
|
|
|
|
|
103
|
|
3
|
22
|
|
|
22
|
|
1140
|
use feature ':5.10'; |
|
22
|
|
|
|
|
106
|
|
|
22
|
|
|
|
|
1330
|
|
4
|
22
|
|
|
22
|
|
110
|
use strict; |
|
22
|
|
|
|
|
36
|
|
|
22
|
|
|
|
|
456
|
|
5
|
22
|
|
|
22
|
|
161
|
use warnings; |
|
22
|
|
|
|
|
54
|
|
|
22
|
|
|
|
|
15114
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
1
|
1004
|
sub description { 'Trend Micro InterScan Messaging Security Suite' } |
8
|
|
|
|
|
|
|
sub make { |
9
|
|
|
|
|
|
|
# Detect an error from InterScanMSS |
10
|
|
|
|
|
|
|
# @param [Hash] mhead Message headers of a bounce email |
11
|
|
|
|
|
|
|
# @param [String] mbody Message body of a bounce email |
12
|
|
|
|
|
|
|
# @return [Hash] Bounce data list and message/rfc822 part |
13
|
|
|
|
|
|
|
# @return [Undef] failed to parse or the arguments are missing |
14
|
|
|
|
|
|
|
# @since v4.1.2 |
15
|
261
|
|
|
261
|
1
|
682
|
my $class = shift; |
16
|
261
|
|
100
|
|
|
625
|
my $mhead = shift // return undef; |
17
|
260
|
|
50
|
|
|
603
|
my $mbody = shift // return undef; |
18
|
260
|
|
|
|
|
440
|
my $match = 0; |
19
|
260
|
|
|
|
|
624
|
my $tryto = [ |
20
|
|
|
|
|
|
|
'Mail could not be delivered', |
21
|
|
|
|
|
|
|
'メッセージを配信できません。', |
22
|
|
|
|
|
|
|
'メール配信に失敗しました', |
23
|
|
|
|
|
|
|
]; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# 'received' => qr/[ ][(]InterScanMSS[)][ ]with[ ]/, |
26
|
260
|
100
|
50
|
|
|
814
|
$match ||= 1 if index($mhead->{'from'}, '"InterScan MSS"') == 0; |
27
|
260
|
50
|
0
|
|
|
691
|
$match ||= 1 if index($mhead->{'from'}, '"InterScan Notification"') == 0; |
28
|
260
|
100
|
100
|
|
|
549
|
$match ||= 1 if grep { $mhead->{'subject'} eq $_ } @$tryto; |
|
780
|
|
|
|
|
1615
|
|
29
|
260
|
100
|
|
|
|
827
|
return undef unless $match; |
30
|
|
|
|
|
|
|
|
31
|
16
|
|
|
|
|
33
|
state $rebackbone = qr|^Content-type:[ ]message/rfc822|m; |
32
|
16
|
|
|
|
|
73
|
my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; |
33
|
16
|
|
|
|
|
93
|
my $emailsteak = Sisimai::RFC5322->fillet($mbody, $rebackbone); |
34
|
16
|
|
|
|
|
31
|
my $recipients = 0; # (Integer) The number of 'Final-Recipient' header |
35
|
16
|
|
|
|
|
26
|
my $v = undef; |
36
|
|
|
|
|
|
|
|
37
|
16
|
|
|
|
|
163
|
for my $e ( split("\n", $emailsteak->[0]) ) { |
38
|
|
|
|
|
|
|
# Read error messages and delivery status lines from the head of the email |
39
|
|
|
|
|
|
|
# to the previous line of the beginning of the original message. |
40
|
569
|
100
|
|
|
|
658
|
next unless length $e; |
41
|
|
|
|
|
|
|
|
42
|
418
|
|
|
|
|
377
|
$v = $dscontents->[-1]; |
43
|
418
|
100
|
100
|
|
|
1560
|
if( $e =~ /\A.+[<>]{3}[ \t]+.+[<]([^ ]+[@][^ ]+)[>]\z/ || |
|
|
|
100
|
|
|
|
|
44
|
|
|
|
|
|
|
$e =~ /\A.+[<>]{3}[ \t]+.+[<]([^ ]+[@][^ ]+)[>]/ || |
45
|
|
|
|
|
|
|
$e =~ /\A(?:Reason:[ ]+)?Unable[ ]to[ ]deliver[ ]message[ ]to[ ][<](.+)[>]/ ) { |
46
|
|
|
|
|
|
|
# Sent <<< RCPT TO: |
47
|
|
|
|
|
|
|
# Received >>> 550 5.1.1 ... user unknown |
48
|
|
|
|
|
|
|
# Unable to deliver message to |
49
|
22
|
|
|
|
|
58
|
my $cr = $1; |
50
|
22
|
50
|
66
|
|
|
83
|
if( $v->{'recipient'} && $cr ne $v->{'recipient'} ) { |
51
|
|
|
|
|
|
|
# There are multiple recipient addresses in the message body. |
52
|
0
|
|
|
|
|
0
|
push @$dscontents, __PACKAGE__->DELIVERYSTATUS; |
53
|
0
|
|
|
|
|
0
|
$v = $dscontents->[-1]; |
54
|
|
|
|
|
|
|
} |
55
|
22
|
|
|
|
|
40
|
$v->{'recipient'} = $cr; |
56
|
22
|
100
|
|
|
|
70
|
$v->{'diagnosis'} = $e if $e =~ /Unable[ ]to[ ]deliver[ ]/; |
57
|
22
|
|
|
|
|
37
|
$recipients = scalar @$dscontents; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
418
|
100
|
|
|
|
629
|
if( $e =~ /\ASent[ \t]+[<]{3}[ \t]+([A-Z]{4})[ \t]/ ) { |
|
|
100
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Sent <<< RCPT TO: |
62
|
6
|
|
|
|
|
17
|
$v->{'command'} = $1 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} elsif( $e =~ /\AReceived[ \t]+[>]{3}[ \t]+(\d{3}[ \t]+.+)\z/ ) { |
65
|
|
|
|
|
|
|
# Received >>> 550 5.1.1 ... user unknown |
66
|
6
|
|
|
|
|
15
|
$v->{'diagnosis'} = $1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} else { |
69
|
|
|
|
|
|
|
# Error message in non-English |
70
|
406
|
50
|
|
|
|
798
|
next unless $e =~ /[ ][<>]{3}[ ]/; |
71
|
0
|
0
|
|
|
|
0
|
$v->{'command'} = $1 if $e =~ /[ ][>]{3}[ ]([A-Z]{4})/; # >>> RCPT TO ... |
72
|
0
|
0
|
|
|
|
0
|
$v->{'diagnosis'} = $1 if $e =~ /[ ][<]{3}[ ](.+)/; # <<< 550 5.1.1 User unknown |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
16
|
50
|
|
|
|
69
|
return undef unless $recipients; |
76
|
|
|
|
|
|
|
|
77
|
16
|
|
|
|
|
31
|
for my $e ( @$dscontents ) { |
78
|
|
|
|
|
|
|
# Set default values if each value is empty. |
79
|
16
|
|
|
|
|
110
|
$e->{'diagnosis'} = Sisimai::String->sweep($e->{'diagnosis'}); |
80
|
16
|
100
|
|
|
|
79
|
$e->{'reason'} = 'userunknown' if $e->{'diagnosis'} =~ /Unable[ ]to[ ]deliver/; |
81
|
|
|
|
|
|
|
} |
82
|
16
|
|
|
|
|
81
|
return { 'ds' => $dscontents, 'rfc822' => $emailsteak->[1] }; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
__END__ |