line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::BIMI::App::Command::checkrecord; |
2
|
|
|
|
|
|
|
# ABSTRACT: Validate a given BIMI assertion record |
3
|
|
|
|
|
|
|
our $VERSION = '3.20210225'; # VERSION |
4
|
2
|
|
|
2
|
|
2263
|
use 5.20.0; |
|
2
|
|
|
|
|
9
|
|
5
|
2
|
|
|
2
|
|
64
|
BEGIN { $ENV{MAIL_BIMI_CACHE_DEFAULT_BACKEND} = 'Null' }; |
6
|
2
|
|
|
2
|
|
14
|
use Mail::BIMI::Prelude; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
22
|
|
7
|
2
|
|
|
2
|
|
690
|
use Mail::BIMI::App -command; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
19
|
|
8
|
2
|
|
|
2
|
|
893
|
use Mail::BIMI; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
59
|
|
9
|
2
|
|
|
2
|
|
14
|
use Mail::BIMI::Indicator; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
10
|
2
|
|
|
2
|
|
12
|
use Mail::BIMI::Record; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
38
|
|
11
|
2
|
|
|
2
|
|
11
|
use Mail::DMARC; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
66
|
|
12
|
2
|
|
|
2
|
|
13
|
use Term::ANSIColor qw{ :constants }; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2124
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
1
|
762
|
sub description { 'Check a given BIMI assertion record' } |
16
|
7
|
|
|
7
|
1
|
84005
|
sub usage_desc { "%c checkrecord %o <RECORD>" } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub opt_spec { |
19
|
|
|
|
|
|
|
return ( |
20
|
7
|
|
|
7
|
1
|
76
|
[ 'profile=s', 'SVG Profile to validate against ('.join('|',@Mail::BIMI::Indicator::VALIDATOR_PROFILES).')' ], |
21
|
|
|
|
|
|
|
[ 'domain=s', 'Optional domain' ], |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
6
|
|
|
6
|
1
|
5435
|
sub validate_args($self,$opt,$args) { |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
13
|
|
26
|
6
|
100
|
|
|
|
36
|
$self->usage_error('No Record specified') if !@$args; |
27
|
5
|
100
|
|
|
|
28
|
$self->usage_error('Multiple Records specified') if scalar @$args > 1; |
28
|
4
|
100
|
100
|
|
|
18
|
$self->usage_error('Unknown SVG Profile') if $opt->profile && !grep {;$_ eq $opt->profile} @Mail::BIMI::Indicator::VALIDATOR_PROFILES; |
|
9
|
|
|
|
|
63
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
3
|
1
|
41
|
sub execute($self,$opt,$args) { |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
5
|
|
32
|
3
|
|
|
|
|
9
|
my $check_record = $args->[0]; |
33
|
3
|
|
50
|
|
|
12
|
my $domain = $opt->domain // '-none-'; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
54
|
my $dmarc = Mail::DMARC::PurePerl->new; |
36
|
3
|
|
50
|
|
|
62
|
$dmarc->header_from($opt->domain // 'reject.test.fastmaildmarc.com'); |
37
|
3
|
|
|
|
|
1307
|
$dmarc->validate; |
38
|
3
|
|
|
|
|
671479
|
$dmarc->result->result('pass'); |
39
|
3
|
50
|
|
|
|
123
|
my $bimi = Mail::BIMI->new( |
|
|
100
|
|
|
|
|
|
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
|
3
|
|
|
|
|
2296
|
my $record = $bimi->record; |
50
|
|
|
|
|
|
|
# my $record = Mail::BIMI::Record->new( domain => $domain, selector => $selector ); |
51
|
3
|
|
|
|
|
29
|
say "BIMI domain checker"; |
52
|
3
|
|
|
|
|
84
|
say ''; |
53
|
3
|
|
|
|
|
43
|
say 'Requested:'; |
54
|
3
|
|
|
|
|
102
|
say YELLOW.' Domain '.WHITE.': '.CYAN.$domain.RESET; |
55
|
3
|
|
|
|
|
347
|
say YELLOW.' Record '.WHITE.': '.CYAN.$check_record.RESET; |
56
|
3
|
|
|
|
|
238
|
say ''; |
57
|
3
|
|
|
|
|
59
|
$record->app_validate; |
58
|
3
|
50
|
33
|
|
|
339
|
if ( $record->location && $record->location->indicator ) { |
59
|
0
|
|
|
|
|
0
|
say ''; |
60
|
0
|
|
|
|
|
0
|
$record->location->indicator->app_validate; |
61
|
|
|
|
|
|
|
} |
62
|
3
|
50
|
33
|
|
|
80
|
if ( $record->authority && $record->authority->vmc ) { |
63
|
0
|
|
|
|
|
0
|
say ''; |
64
|
0
|
|
|
|
|
0
|
$record->authority->vmc->app_validate; |
65
|
0
|
0
|
|
|
|
0
|
if ( $record->authority->vmc->indicator ) { |
66
|
0
|
|
|
|
|
0
|
say ''; |
67
|
0
|
|
|
|
|
0
|
$record->authority->vmc->indicator->app_validate; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
3
|
|
|
|
|
14
|
say ''; |
71
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
53
|
say 'An authenticated email with this record would receive the following BIMI results:'; |
73
|
3
|
|
|
|
|
49
|
say ''; |
74
|
3
|
|
|
|
|
119
|
my $result = $bimi->result; |
75
|
3
|
|
|
|
|
15
|
say "Authentication-Results: authservid.example.com; ".$result->get_authentication_results; |
76
|
3
|
|
|
|
|
1747
|
my $headers = $result->headers; |
77
|
3
|
|
|
|
|
17
|
foreach my $header ( sort keys $headers->%* ) { |
78
|
0
|
|
|
|
|
0
|
say "$header: ".$headers->{$header}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
3
|
|
|
|
|
216
|
$bimi->finish; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding UTF-8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Mail::BIMI::App::Command::checkrecord - Validate a given BIMI assertion record |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 3.20210225 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
App::Cmd class implementing the 'mailbimi checkdomain' command |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 REQUIRES |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=over 4 |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * L<Mail::BIMI|Mail::BIMI> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * L<Mail::BIMI::App|Mail::BIMI::App> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Indicator|Mail::BIMI::Indicator> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Record|Mail::BIMI::Record> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * L<Mail::DMARC|Mail::DMARC> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * L<Term::ANSIColor|Term::ANSIColor> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Marc Bradshaw <marc@marcbradshaw.net> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Marc Bradshaw. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
133
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |