| 1 | package Mail::DKIM2::Chain; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 196 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 196 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 196 | our $VERSION = '0.34'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 196 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 196 | ▶ | use Mail::DKIM2::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 196 | ▶ | use Mail::DKIM2::Common qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | MI_MISSING_M_ERROR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | MAX_CHAIN_LENGTH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | chain_length_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | chain_number_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | duplicate_number_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | extract_mi_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | mi_version_tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | unkeyable_signature_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | valid_sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 196 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 196 | ▶ | use Mail::DKIM2::HeaderParser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 196 | ▶ | use Mail::DKIM2::Signature; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 196 | ▶ | use Mail::DKIM2::MessageInstance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # The Message-Instance and DKIM2-Signature fields of one message, numbered: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # what the Verifier, the Signer and the Gate each need to know about a chain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # before any of them looks at the content. Fields are added as the header is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # read; nothing here hashes, fetches a key or checks a signature. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2090 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my ($class) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | return bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | instance => {}, # m => the raw field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | signature => {}, # i => { raw => the raw field, sig => Signature } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | count => {}, # lower-cased field name => how many there were | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | numbers => { 'message-instance' => [], 'dkim2-signature' => [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | parsed => {}, # m => [MessageInstance or undef, error] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # from_fields(\@fields): a chain from header fields given whole, name and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # value, as Mail::DKIM2::HeaderParser keeps them. Other fields are ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | sub from_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_fields: called CC=3 SCAR=15.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my ($class, $fields) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_fields: not called CC=3 SCAR=15.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $self = $class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | for my $raw (@$fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my ($name, $value) = $raw =~ /\A([^\s:]+)[ \t]*:[ \t]*(.*)\z/s or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $value =~ s/\r?\n\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->add_field($name, $value, $raw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # from_message($text): a chain from a message, or from its header block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # alone, as a string. Only the header fields are read. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 422 | ▶ | sub from_message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_message: called CC=2 SCAR=10.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my ($class, $text) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_message: not called CC=2 SCAR=10.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | Carp::croak("from_message needs a message") unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $reader = Mail::DKIM2::Chain::_Reader->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $reader->PRINT($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $reader->CLOSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return $reader->{chain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # The header fields of a message, as the Signer and the Verifier split | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # them, straight into a chain; the body is not read. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | package Mail::DKIM2::Chain::_Reader; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 196 | ▶ | use parent -norequire, 'Mail::DKIM2::HeaderParser'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 422 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->SUPER::init; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->{chain} = Mail::DKIM2::Chain->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3634 | ▶ | sub handle_header { $_[0]{chain}->add_field(@_[1 .. 3]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_header: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 422 | ▶ | sub finish_header { $_[0]->stop } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish_header: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # add_field($name, $value, $raw): take one header field -- its name, its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # value without the line break, and the whole field as it is in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # message. True if it was a Message-Instance or DKIM2-Signature field. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # A field that cannot be placed in the chain is remembered as the chain's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # fault (numbering_error), never skipped: a DKIM2-Signature that does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # parse, or has no i=, or an i= or m= that is not a chain number (1*DIGIT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # at most two digits, no more than MAX_CHAIN_LENGTH); a Message-Instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # without a usable m=. Past MAX_CHAIN_LENGTH fields of either kind the rest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # are counted and not read: the count alone is the fault. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 196 | ▶ | sub add_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_field: called CC=17 SCAR=28.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 23216 | my ($self, $name, $value, $raw) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 23216 | my $lc = lc $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 23216 | $lc =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 23216 | ▶ | return 0 unless $lc eq 'message-instance' || $lc eq 'dkim2-signature'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$lc eq "message-instance" or $lc eq "dkim2-signature"
MC/DC100%2/2
$lc eq "message-instance" or $lc eq "dkim2-signature"
$lc eq "message-instance"
$lc eq "dkim2-signature"
Truth table100%3/3
A or B
A= $lc eq "message-instance"B= $lc eq "dkim2-signature"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 7174 | ▶ | return 1 if ++$self->{count}{$lc} > MAX_CHAIN_LENGTH; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 6171 | ▶ | $raw //= "$name:$value"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$raw //= "${name}:$value"
MC/DC0%0/1
$raw //= "${name}:$value"
$raw
Truth table50%1/2
A
A= $raw
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 6171 | ▶ | if ($lc eq 'message-instance') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 3445 | my $tag = mi_version_tag($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3445 | ▶ | if (!defined $tag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | ▶ | $self->{instance_unusable} //= MI_MISSING_M_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"instance_unusable"} //= "PERMERROR: Message-Instance m= tag=m missing"
MC/DC0%0/1
$self->{"instance_unusable"} //= "PERMERROR: Message-Instance m= tag=m missing"
$self->{"instance_unusable"}
Truth table50%1/2
A
A= $self->{"instance_unusable"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif (my $e = chain_number_error('Message-Instance', 'm', $tag)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 17 | ▶ | $self->{instance_unusable} //= $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"instance_unusable"} //= $e
MC/DC0%0/2
$self->{"instance_unusable"} //= $e
$self->{"instance_unusable"}
$e
Truth table33%1/3
A //= B
A= $self->{"instance_unusable"}B= $e
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3425 | my $m = extract_mi_version($value); # numeric: m=01 is m=1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3425 | push @{ $self->{numbers}{$lc} }, $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 3425 | $self->{instance}{$m} = $raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 3445 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2726 | my $sig = eval { Mail::DKIM2::Signature->parse($value) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2726 | ▶ | die $@ if ref $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2726 | ▶ | my $i = $sig ? $sig->sequence : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2726 | ▶ | if (!valid_sequence($i)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 62 | ▶ | $self->{signature_unusable} //= unkeyable_signature_error($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"signature_unusable"} //= unkeyable_signature_error($value)
MC/DC0%0/2
$self->{"signature_unusable"} //= unkeyable_signature_error($value)
$self->{"signature_unusable"}
unkeyable_signature_error($value)
Truth table33%1/3
A //= B
A= $self->{"signature_unusable"}B= unkeyable_signature_error($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ▶ | elsif (my $e = chain_number_error('DKIM2-Signature', 'i', $i) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
chain_number_error("DKIM2-Signature", "i", $i) // chain_number_error("DKIM2-Signature", "m", $sig->version, $i)
MC/DC100%2/2
chain_number_error("DKIM2-Signature", "i", $i) // chain_number_error("DKIM2-Signature", "m", $sig->version, $i)
chain_number_error("DKIM2-Signature", "i", $i)
chain_number_error("DKIM2-Signature", "m", $sig->version, $i)
Truth table100%3/3
A // B
A= chain_number_error("DKIM2-Signature", "i", $i)B= chain_number_error("DKIM2-Signature", "m", $sig->version, $i)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | // chain_number_error('DKIM2-Signature', 'm', $sig->version, $i)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 24 | ▶ | $self->{signature_unusable} //= $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"signature_unusable"} //= $e
MC/DC0%0/2
$self->{"signature_unusable"} //= $e
$self->{"signature_unusable"}
$e
Truth table33%1/3
A //= B
A= $self->{"signature_unusable"}B= $e
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 2640 | push @{ $self->{numbers}{$lc} }, $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2640 | $self->{signature}{ $i + 0 } = { raw => $raw, sig => $sig }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 2726 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # --- What is in the chain --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 540 | ▶ | sub count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 540 | my ($self, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 540 | ▶ | return $self->{count}{ lc $field } // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"count"}{lc $field} // 0
MC/DC100%1/1
$self->{"count"}{lc $field} // 0
$self->{"count"}{lc $field}
Truth table100%2/2
A
A= $self->{"count"}{lc $field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | sub is_empty { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_empty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | return !%{ $self->{count} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # (Through an array: sort in scalar context returns nothing useful, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # "unless $chain->instance_numbers" should count them.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7034 | ▶ | sub instance_numbers { my @n = sort { $a <=> $b } keys %{ $_[0]{instance} }; return @n } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instance_numbers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5630 | ▶ | sub signature_numbers { my @n = sort { $a <=> $b } keys %{ $_[0]{signature} }; return @n } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signature_numbers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2948 | ▶ | sub top_instance { return ($_[0]->instance_numbers)[-1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_instance: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2635 | ▶ | sub top_signature_number { return ($_[0]->signature_numbers)[-1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_signature_number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1225 | ▶ | sub instance_field { return $_[0]{instance}{ $_[1] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instance_field: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # The chain's own maps, for a caller that walks all of it: m => the raw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # field, and i => { raw => the raw field, sig => the Signature }. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1094 | ▶ | sub instance_fields { return $_[0]{instance} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instance_fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1094 | ▶ | sub signature_entries { return $_[0]{signature} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signature_entries: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1762 | ▶ | sub signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signature: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1762 | my ($self, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1762 | ▶ | my $entry = $self->{signature}{$i} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1762 | return $entry->{sig}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 727 | ▶ | sub signature_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signature_field: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 727 | my ($self, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 727 | ▶ | my $entry = $self->{signature}{$i} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 725 | return $entry->{raw}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1887 | ▶ | sub signatures { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signatures: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1887 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1887 | return map { $self->{signature}{$_}{sig} } $self->signature_numbers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 215 | ▶ | sub top_signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_signature: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 215 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 215 | ▶ | my $i = $self->top_signature_number // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->top_signature_number // (return)
MC/DC100%1/1
$self->top_signature_number // (return)
$self->top_signature_number
Truth table100%2/2
A
A= $self->top_signature_number
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 147 | return $self->{signature}{$i}{sig}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # instance($m): the parsed Message-Instance m=, or (undef, $error) when it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # is not there or does not parse -- $error in the words the Verifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # reports. Parsed once, however many callers ask. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 3851 | ▶ | sub instance { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instance: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 3851 | my ($self, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 3851 | ▶ | my $cached = $self->{parsed}{$m} //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"parsed"}{$m} //= do {
my $raw = $self->{"instance"}{$m};
if (not defined $raw) {
[undef, "PERMERROR: Message-Instance m=$m missing"];
}
else {
(my $value = $raw) =~ s/\A[^:]*:[ \t]*//;
my $obj = eval {
do {
"Mail::DKIM2::MessageInstance"->parse($value)
}
};
die $@ if ref $@;
$obj ? [$obj] : [undef, Mail::DKIM2::MessageInstance::_parse_error($@)];
}
}
MC/DC0%0/2
$self->{"parsed"}{$m} //= do {
my $raw = $self->{"instance"}{$m};
if (not defined $raw) {
[undef, "PERMERROR: Message-Instance m=$m missing"];
}
else {
(my $value = $raw) =~ s/\A[^:]*:[ \t]*//;
my $obj = eval {
do {
"Mail::DKIM2::MessageInstance"->parse($value)
}
};
die $@ if ref $@;
$obj ? [$obj] : [undef, Mail::DKIM2::MessageInstance::_parse_error($@)];
}
}
$self->{"parsed"}{$m}
do {
my $raw = $self->{"instance"}{$m};
if (not defined $raw) {
[undef, "PERMERROR: Message-Instance m=$m missing"];
}
else {
(my $value = $raw) =~ s/\A[^:]*:[ \t]*//;
my $obj = eval {
do {
"Mail::DKIM2::MessageInstance"->parse($value)
}
};
die $@ if ref $@;
$obj ? [$obj] : [undef, Mail::DKIM2::MessageInstance::_parse_error($@)];
}
}
Truth table66%2/3
A //= B
A= $self->{"parsed"}{$m}B= do {
my $raw = $self->{"instance"}{$m};
if (not defined $raw) {
[undef, "PERMERROR: Message-Instance m=$m missing"];
}
else {
(my $value = $raw) =~ s/\A[^:]*:[ \t]*//;
my $obj = eval {
do {
"Mail::DKIM2::MessageInstance"->parse($value)
}
};
die $@ if ref $@;
$obj ? [$obj] : [undef, Mail::DKIM2::MessageInstance::_parse_error($@)];
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1873 | my $raw = $self->{instance}{$m}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1873 | ▶ | if (!defined $raw) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | [undef, "PERMERROR: Message-Instance m=$m missing"]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1872 | (my $value = $raw) =~ s/\A[^:]*:[ \t]*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1872 | my $obj = eval { Mail::DKIM2::MessageInstance->parse($value) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1872 | ▶ | die $@ if ref $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1872 | ▶ | $obj ? [$obj] : [undef, Mail::DKIM2::MessageInstance::_parse_error($@)]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3851 | ▶ | return wantarray ? @$cached : $cached->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # covered_m(): the highest m= any signature names, or 0. A DKIM2-Signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # with m=k covers instances 1 to k (-09 section 10.2), so every instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # above this is one nobody has signed yet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1884 | ▶ | sub covered_m { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
covered_m: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1884 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1884 | my $covered = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1884 | for my $sig ($self->signatures) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3291 | ▶ | my $m = $sig->version // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$sig->version // (next)
MC/DC0%0/1
$sig->version // (next)
$sig->version
Truth table50%1/2
A
A= $sig->version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 3291 | ▶ | $covered = 0 + $m if $m > $covered; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1884 | return $covered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # unsigned_instances(): the m= of every instance above covered_m, ascending. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | ▶ | sub unsigned_instances { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unsigned_instances: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | my $covered = $self->covered_m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | my @above = grep { $_ > $covered } $self->instance_numbers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | return @above; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # instances_changing($name, $above, $upto): the m= of every instance with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # $above < m <= $upto that has a header Recipe for the field named $name -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # the hops, between two signatures, that say they changed that field. One | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # that does not parse says nothing. m=1 is never in it: its Recipes record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # what happened to the message before DKIM2, which no signature answers for. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 958 | ▶ | sub instances_changing { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instances_changing: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 958 | my ($self, $name, $above, $upto) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 958 | ▶ | $above //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$above //= 0
MC/DC0%0/1
$above //= 0
$above
Truth table50%1/2
A
A= $above
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 958 | ▶ | $upto //= $self->top_instance // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$upto //= $self->top_instance // 0
$self->top_instance // 0
MC/DC100%1/1
$upto //= $self->top_instance // 0
$upto
Truth table100%2/2
A
A= $upto
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | my @changing = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 958 | ▶ | my $mi = $_ >= 2 && $_ > $above && $_ <= $upto ? $self->instance($_) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$_ >= 2 and $_ > $above and $_ <= $upto
$_ >= 2 and $_ > $above
MC/DC100%3/3
$_ >= 2 and $_ > $above and $_ <= $upto
$_ >= 2
$_ > $above
$_ <= $upto
Truth table100%4/4
A and B and C
A= $_ >= 2B= $_ > $aboveC= $_ <= $upto
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 4920 | ▶ | $mi && $mi->changes_header($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$mi && $mi->changes_header($name)
MC/DC100%2/2
$mi && $mi->changes_header($name)
$mi
$mi->changes_header($name)
Truth table100%3/3
A && B
A= $miB= $mi->changes_header($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } $self->instance_numbers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 958 | return @changing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # --- Whether it is a chain --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # numbering_error(%opts): the PERMERROR for a chain whose fields cannot be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # numbered, or undef -- too many fields, a field with no usable number, a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # number given twice. In the interop contract's order (C9, a to e), so every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # verifier names the same fault first. Signatures => 0 leaves the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # DKIM2-Signature fields out of it, but for their count. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2773 | ▶ | sub numbering_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
numbering_error: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2773 | my ($self, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2773 | ▶ | my $sigs = $o{Signatures} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$o{"Signatures"} // 1
MC/DC100%1/1
$o{"Signatures"} // 1
$o{"Signatures"}
Truth table100%2/2
A
A= $o{"Signatures"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2773 | my $n = $self->{numbers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | return chain_length_error($self->{count}) # a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | // $self->{instance_unusable} # b | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2749 | ▶ | // duplicate_number_error('Message-Instance', 'm', @{ $n->{'message-instance'} }) # c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | // ($sigs ? $self->{signature_unusable} : undef) # d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | // ($sigs ? duplicate_number_error('DKIM2-Signature', 'i', # e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 2773 | ▶ | @{ $n->{'dkim2-signature'} }) : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%12/12
(((chain_length_error($self->{"count"}) // $self->{"instance_unusable"}) // duplicate_number_error("Message-Instance", "m", @{$$n{"message-instance"};})) // ($sigs ? $self->{"signature_unusable"} : undef)) // ($sigs ? duplicate_number_error("DKIM2-Signature", "i", @{$$n{"dkim2-signature"};}) : undef)
((chain_length_error($self->{"count"}) // $self->{"instance_unusable"}) // duplicate_number_error("Message-Instance", "m", @{$$n{"message-instance"};})) // ($sigs ? $self->{"signature_unusable"} : undef)
(chain_length_error($self->{"count"}) // $self->{"instance_unusable"}) // duplicate_number_error("Message-Instance", "m", @{$$n{"message-instance"};})
chain_length_error($self->{"count"}) // $self->{"instance_unusable"}
MC/DC100%5/5
(((chain_length_error($self->{"count"}) // $self->{"instance_unusable"}) // duplicate_number_error("Message-Instance", "m", @{$$n{"message-instance"};})) // ($sigs ? $self->{"signature_unusable"} : undef)) // ($sigs ? duplicate_number_error("DKIM2-Signature", "i", @{$$n{"dkim2-signature"};}) : undef)
chain_length_error($self->{"count"})
$self->{"instance_unusable"}
duplicate_number_error("Message-Instance", "m", @{$$n{"message-instance"};})
($sigs ? $self->{"signature_unusable"} : undef)
($sigs ? duplicate_number_error("DKIM2-Signature", "i", @{$$n{"dkim2-signature"};}) : undef)
Truth table100%6/6
A // B // C // D // E
A= chain_length_error($self->{"count"})B= $self->{"instance_unusable"}C= duplicate_number_error("Message-Instance", "m", @{$$n{"message-instance"};})D= ($sigs ? $self->{"signature_unusable"} : undef)E= ($sigs ? duplicate_number_error("DKIM2-Signature", "i", @{$$n{"dkim2-signature"};}) : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # structure_error(%opts): numbering_error, then the gaps and the coverage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # the numbers give (-09 section 14.2; C9, f to h): every instance from m=1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # to the highest there is or the highest the top signature names; no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # instance above every signature's m= (unless AllowUnsigned: a signer holds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # the instance it is about to sign); every signature from i=1 to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # highest. Signatures => 0 checks the instances alone. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2067 | ▶ | sub structure_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
structure_error: called CC=17 SCAR=28.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2067 | my ($self, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 2067 | Mail::DKIM2::Util::check_options('structure_error', \%o, qw(Signatures AllowUnsigned)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2067 | ▶ | my $sigs = $o{Signatures} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$o{"Signatures"} // 1
MC/DC100%1/1
$o{"Signatures"} // 1
$o{"Signatures"}
Truth table100%2/2
A
A= $o{"Signatures"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2067 | ▶ | if (my $error = $self->numbering_error(Signatures => $sigs)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 67 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2000 | my $top_m = $self->top_instance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2000 | ▶ | my $top_i = $sigs ? $self->top_signature_number : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2000 | ▶ | my $named = defined $top_i ? ($self->signature($top_i)->version || 0) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->signature($top_i)->version or 0
MC/DC0%0/1
$self->signature($top_i)->version or 0
$self->signature($top_i)->version
Truth table50%1/2
A
A= $self->signature($top_i)->version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2000 | ▶ | my $upto = ($top_m // 0) > $named ? $top_m : $named; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$top_m // 0
MC/DC100%1/1
$top_m // 0
$top_m
Truth table100%2/2
A
A= $top_m
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2000 | for my $m (1 .. $upto) { # f | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2991 | ▶ | return "PERMERROR: Message-Instance m=$m missing" unless $self->{instance}{$m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 1992 | ▶ | if (defined $top_m && $sigs && !$o{AllowUnsigned}) { # g | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $top_m and $sigs and not $o{"AllowUnsigned"}
defined $top_m and $sigs
MC/DC100%3/3
defined $top_m and $sigs and not $o{"AllowUnsigned"}
defined $top_m
$sigs
not $o{"AllowUnsigned"}
Truth table100%4/4
A and B and not(C)
A= defined $top_mB= $sigsC= not $o{"AllowUnsigned"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1463 | ▶ | return "PERMERROR: Message-Instance m=$top_m is not signed" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | if $top_m > $self->covered_m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1980 | ▶ | for my $i (1 .. ($top_i // 0)) { # h | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$top_i // 0
MC/DC100%1/1
$top_i // 0
$top_i
Truth table100%2/2
A
A= $top_i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2803 | ▶ | return "PERMERROR: DKIM2-Signature i=$i missing" unless $self->{signature}{$i}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1976 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 196 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||