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