| 1 | package Sisimai::SMTP::Command; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 92 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 92 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 92 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 92 | ▶ | use Sisimai::Eb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 92 | ▶ | use constant ExceptDATA => [$Sisimai::Eb::CeCONN, $Sisimai::Eb::CeEHLO, $Sisimai::Eb::CeHELO, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 92 | $Sisimai::Eb::CeMAIL, $Sisimai::Eb::CeRCPT]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 92 | ▶ | use constant BeforeRCPT => [$Sisimai::Eb::CeCONN, $Sisimai::Eb::CeEHLO, $Sisimai::Eb::CeHELO, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 92 | $Sisimai::Eb::CeMAIL, $Sisimai::Eb::CeAUTH, $Sisimai::Eb::CeTTLS]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 92 | state $Availables = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | $Sisimai::Eb::CeHELO, $Sisimai::Eb::CeEHLO, $Sisimai::Eb::CeMAIL, $Sisimai::Eb::CeRCPT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | $Sisimai::Eb::CeDATA, $Sisimai::Eb::CeQUIT, $Sisimai::Eb::CeRSET, $Sisimai::Eb::CeNOOP, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | $Sisimai::Eb::CeVRFY, $Sisimai::Eb::CeETRN, $Sisimai::Eb::CeEXPN, $Sisimai::Eb::CeHELP, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | $Sisimai::Eb::CeAUTH, $Sisimai::Eb::CeTTLS, $Sisimai::Eb::CeXFWD, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | $Sisimai::Eb::CeCONN, # CONN is a pseudo SMTP command used only in Sisimai | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 92 | state $Detectable = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | $Sisimai::Eb::CeHELO, $Sisimai::Eb::CeEHLO, $Sisimai::Eb::CeTTLS, "AUTH PLAIN", "AUTH LOGIN", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | "AUTH CRAM-", "AUTH DIGEST-", "MAIL F", $Sisimai::Eb::CeRCPT, "RCPT T", $Sisimai::Eb::CeDATA, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | $Sisimai::Eb::CeQUIT, $Sisimai::Eb::CeXFWD, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7162 | ▶ | sub test { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Check that an SMTP command in the argument is valid or not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # @param [String] argv0 An SMTP command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # @return [Boolean] 0: Is not a valid SMTP command, 1: Is a valid SMTP command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # @since v5.0.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7162 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 7162 | ▶ | my $argv0 = shift // return 0; return 0 unless length $argv0 > 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
shift() // (return 0)
MC/DC100%1/1
shift() // (return 0)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 5198 | ▶ | return 1 if grep { index($argv0, $_) > -1 } @$Availables; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1977 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3507 | ▶ | sub find { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: called CC=22 SCAR=32.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Pick an SMTP command from the given string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # @param [String] argv0 A transcript text MTA returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # @return [String] An SMTP command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # @since v5.0.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3507 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3507 | ▶ | my $argv0 = shift // return ""; return "" unless __PACKAGE__->test($argv0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
shift() // (return "")
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1519 | my $issuedcode = ' '.lc($argv0).' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1519 | my $commandmap = {'STAR' => $Sisimai::Eb::CeTTLS, 'XFOR' => $Sisimai::Eb::CeXFWD}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1519 | my $commandset = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1519 | for my $e ( @$Detectable ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # Find an SMTP command from the given string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 19747 | ▶ | my $p0 = index($argv0, $e); next if $p0 < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2087 | ▶ | if( index($e, " ") < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # For example, "RCPT T" does not appear in an email address or a domain name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1283 | my $cx = 1; while(1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # Exclude an SMTP command in the part of an email address, a domain name, such as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # DATABASE@EXAMPLE.JP, EMAIL.EXAMPLE.COM, and so on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1283 | my $ca = ord(substr($issuedcode, $p0, 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1283 | my $cz = ord(substr($issuedcode, $p0 + length($e) + 1, 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1283 | ▶ | last if $ca > 47 && $ca < 58 || $cz > 47 && $cz < 58; # 0-9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$ca > 47 and $ca < 58 or $cz > 47 and $cz < 58
$ca > 47 and $ca < 58
$cz > 47 and $cz < 58
MC/DC0%0/4
$ca > 47 and $ca < 58 or $cz > 47 and $cz < 58
$ca > 47
$ca < 58
$cz > 47
$cz < 58
Truth table57%4/7
A and B or C and D
A= $ca > 47B= $ca < 58C= $cz > 47D= $cz < 58
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1283 | ▶ | last if $ca > 63 && $ca < 91 || $cz > 63 && $cz < 91; # @-Z | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$ca > 63 and $ca < 91 or $cz > 63 and $cz < 91
$ca > 63 and $ca < 91
$cz > 63 and $cz < 91
MC/DC25%1/4
$ca > 63 and $ca < 91 or $cz > 63 and $cz < 91
$ca > 63
$ca < 91
$cz > 63
$cz < 91
Truth table42%3/7
A and B or C and D
A= $ca > 63B= $ca < 91C= $cz > 63D= $cz < 91
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1282 | ▶ | last if $ca > 96 && $ca < 123 || $cz > 96 && $cz < 123; # `-z | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$ca > 96 and $ca < 123 or $cz > 96 and $cz < 123
$ca > 96 and $ca < 123
$cz > 96 and $cz < 123
MC/DC0%0/4
$ca > 96 and $ca < 123 or $cz > 96 and $cz < 123
$ca > 96
$ca < 123
$cz > 96
$cz < 123
Truth table14%1/7
A and B or C and D
A= $ca > 96B= $ca < 123C= $cz > 96D= $cz < 123
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1282 | $cx = 0; last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1283 | ▶ | next if $cx == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # There is the same command in the "commanset" or nor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2086 | ▶ | my $cv = substr($e, 0, 4); next if grep { index($cv, $_) == 0 } @$commandset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1530 | ▶ | $cv = $commandmap->{ $cv } if exists $commandmap->{ $cv }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1530 | push @$commandset, $cv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1519 | ▶ | return "" unless scalar @$commandset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1514 | return pop @$commandset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 92 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||