| 1 | package Mail::BIMI::App::Command::checkvmc; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Check an VMC for validation | ||||||||||||||||||||||||||||
| 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::VMC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Term::ANSIColor qw{ :constants }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub description { 'Check a VMC from a given URI or File for validity' } | ||||||||||||||||||||||||||
|
Subroutine
description: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub usage_desc { "%c checksvg %o <URI>" } | ||||||||||||||||||||||||||
|
Subroutine
usage_desc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | return ( | ||||||||||||||||||||||||||||
| 19 | 0 | [ 'profile=s', 'SVG Profile to validate against ('.join('|',@Mail::BIMI::Indicator::VALIDATOR_PROFILES).')' ], | |||||||||||||||||||||||||||
| 20 | [ 'domain=s', 'Domain' ], | ||||||||||||||||||||||||||||
| 21 | [ 'selector=s', 'Selector' ], | ||||||||||||||||||||||||||||
| 22 | [ 'fromfile', 'Fetch from file instead of from URI' ], | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub validate_args($self,$opt,$args) { | ||||||||||||||||||||||||||
|
Subroutine
validate_args: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $self->usage_error('No URI specified') if !@$args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $self->usage_error('Multiple URIs specified') if scalar @$args > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $self->usage_error('Unknown SVG Profile') if $opt->profile && !grep {;$_ eq $opt->profile} @Mail::BIMI::Indicator::VALIDATOR_PROFILES; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt->profile and not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
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)
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $self->usage_error('Selector requires domain') if $opt->selector && !$opt->domain; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt->selector and not $opt->domain
MC/DC0%0/2
$opt->selector and not $opt->domain
$opt->selector
not $opt->domain
Truth table0%0/3
A and not(B)
A= $opt->selectorB= not $opt->domain
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub execute($self,$opt,$args) { | ||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 0 | my $uri = $args->[0]; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | my %bimi_opt; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ( $opt->domain ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | $bimi_opt{domain} = $opt->domain; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||
| 41 | 0 | $bimi_opt{domain} = 'example.com'; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 0 | $bimi_opt{options} = {}; | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | $bimi_opt{options}->{vmc_no_check_alt} = 1 if !$opt->domain; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $bimi_opt{options}->{vmc_from_file} = $uri if $opt->fromfile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | my $bimi = Mail::BIMI->new(%bimi_opt); | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $vmc = Mail::BIMI::VMC->new( check_domain => $opt->domain//'', check_selector => $opt->selector//'default', uri => $uri, bimi_object => $bimi ); | ||||||||||||||||||||||||||
|
Condition0%0/4
$opt->domain // ""
$opt->selector // "default"
MC/DC0%0/1
$opt->domain // ""
$opt->domain
MC/DC0%0/1
$opt->selector // "default"
$opt->selector
Truth table0%0/2
A
A= $opt->domain
Truth table0%0/2
A
A= $opt->selector
| |||||||||||||||||||||||||||||
| 50 | # $indicator->validator_profile($opt->profile) if $opt->profile; | ||||||||||||||||||||||||||||
| 51 | 0 | say "BIMI VMC checker"; | |||||||||||||||||||||||||||
| 52 | 0 | say ''; | |||||||||||||||||||||||||||
| 53 | 0 | say 'Requested:'; | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | say YELLOW.($opt->fromfile?'File':'URI').WHITE.': '.$uri.RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | say ''; | |||||||||||||||||||||||||||
| 56 | 0 | $vmc->app_validate; | |||||||||||||||||||||||||||
| 57 | 0 | say ''; | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ( $vmc->indicator ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | $vmc->indicator->app_validate; | |||||||||||||||||||||||||||
| 60 | 0 | say ''; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | $bimi->finish; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | 1; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||