Sisimai/Lhost/FML.pm

filter: Statementstmt 95.8% 46 / 48 Branchbran 72.2% 13 / 18 Conditioncond 77.7% 7 / 9 MC/DCmcdc 60.0% 3 / 5 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 87.5% 77 / 88 CC 17 SCAR 26.4
CC
17
Cov
88%
inquire
17.9
BEGIN
1.0
BEGIN
1.0
CRAP 14.0
« Sisimai/SMTP/Reply.pm ↑ Summary Sisimai/SMTP/Failure.pm »
1 package Sisimai::Lhost::FML;
2 40 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 40 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub description { 'fml mailing list server/manager: https://www.fml.org/' };
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 903 ▶sub inquire {
Subroutine inquire: called CC=17 SCAR=28.8
Pod documented
9 # Detect an error from fml mailing list server/manager
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 decode or the arguments are missing
14 # @since v4.22.3
15 903 my $class = shift;
16 903 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9021
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 902 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9011
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18  
19 901 ▶ return undef unless defined $mhead->{'x-mlserver'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mhead->{"x-mlserver"} 891 10 901
20 10 ▶ return undef unless index($mhead->{'from'}, '-admin@') > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($mhead->{"from"}, "-admin\@") > 0 0 10 10
21 10 ▶ return undef unless index($mhead->{'message-id'}, '.FML') > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless index($mhead->{"message-id"}, ".FML") > 1 0 10 10
22  
23 10 require Sisimai::Eb;
24 10 state $boundaries = ['Original mail as follows:'];
25 10 state $errortitle = {
26 $Sisimai::Eb::ReFROM => [
27 ' are not member',
28 'NOT MEMBER article from ',
29 'reject mail ',
30 'Spam mail from a spammer is rejected',
31 ],
32 $Sisimai::Eb::RePROC => [
33 'fml system error message',
34 'Loop Alert: ',
35 'Loop Back Warning: ',
36 'WARNING: UNIX FROM Loop',
37 ],
38 $Sisimai::Eb::ReSAFE => ['Security Alert'],
39 };
40  
41 10 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 10 10
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
100
MC/DC0%0/1
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
"Sisimai::RFC5322"->part($mbody, $boundaries)
Truth table50%1/2
A
A= "Sisimai::RFC5322"->part($mbody, $boundaries)
Aresult
11
00
42 10 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
43 10 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
44  
45 10 for my $e ( split("\n", $emailparts->[0]) ) {
46 # Read error messages and delivery status lines from the head of the email to the previous
47 # line of the beginning of the original message.
48 65 ▶ next unless length $e;
Branch: 1 branch
BranchTrueFalseTotal
unless length $e 25 40 65
49  
50 # Duplicated Message-ID in <2ndml@example.com>. Original mail as follows:
51 40 $v = $dscontents->[-1];
52  
53 40 my $p1 = index($e, '<');
54 40 my $p2 = rindex($e, '>');
55 40 ▶ if( $p1 > 0 && $p2 > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p1 > 0 and $p2 > 0) { } 10 30 40
Condition66%2/3
$p1 > 0 and $p2 > 0
!ll&&!rl&&r
30010
MC/DC50%1/2
$p1 > 0 and $p2 > 0
$p1 > 0 $p2 > 0
Truth table66%2/3
A and B
A= $p1 > 0B= $p2 > 0
ABresult
0X0
100
111
56 # You are not a member of this mailing list <neko-nyaan@example.org>.
57 10 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 10 10
58 # There are multiple recipient addresses in the message body.
59 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
60 0 $v = $dscontents->[-1];
61 }
62 10 $v->{'recipient'} = substr($e, $p1 + 1, $p2 - $p1 - 1);
63 10 $v->{'diagnosis'} = $e;
64 10 $recipients++;
65  
66 } else {
67 # If you know the general guide of this list, please send mail with the mail body
68 30 $v->{'diagnosis'} .= $e;
69 }
70 }
71 10 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 10 10
72  
73 10 for my $e ( @$dscontents ) {
74 # Error messages in the message body did not matched
75 10 for my $f ( keys %$errortitle ) {
76 # Try to match with the Subject string
77 17 ▶ next unless grep { index($mhead->{'subject'}, $_) > -1 } $errortitle->{ $f }->@*;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {index($mhead->{"subject"}, $_) != -1;} @{$$errortitle{$f}} 7 10 17
78 10 $e->{'reason'} = $f;
79 10 last;
80 }
81 }
82 10 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
83 }
84  
85 40 1;
86 __END__
« Sisimai/SMTP/Reply.pm ↑ Summary Sisimai/SMTP/Failure.pm »