BIMI/App/Command/checkrecord.pm

filter: Statementstmt 39.3% 26 / 66 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 64.2% 9 / 14 Podpod 100% 5 / 5 totaltotal 32.7% 40 / 122 CC 15 SCAR 40.6
CC
15
Cov
27%
execute
132.0
validate_args
30.0
description
2.0
CRAP 57.8
« BIMI/Indicator.pm ↑ Summary BIMI/App/Command/svgfromvmc.pm »
1 package Mail::BIMI::App::Command::checkrecord;
2 # ABSTRACT: Validate a given BIMI assertion record
3 1 our $VERSION = '3.20261116'; # VERSION
4 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶BEGIN { $ENV{MAIL_BIMI_CACHE_DEFAULT_BACKEND} = 'Null' };
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Mail::BIMI::Prelude;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Mail::BIMI::App -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Mail::BIMI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Mail::BIMI::Indicator;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Mail::BIMI::Record;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Mail::DMARC;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Term::ANSIColor qw{ :constants };
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 0 ▶sub description { 'Check a given BIMI assertion record' }
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
16 0 ▶sub usage_desc { "%c checkrecord %o <RECORD>" }
Subroutine usage_desc: not called CC=1 SCAR=6.9
Pod documented
17  
18 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
19 return (
20 0 [ 'profile=s', 'SVG Profile to validate against ('.join('|',@Mail::BIMI::Indicator::VALIDATOR_PROFILES).')' ],
21 [ 'domain=s', 'Optional domain' ],
22 );
23 }
24  
25 0 ▶sub validate_args($self,$opt,$args) {
Subroutine validate_args: not called CC=5 SCAR=34.0
Pod documented
26 0 ▶ $self->usage_error('No Record specified') if !@$args;
Branch: 1 branch
BranchTrueFalseTotal
unless @$args 0 0 0
27 0 ▶ $self->usage_error('Multiple Records specified') if scalar @$args > 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$args > 1 0 0 0
28 0 ▶ $self->usage_error('Unknown SVG Profile') if $opt->profile && !grep {;$_ eq $opt->profile} @Mail::BIMI::Indicator::VALIDATOR_PROFILES;
Branch: 1 branch
BranchTrueFalseTotal
if $opt->profile and not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES) 0 0 0
Condition0%0/3
$opt->profile and not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
!ll&&!rl&&r
000
MC/DC0%0/2
$opt->profile and not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
$opt->profile not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
Truth table0%0/3
A and not(B)
A= $opt->profileB= not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
ABresult
0X0
100
111
29 }
30  
31 0 ▶sub execute($self,$opt,$args) {
Subroutine execute: not called CC=11 SCAR=48.8
Pod documented
32 0 my $check_record = $args->[0];
33 0 ▶ my $domain = $opt->domain // '-none-';
Condition0%0/2
$opt->domain // "-none-"
l!l
00
MC/DC0%0/1
$opt->domain // "-none-"
$opt->domain
Truth table0%0/2
A
A= $opt->domain
Aresult
11
00
34  
35 0 my $dmarc = Mail::DMARC::PurePerl->new;
36 0 ▶ $dmarc->header_from($opt->domain // 'reject.test.fastmaildmarc.com');
Condition0%0/2
$opt->domain // "reject.test.fastmaildmarc.com"
l!l
00
MC/DC0%0/1
$opt->domain // "reject.test.fastmaildmarc.com"
$opt->domain
Truth table0%0/2
A
A= $opt->domain
Aresult
11
00
37 0 $dmarc->validate;
38 0 $dmarc->result->result('pass');
39 0 ▶ my $bimi = Mail::BIMI->new(
Branch: 2 branches
BranchTrueFalseTotal
$opt->domain ? : 0 0 0
$opt->profile ? : 0 0 0
40 dmarc_object => $dmarc,
41 domain => $domain,
42 options => {
43 force_record => $check_record,
44 vmc_no_check_alt => $opt->domain ? 0 : 1,
45 ( $opt->profile ? ( svg_profile => $opt->profile ) : () ),
46 }
47 );
48  
49 0 my $record = $bimi->record;
50 # my $record = Mail::BIMI::Record->new( domain => $domain, selector => $selector );
51 0 say "BIMI domain checker";
52 0 say '';
53 0 say 'Requested:';
54 0 say YELLOW.' Domain '.WHITE.': '.CYAN.$domain.RESET;
55 0 say YELLOW.' Record '.WHITE.': '.CYAN.$check_record.RESET;
56 0 say '';
57 0 $record->app_validate;
58 0 ▶ if ( $record->location && $record->location->indicator ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->location and $record->location->indicator) 0 0 0
Condition0%0/3
$record->location and $record->location->indicator
!ll&&!rl&&r
000
MC/DC0%0/2
$record->location and $record->location->indicator
$record->location $record->location->indicator
Truth table0%0/3
A and B
A= $record->locationB= $record->location->indicator
ABresult
0X0
100
111
59 0 say '';
60 0 $record->location->indicator->app_validate;
61 }
62 0 ▶ if ( $record->authority && $record->authority->vmc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->authority and $record->authority->vmc) 0 0 0
Condition0%0/3
$record->authority and $record->authority->vmc
!ll&&!rl&&r
000
MC/DC0%0/2
$record->authority and $record->authority->vmc
$record->authority $record->authority->vmc
Truth table0%0/3
A and B
A= $record->authorityB= $record->authority->vmc
ABresult
0X0
100
111
63 0 say '';
64 0 $record->authority->vmc->app_validate;
65 0 ▶ if ( $record->authority->vmc->indicator ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->authority->vmc->indicator) 0 0 0
66 0 say '';
67 0 $record->authority->vmc->indicator->app_validate;
68 }
69 }
70 0 say '';
71  
72 0 say 'An authenticated email with this record would receive the following BIMI results:';
73 0 say '';
74 0 my $result = $bimi->result;
75 0 say "Authentication-Results: authservid.example.com; ".$result->get_authentication_results;
76 0 my $headers = $result->headers;
77 0 foreach my $header ( sort keys $headers->%* ) {
78 0 say "$header: ".$headers->{$header};
79 }
80  
81 0 $bimi->finish;
82 }
83  
84 1 1;
85  
86 __END__
« BIMI/Indicator.pm ↑ Summary BIMI/App/Command/svgfromvmc.pm »