Authentication/Handler/BIMI.pm

filter: Statementstmt 64.9% 152 / 234 Branchbran 55.4% 71 / 128 Conditioncond 39.3% 13 / 33 MC/DCmcdc 12.5% 2 / 16 Subroutinesub 92.8% 13 / 14 Podpod 12.5% 1 / 8 totaltotal 58.2% 252 / 433 CC 84 SCAR 58.1
CC
84
Cov
60%
eom_callback
446.3
header_callback
19.8
setup_callback
5.5
CRAP 333.5
↑ Summary Authentication/Handler/ReturnOK.pm »
1 package Mail::Milter::Authentication::Handler::BIMI;
2 2 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Mail::Milter::Authentication::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: Handler class for BIMI
7 2 our $VERSION = '4.20261116'; # VERSION
8 2 ▶use base 'Mail::Milter::Authentication::Handler';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Mail::BIMI 3.20230913;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶sub default_config {
Subroutine default_config: called CC=1 SCAR=0.0
Pod undocumented
12 return {
13 1 'bimi_options' => {},
14 'rbl_allowlist' => '',
15 'rbl_blocklist' => '',
16 'rbl_no_evidence_allowlist' => '',
17 };
18 }
19  
20 1 ▶sub register_metrics {
Subroutine register_metrics: called CC=1 SCAR=0.0
Pod documented
21 return {
22 1 'bimi_total' => 'The number of emails processed for BIMI',
23 };
24 }
25  
26 1 ▶sub setup_callback {
Subroutine setup_callback: called CC=5 SCAR=17.0
Pod undocumented
27 1 my ($self) = @_;
28 1 my $config = $self->handler_config();
29 1 ▶ my $sanitize_location_header = $config->{sanitize_location_header} // 'yes';
Condition50%1/2
$config->{"sanitize_location_header"} // "yes"
l!l
01
MC/DC0%0/1
$config->{"sanitize_location_header"} // "yes"
$config->{"sanitize_location_header"}
Truth table50%1/2
A
A= $config->{"sanitize_location_header"}
Aresult
11
00
30 1 ▶ my $sanitize_indicator_header = $config->{sanitize_indicator_header} // 'silent';
Condition50%1/2
$config->{"sanitize_indicator_header"} // "silent"
l!l
01
MC/DC0%0/1
$config->{"sanitize_indicator_header"} // "silent"
$config->{"sanitize_indicator_header"}
Truth table50%1/2
A
A= $config->{"sanitize_indicator_header"}
Aresult
11
00
31 1 ▶ $self->add_header_to_sanitize_list('bimi-location', $sanitize_location_header eq 'silent') unless $sanitize_location_header eq 'no';
Branch: 1 branch
BranchTrueFalseTotal
unless $sanitize_location_header eq "no" 1 0 1
32 1 ▶ $self->add_header_to_sanitize_list('bimi-indicator', $sanitize_indicator_header eq 'silent') unless $sanitize_indicator_header eq 'no';
Branch: 1 branch
BranchTrueFalseTotal
unless $sanitize_indicator_header eq "no" 1 0 1
33 1 return;
34 }
35  
36 10 ▶sub envfrom_callback {
Subroutine envfrom_callback: called CC=1 SCAR=0.0
Pod undocumented
37 10 my ( $self, $env_from ) = @_;
38 10 $self->{ 'header_added' } = 0;
39 }
40  
41 46 ▶sub header_callback {
Subroutine header_callback: called CC=9 SCAR=29.9
Pod undocumented
42 46 my ( $self, $header, $value ) = @_;
43  
44 46 ▶ return if ( $self->is_local_ip_address() );
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_local_ip_address 0 46 46
45 46 ▶ return if ( $self->is_trusted_ip_address() );
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_trusted_ip_address 0 46 46
46 46 ▶ return if ( $self->is_authenticated() );
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_authenticated 0 46 46
47 46 ▶ return if ( $self->{'failmode'} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failmode"} 0 46 46
48  
49 46 ▶ if ( lc $header eq 'bimi-selector' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $header eq "bimi-selector") 7 39 46
50 7 ▶ if ( exists $self->{'selector'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"selector"}) 0 7 7
51 0 $self->dbgout( 'BIMIFail', 'Multiple BIMI-Selector fields', LOG_DEBUG );
52 0 my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'bimi' )->safe_set_value( 'fail' );
53 0 $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'multiple BIMI-Selector fields in message' ) );
54 0 $self->add_auth_header( $header );
55 0 $self->metric_count( 'bimi_total', { 'result' => 'fail', 'reason' => 'bad_selector_header' } );
56 0 $self->{ 'header_added' } = 1;
57 0 $self->{'failmode'} = 1;
58 0 return;
59 }
60 7 $self->{'selector'} = $value;
61 }
62 46 ▶ if ( lc $header eq 'from' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $header eq "from") 10 36 46
63 10 ▶ if ( exists $self->{'from_header'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"from_header"}) 0 10 10
64 0 $self->dbgout( 'BIMIFail', 'Multiple RFC5322 from fields', LOG_DEBUG );
65 0 my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'bimi' )->safe_set_value( 'fail' );
66 0 $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'multiple RFC5322 from fields in message' ) );
67 0 $self->add_auth_header( $header );
68 0 $self->metric_count( 'bimi_total', { 'result' => 'fail', 'reason' => 'bad_from_header' } );
69 0 $self->{ 'header_added' } = 1;
70 0 $self->{'failmode'} = 1;
71 0 return;
72 }
73 10 $self->{'from_header'} = $value;
74 }
75 }
76  
77 1 ▶sub eom_requires {
Subroutine eom_requires: called CC=1 SCAR=0.0
Pod undocumented
78 1 my ($self) = @_;
79 1 my @requires = qw{ DMARC };
80 1 return \@requires;
81 }
82  
83 10 ▶sub eom_callback {
Subroutine eom_callback: called CC=72 SCAR=61.0
Pod undocumented
84 10 my ($self) = @_;
85 10 my $config = $self->handler_config();
86  
87 10 ▶ if ( $config->{rbl_allowlist} && $config->{rbl_blocklist} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"rbl_allowlist"} and $config->{"rbl_blocklist"}) 0 10 10
Condition33%1/3
$config->{"rbl_allowlist"} and $config->{"rbl_blocklist"}
!ll&&!rl&&r
1000
MC/DC0%0/2
$config->{"rbl_allowlist"} and $config->{"rbl_blocklist"}
$config->{"rbl_allowlist"} $config->{"rbl_blocklist"}
Truth table33%1/3
A and B
A= $config->{"rbl_allowlist"}B= $config->{"rbl_blocklist"}
ABresult
0X0
100
111
88 0 $self->dbgout( 'BIMI Error', 'Cannot specify both rbl_allowlist and rbl_blocklist', LOG_DEBUG );
89 0 return;
90 }
91  
92 10 ▶ return if ( $self->{ 'header_added' } );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"header_added"} 0 10 10
93 10 ▶ return if ( $self->is_local_ip_address() );
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_local_ip_address 0 10 10
94 10 ▶ return if ( $self->is_trusted_ip_address() );
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_trusted_ip_address 0 10 10
95 10 ▶ return if ( $self->is_authenticated() );
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_authenticated 0 10 10
96 10 ▶ return if ( $self->{'failmode'} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"failmode"} 0 10 10
97 10 eval {
98 10 my $Domain = $self->get_domain_from( $self->{'from_header'} );
99  
100 10 my $DMARCResults = $self->get_object( 'dmarc_results' );
101 10 ▶ if ( ! $DMARCResults ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $DMARCResults) { } 0 10 10
102  
103 0 my $failure_type = 'temperror';
104 0 my $top_handler = $self->get_top_handler();
105 0 my @auth_headers;
106 0 ▶ if ( exists( $top_handler->{'auth_headers'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $top_handler->{"auth_headers"}) 0 0 0
107 0 for my $type ( sort keys $top_handler->{'auth_headers'}->%* ) {
108 0 @auth_headers = ( @auth_headers, @{ $top_handler->{'auth_headers'}->{$type} } );
109 }
110 }
111 0 ▶ if (@auth_headers) {
Branch: 1 branch
BranchTrueFalseTotal
if (@auth_headers) 0 0 0
112 0 foreach my $auth_header (@auth_headers) {
113 0 ▶ next unless $auth_header->key eq 'dmarc';
Branch: 1 branch
BranchTrueFalseTotal
unless $auth_header->key eq "dmarc" 0 0 0
114 0 ▶ if ( $auth_header->value eq 'permerror' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth_header->value eq "permerror") 0 0 0
115 0 $failure_type = 'permerror';
116 0 last;
117 }
118 }
119 }
120  
121 0 $self->log_error( 'BIMI Error No DMARC Results object');
122 0 my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'bimi' )->safe_set_value( $failure_type );
123 0 $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'Internal DMARC error' ) );
124 0 $self->add_auth_header( $header );
125 0 $self->{ 'header_added' } = 1;
126  
127 }
128 else {
129 10 ▶ if ( scalar @$DMARCResults != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$DMARCResults != 1) { } 0 10 10
130 0 $self->dbgout( 'BIMIFail', 'Multiple DMARC Results', LOG_DEBUG );
131 0 my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'bimi' )->safe_set_value( 'fail' );
132 0 $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'multiple DMARC results for message' ) );
133 0 $self->add_auth_header( $header );
134 0 $self->metric_count( 'bimi_total', { 'result' => 'fail', 'reason' => 'multiple_dmarc_results' } );
135 0 $self->{ 'header_added' } = 1;
136 0 $self->{'failmode'} = 1;
137 0 return;
138 }
139 else {
140 10 my $DMARCResult = clone $DMARCResults->[0]; # Clone so we can modify without breaking reporting data
141  
142 ## Consider ARC
143 # We only have 1 DMARC result so we find the auth results header that it added
144 10 my $selector_arc_pass = 0;
145 10 ▶ if ( $DMARCResult->result ne 'pass' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DMARCResult->result ne "pass") 2 8 10
146 2 my $top_handler = $self->get_top_handler();
147 2 my @auth_headers;
148 2 ▶ if ( exists( $top_handler->{'auth_headers'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $top_handler->{"auth_headers"}) 2 0 2
149 2 for my $type ( sort keys $top_handler->{'auth_headers'}->%* ) {
150 2 @auth_headers = ( @auth_headers, @{ $top_handler->{'auth_headers'}->{$type} } );
151 }
152 }
153 2 ▶ if (@auth_headers) {
Branch: 1 branch
BranchTrueFalseTotal
if (@auth_headers) 2 0 2
154 2 foreach my $auth_header ( @auth_headers ) {
155 9 ▶ next if $auth_header->key ne 'dmarc';
Branch: 1 branch
BranchTrueFalseTotal
if $auth_header->key ne "dmarc" 7 2 9
156 2 ▶ my $arc_aware_result = eval{ $auth_header->search({key=>'policy.arc-aware-result'})->children->[0]->value } // '';
Condition50%1/2
eval { do { $auth_header->search({"key", "policy.arc-aware-result"})->children->[0]->value } } // ""
l!l
20
MC/DC0%0/1
eval { do { $auth_header->search({"key", "policy.arc-aware-result"})->children->[0]->value } } // ""
eval { do { $auth_header->search({"key", "policy.arc-aware-result"})->children->[0]->value } }
Truth table50%1/2
A
A= eval { do { $auth_header->search({"key", "policy.arc-aware-result"})->children->[0]->value } }
Aresult
11
00
157 2 $self->handle_exception( $@ );
158 2 ▶ if ( $arc_aware_result eq 'pass' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arc_aware_result eq "pass") 1 1 2
159 1 $self->log_error( 'BIMI DMARC ARC pass detected' );
160 1 $DMARCResult->{result} = $arc_aware_result; # Feels hacky, but does the right thing
161 # Note, we can't check for signness of BIMI-Selector for arc forwarded mail where DKIM context has been lost
162 # When we have a pass by arc we skip the DKIM check for BIMI-Selector
163 1 $selector_arc_pass = 1;
164 }
165 }
166 }
167 }
168  
169 10 my $Selector = $self->{ 'selector' };
170 10 ▶ if ( !$Selector ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $Selector) { } 3 7 10
elsif ($Selector =~ /^v=BIMI1;\s+s=(\w+);?/iu) { } 7 0 7
171 3 $Selector = 'default';
172 }
173 elsif ( $Selector =~ m/^v=BIMI1;\s+s=(\w+);?/i ) {
174 7 $Selector = $1;
175 7 $Selector = lc $Selector;
176 # Was the BIMI-Selector header DKIM Signed?
177 7 my $selector_was_domain_signed = 0;
178 7 my $selector_was_org_domain_signed = 0;
179 7 my $selector_was_third_party_domain_signed = 0;
180 7 my $OrgDomain = eval{ $self->get_handler('DMARC')->get_dmarc_object()->get_organizational_domain( $Domain ) };
181 7 $self->handle_exception( $@ );
182 7 ▶ if ( $self->{'selector'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"selector"}) 7 0 7
183 7 my $dkim_handler = $self->get_handler('DKIM');
184 7 ▶ if ( $dkim_handler->{'has_dkim'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dkim_handler->{"has_dkim"}) 4 3 7
185 4 my $dkim_object = $self->get_object('dkim');
186 4 ▶ if ( $dkim_object ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dkim_object) 4 0 4
187 4 ▶ if ( $dkim_object->signatures() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dkim_object->signatures) 4 0 4
188 4 foreach my $signature ( $dkim_object->signatures() ) {
189 4 ▶ next if $signature->result ne 'pass';
Branch: 1 branch
BranchTrueFalseTotal
if $signature->result ne "pass" 0 4 4
190 4 my @signed_headers = $signature->headerlist;
191 4 ▶ next if ! grep { lc $_ eq 'bimi-selector' } @signed_headers;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {lc $_ eq "bimi-selector";} @signed_headers 1 3 4
192 3 my $signature_domain = $signature->domain;
193 3 ▶ if ( lc $signature_domain eq lc $Domain ) {
Branch: 2 branches
BranchTrueFalseTotal
if (lc $signature_domain eq lc $Domain) { } 1 2 3
elsif (lc $signature_domain eq lc $OrgDomain) { } 1 1 2
194 1 $selector_was_domain_signed = 1;
195 }
196 elsif ( lc $signature_domain eq lc $OrgDomain ) {
197 1 $selector_was_org_domain_signed = 1;
198 }
199 else {
200 1 $selector_was_third_party_domain_signed = 1;
201 }
202 }
203 }
204 }
205 }
206 }
207 7 ▶ my $Alignment = $selector_was_domain_signed ? 'domain'
Branch: 4 branches
BranchTrueFalseTotal
$selector_was_domain_signed ? : 1 6 7
$selector_was_org_domain_signed ? : 1 5 6
$selector_arc_pass ? : 1 4 5
$selector_was_third_party_domain_signed ? : 1 3 4
208 : $selector_was_org_domain_signed ? 'orgdomain'
209 : $selector_arc_pass ? 'arc'
210 : $selector_was_third_party_domain_signed ? 'thirdparty'
211 : 'unsigned';
212 7 ▶ if ( $Alignment eq 'unsigned' || $Alignment eq 'thirdparty' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Alignment eq "unsigned" or $Alignment eq "thirdparty") 4 3 7
Condition100%3/3
$Alignment eq "unsigned" or $Alignment eq "thirdparty"
l!l&&r!l&&!r
313
MC/DC100%2/2
$Alignment eq "unsigned" or $Alignment eq "thirdparty"
$Alignment eq "unsigned" $Alignment eq "thirdparty"
Truth table100%3/3
A or B
A= $Alignment eq "unsigned"B= $Alignment eq "thirdparty"
ABresult
1X1
011
000
213 4 $self->log_error( 'BIMI Header DKIM '.$Alignment.' for Selector '.$Selector.' - ignoring' );
214 4 $Selector = 'default';
215 }
216  
217 }
218 else {
219 0 $self->log_error( 'BIMI Invalid Selector Header: ' . $Selector );
220 0 $Selector = 'default';
221 }
222  
223 10 my $RelevantSPFResult;
224 10 my $SPFResults = $self->get_object( 'spf_results' );
225 10 ▶ if ( $SPFResults ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($SPFResults) 10 0 10
226 10 foreach my $SPFResult ( $SPFResults->@* ) {
227 10 ▶ next if lc $SPFResult->request->domain ne $Domain;
Branch: 1 branch
BranchTrueFalseTotal
if lc $SPFResult->request->domain ne $Domain 3 7 10
228 7 $RelevantSPFResult = $SPFResult;
229 }
230 }
231  
232 10 my $Skip;
233 10 ▶ if ( $config->{rbl_allowlist} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($config->{'rbl_allowlist'}) { } 0 10 10
elsif ($config->{'rbl_blocklist'}) { } 0 10 10
234 0 my $OrgDomain = $self->get_object('dmarc')->get_organizational_domain($Domain);
235 0 ▶ unless ( $self->rbl_check_domain( $OrgDomain, $config->{'rbl_allowlist'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->rbl_check_domain($OrgDomain, $config->{"rbl_allowlist"})) 0 0 0
236 0 $self->dbgout( 'BIMISkip', 'Not on allowlist', LOG_DEBUG );
237 0 $Skip = 'Local policy; not allowed';
238 }
239 }
240 elsif ( $config->{rbl_blocklist} ) {
241 0 my $OrgDomain = $self->get_object('dmarc')->get_organizational_domain($Domain);
242 0 ▶ if ( $self->rbl_check_domain( $OrgDomain, $config->{'rbl_blocklist'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->rbl_check_domain($OrgDomain, $config->{"rbl_blocklist"})) 0 0 0
243 0 $self->dbgout( 'BIMISkip', 'On blocklist', LOG_DEBUG );
244 0 $Skip = 'Local policy; blocked';
245 }
246 }
247  
248 10 my %Options;
249 10 ▶ $Options{options} = $config->{'bimi_options'} if exists $config->{'bimi_options'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $config->{"bimi_options"} 0 10 10
250 10 $Options{resolver} = $self->get_object( 'resolver' );
251 10 $Options{dmarc_object} = $self->get_object('dmarc');
252 10 ▶ $Options{spf_object} = $RelevantSPFResult if $RelevantSPFResult;
Branch: 1 branch
BranchTrueFalseTotal
if $RelevantSPFResult 7 3 10
253 10 $Options{domain} = $Domain;
254 10 $Options{selector} = $Selector;
255 10 my $BIMI = Mail::BIMI->new(%Options);
256 10 $self->{'bimi_object'} = $BIMI; # For testing!
257  
258 10 my $Result;
259 10 ▶ my $timeout = $config->{'timeout'} // 5000000;
Condition50%1/2
$config->{"timeout"} // 5000000
l!l
010
MC/DC0%0/1
$config->{"timeout"} // 5000000
$config->{"timeout"}
Truth table50%1/2
A
A= $config->{"timeout"}
Aresult
11
00
260 10 eval {
261 10 $self->set_handler_alarm( $timeout );
262 10 ▶ $Result = $BIMI->result() if ! $Skip;
Branch: 1 branch
BranchTrueFalseTotal
unless $Skip 10 0 10
263 };
264 10 ▶ if ( my $Error = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $Error = $@) 0 10 10
265 0 $self->reset_alarm();
266 0 my $Type = $self->is_exception_type( $Error );
267 0 ▶ if ( $Type ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Type) 0 0 0
268 0 ▶ if ( $Type eq 'Timeout' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Type eq "Timeout") 0 0 0
269 # We have a timeout, is it global or is it ours?
270 0 ▶ if ( $self->get_time_remaining() > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_time_remaining > 0) { } 0 0 0
271 # We have time left, but this operation save timed out
272 0 $Skip = 'Timeout';
273 }
274 else {
275 0 $self->handle_exception( $Error );
276 }
277 }
278 }
279 }
280  
281 10 ▶ if ( !$Skip
Branch: 1 branch
BranchTrueFalseTotal
if (not $Skip and $config->{"rbl_no_evidence_allowlist"} and $Result->result eq "pass" and not $BIMI->record->authority && $BIMI->record->authority->vmc && $BIMI->record->authority->vmc->is_valid) 0 10 10
Condition20%3/15
not $Skip and $config->{"rbl_no_evidence_allowlist"} and $Result->result eq "pass" and not $BIMI->record->authority && $BIMI->record->authority->vmc && $BIMI->record->authority->vmc->is_valid
!ll&&!rl&&r
1000
not $Skip and $config->{"rbl_no_evidence_allowlist"} and $Result->result eq "pass"
!ll&&!rl&&r
1000
not $Skip and $config->{"rbl_no_evidence_allowlist"}
!ll&&!rl&&r
0100
$BIMI->record->authority && $BIMI->record->authority->vmc && $BIMI->record->authority->vmc->is_valid
!ll&&!rl&&r
000
$BIMI->record->authority and $BIMI->record->authority->vmc
!ll&&!rl&&r
000
MC/DC0%0/6
not $Skip and $config->{"rbl_no_evidence_allowlist"} and $Result->result eq "pass" and not $BIMI->record->authority && $BIMI->record->authority->vmc && $BIMI->record->authority->vmc->is_valid
not $Skip $config->{"rbl_no_evidence_allowlist"} $Result->result eq "pass" $BIMI->record->authority $BIMI->record->authority->vmc $BIMI->record->authority->vmc->is_valid
Truth table14%1/7
not(A) and B and C and not(D and E && F)
A= not $SkipB= $config->{"rbl_no_evidence_allowlist"}C= $Result->result eq "pass"D= $BIMI->record->authorityE= $BIMI->record->authority->vmcF= $BIMI->record->authority->vmc->is_valid
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1111110
1110XX1
11110X1
1111101
282 && $config->{rbl_no_evidence_allowlist}
283 && $Result->result eq 'pass'
284 && (
285 !$BIMI->record->authority
286 || !$BIMI->record->authority->vmc
287 || !$BIMI->record->authority->vmc->is_valid
288 )
289 ) {
290 0 my $OrgDomain = $self->get_object('dmarc')->get_organizational_domain($Domain);
291 0 ▶ unless ( $self->rbl_check_domain( $OrgDomain, $config->{'rbl_no_evidence_allowlist'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->rbl_check_domain($OrgDomain, $config->{"rbl_no_evidence_allowlist"})) 0 0 0
292 0 $self->dbgout( 'BIMISkip', 'Not on No Evidence Allowlist', LOG_DEBUG );
293 0 $Skip = 'Local policy; not allowed without evidence';
294 }
295 }
296  
297  
298 10 ▶ if ( $Skip ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Skip) { } 0 10 10
299 0 my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'bimi' )->safe_set_value( 'skipped' );
300 0 $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( $Skip ) );
301 0 $self->add_auth_header( $header );
302 0 $self->{ 'header_added' } = 1;
303 0 $self->metric_count( 'bimi_total', { 'result' => 'skipped', 'reason' => 'rbl' } );
304 }
305 else {
306 10 my $AuthResults = $Result->get_authentication_results_object();
307 10 $self->add_auth_header( $AuthResults );
308 10 $self->{ 'header_added' } = 1;
309 10 my $Record = $BIMI->record();
310 10 my $is_experimental = 'none';
311 10 my $mark_type = 'none';
312 10 ▶ if ( $Result->result() eq 'pass' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Result->result eq "pass") 8 2 10
313 8 my $Headers = $Result->headers;
314 8 ▶ if ( $Headers ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Headers) 8 0 8
315 8 ▶ $self->prepend_header( 'BIMI-Location', $Headers->{'BIMI-Location'} ) if exists $Headers->{'BIMI-Location'} ;
Branch: 1 branch
BranchTrueFalseTotal
if exists $Headers->{"BIMI-Location"} 8 0 8
316 8 ▶ $self->prepend_header( 'BIMI-Indicator', $Headers->{'BIMI-Indicator'} ) if exists $Headers->{'BIMI-Indicator'} ;
Branch: 1 branch
BranchTrueFalseTotal
if exists $Headers->{"BIMI-Indicator"} 8 0 8
317 }
318 8 ▶ $is_experimental = eval{ $AuthResults->search({ 'isa' => 'subentry', 'key' => 'policy.experimental' })->children()->[0]->value() } // 'no';
Condition50%1/2
eval { do { $AuthResults->search({"isa", "subentry", "key", "policy.experimental"})->children->[0]->value } } // "no"
l!l
08
MC/DC0%0/1
eval { do { $AuthResults->search({"isa", "subentry", "key", "policy.experimental"})->children->[0]->value } } // "no"
eval { do { $AuthResults->search({"isa", "subentry", "key", "policy.experimental"})->children->[0]->value } }
Truth table50%1/2
A
A= eval { do { $AuthResults->search({"isa", "subentry", "key", "policy.experimental"})->children->[0]->value } }
Aresult
11
00
319 8 $self->handle_exception($@);
320 8 ▶ $mark_type = eval{ $AuthResults->search({ 'isa' => 'subentry', 'key' => 'policy.mark-type' })->children()->[0]->value() } // 'unknown';
Condition50%1/2
eval { do { $AuthResults->search({"isa", "subentry", "key", "policy.mark-type"})->children->[0]->value } } // "unknown"
l!l
08
MC/DC0%0/1
eval { do { $AuthResults->search({"isa", "subentry", "key", "policy.mark-type"})->children->[0]->value } } // "unknown"
eval { do { $AuthResults->search({"isa", "subentry", "key", "policy.mark-type"})->children->[0]->value } }
Truth table50%1/2
A
A= eval { do { $AuthResults->search({"isa", "subentry", "key", "policy.mark-type"})->children->[0]->value } }
Aresult
11
00
321 8 $self->handle_exception($@);
322 }
323 10 $self->metric_count( 'bimi_total', { 'result' => $Result->result(), 'is_experimental' => $is_experimental, 'mark_type' => $mark_type } );
324 }
325 10 $BIMI->finish;
326 }
327 }
328  
329 };
330 10 ▶ if ( my $error = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = $@) 0 10 10
331 0 $self->handle_exception( $error );
332 0 $self->log_error( 'BIMI Error ' . $error );
333 0 ▶ if ( ! $self->{ 'header_added' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"header_added"}) 0 0 0
334 0 my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'bimi' )->safe_set_value( 'temperror' );
335 0 $self->add_auth_header( $header );
336 0 $self->{ 'header_added' } = 1;
337 }
338 }
339 }
340  
341 0 ▶sub close_callback {
Subroutine close_callback: not called CC=1 SCAR=6.9
Pod undocumented
342 0 my ( $self ) = @_;
343 0 delete $self->{'selector'};
344 0 delete $self->{'from_header'};
345 0 delete $self->{'failmode'};
346 0 delete $self->{'bimi_object'};
347 0 delete $self->{'header_added'};
348 }
349  
350 2 1;
351  
352 __END__
↑ Summary Authentication/Handler/ReturnOK.pm »