| 1 | package Mail::BIMI::VMC; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Class to model a VMC | ||||||||||||||||||||||||||||
| 3 | 29 | our $VERSION = '3.20260302'; # VERSION | |||||||||||||||||||||||||||
| 4 | 30 | ▶ | use 5.20.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 30 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 30 | ▶ | use Mail::BIMI::Prelude; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 30 | ▶ | use File::Slurp qw{ read_file write_file }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 30 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 30 | ▶ | use Term::ANSIColor qw{ :constants }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 30 | ▶ | use Mail::BIMI::Indicator; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 29 | ▶ | use Mail::BIMI::VMC::Chain; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 29 | extends 'Mail::BIMI::Base'; | |||||||||||||||||||||||||||
| 14 | 29 | with( | |||||||||||||||||||||||||||
| 15 | 'Mail::BIMI::Role::HasError', | ||||||||||||||||||||||||||||
| 16 | 'Mail::BIMI::Role::HasHTTPClient', | ||||||||||||||||||||||||||||
| 17 | 'Mail::BIMI::Role::Cacheable', | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | 29 | has uri => ( is => 'rw', isa => 'Str', traits => ['CacheKey'], | |||||||||||||||||||||||||||
| 20 | documentation => 'inputs: URI of this VMC', ); | ||||||||||||||||||||||||||||
| 21 | 29 | has check_domain => ( is => 'ro', isa => 'Str', required => 1, traits => ['CacheKey'], | |||||||||||||||||||||||||||
| 22 | documentation => 'inputs: Domain to check the alt_name against', ); | ||||||||||||||||||||||||||||
| 23 | 29 | has check_selector => ( is => 'ro', isa => 'Str', required => 1, traits => ['CacheKey'], | |||||||||||||||||||||||||||
| 24 | documentation => 'inputs: Selector to check the alt_name against', ); | ||||||||||||||||||||||||||||
| 25 | 29 | has data => ( is => 'rw', isa => 'Str', lazy => 1, builder => '_build_data', traits => ['Cacheable'], | |||||||||||||||||||||||||||
| 26 | documentation => 'inputs: Raw data of the VMC contents; Fetched from authority URI if not given', ); | ||||||||||||||||||||||||||||
| 27 | 29 | has cert_list => ( is => 'rw', isa => 'ArrayRef', lazy => 1, builder => '_build_cert_list', traits => ['Cacheable'], | |||||||||||||||||||||||||||
| 28 | documentation => 'ArrayRef of individual Certificates in the chain' ); | ||||||||||||||||||||||||||||
| 29 | 29 | has chain_object => ( is => 'rw', lazy => 1, builder => '_build_chain_object', | |||||||||||||||||||||||||||
| 30 | documentation => 'Mail::BIMI::VMC::Chain object for this Chain' ); | ||||||||||||||||||||||||||||
| 31 | 29 | has is_valid => ( is => 'rw', lazy => 1, builder => '_build_is_valid', traits => ['Cacheable'], | |||||||||||||||||||||||||||
| 32 | documentation => 'Is this VMC valid' ); | ||||||||||||||||||||||||||||
| 33 | 29 | has vmc_object => ( is => 'rw', lazy => 1, builder => '_build_vmc_object', | |||||||||||||||||||||||||||
| 34 | documentation => 'Mail::BIMI::VMC::Cert object for this VMC Set' ); | ||||||||||||||||||||||||||||
| 35 | 29 | has is_cert_valid => ( is => 'rw', lazy => 1, builder => '_build_is_cert_valid', traits => ['Cacheable'], | |||||||||||||||||||||||||||
| 36 | documentation => 'Is this Certificate Set valid' ); | ||||||||||||||||||||||||||||
| 37 | 29 | has indicator_uri => ( is => 'rw', lazy => 1, builder => '_build_indicator_uri', traits => ['Cacheable'], | |||||||||||||||||||||||||||
| 38 | documentation => 'The URI of the embedded Indicator' ); | ||||||||||||||||||||||||||||
| 39 | 29 | has indicator => ( is => 'rw', lazy => 1, builder => '_build_indicator', | |||||||||||||||||||||||||||
| 40 | documentation => 'Mail::BIMI::Indicator object for the Indicator embedded in this VMC Set' ); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub cache_valid_for($self) { return 3600 } | ||||||||||||||||||||||||||
|
Subroutine
cache_valid_for: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub http_client_max_fetch_size($self) { return $self->bimi_object->options->vmc_max_fetch_size }; | ||||||||||||||||||||||||||
|
Subroutine
http_client_max_fetch_size: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | ▶ | sub _build_data($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_data: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ( ! $self->uri ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | $self->add_error('CODE_MISSING_AUTHORITY'); | |||||||||||||||||||||||||||
| 52 | 0 | return ''; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ($self->bimi_object->options->vmc_from_file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | return scalar read_file $self->bimi_object->options->vmc_from_file; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | $self->log_verbose('HTTP Fetch: '.$self->uri); | |||||||||||||||||||||||||||
| 59 | 0 | my $response = $self->http_client_get( $self->uri ); | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ( !$response->{success} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( $response->{status} == 599 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | $self->add_error('VMC_FETCH_ERROR',$response->{content}); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||
| 65 | 0 | $self->add_error('VMC_FETCH_ERROR',$response->{status}); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | return ''; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 0 | return $response->{content}; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | ▶ | sub _build_cert_list($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_cert_list: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 73 | 0 | my @certs; | |||||||||||||||||||||||||||
| 74 | 0 | my $this_cert = []; | |||||||||||||||||||||||||||
| 75 | 0 | my $data = $self->data; | |||||||||||||||||||||||||||
| 76 | 0 | foreach my $cert_line ( split(/\n/,$data) ) { | |||||||||||||||||||||||||||
| 77 | 0 | $cert_line =~ s/\r//; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | next if ! $cert_line; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | push $this_cert->@*, $cert_line; | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( $cert_line =~ /^\-+END CERTIFICATE\-+$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | push @certs, $this_cert if $this_cert->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | $this_cert = []; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | push @certs, $this_cert if $this_cert->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | return \@certs; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | ▶ | sub _build_chain_object($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_chain_object: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 91 | 0 | return Mail::BIMI::VMC::Chain->new( bimi_object => $self->bimi_object, cert_list => $self->cert_list ); | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | ▶ | sub _build_vmc_object($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_vmc_object: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | return if !$self->chain_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | return if !$self->chain_object->vmc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | return $self->chain_object->vmc; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | ▶ | sub _build_is_cert_valid($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_is_cert_valid: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return 1 if $self->bimi_object->options->no_validate_cert; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | return $self->chain_object->is_valid; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | ▶ | sub subject($self) { | |||||||||||||||||||||||||||
|
Subroutine
subject: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 0 | return $self->vmc_object->x509_object->subject; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | ▶ | sub subject_entries($self, $subject) { | |||||||||||||||||||||||||||
|
Subroutine
subject_entries: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | 7 | my %result; | |||||||||||||||||||||||||||
| 116 | 7 | ▶ | return \%result unless defined $subject; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 7 | ▶ | while ($subject) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | # Messy regex ahead. | ||||||||||||||||||||||||||||
| 119 | # overall goal is to break apart a comma-separated list of key=value pairs, | ||||||||||||||||||||||||||||
| 120 | # where value can contain a comma, | ||||||||||||||||||||||||||||
| 121 | # The regex accepts a key (containing no commas or equals), (^,=)* | ||||||||||||||||||||||||||||
| 122 | # then an equals, then a value. This is a little tangled. To make it able to survive | ||||||||||||||||||||||||||||
| 123 | # an equals in a value, it is allowed any character (inc. =) till it reaches a comma. | ||||||||||||||||||||||||||||
| 124 | # once it gets to a comma, and equals would define a new section so we grab an equals, | ||||||||||||||||||||||||||||
| 125 | # as many non-comma characters as we can then all the non-equals characters: =([^,]*[^=]*?) | ||||||||||||||||||||||||||||
| 126 | # basically matching "key = value" - (note: *? to take the least characters possible) where | ||||||||||||||||||||||||||||
| 127 | # value is allowed = as long as there is no comma, and commas till the last one before an equals. | ||||||||||||||||||||||||||||
| 128 | # It then uses a look-ahead match to make sure that the next thing after the value | ||||||||||||||||||||||||||||
| 129 | # is a ", key=" sequence or the end of the string (?:$|,\s*(?=[^,]*?=)) | ||||||||||||||||||||||||||||
| 130 | # It does this by matching either the end of the string or comma then a set of | ||||||||||||||||||||||||||||
| 131 | # characters not including comma or equals which are then followed by an equals. | ||||||||||||||||||||||||||||
| 132 | # All the ?: are to avoid capturing unwanted segments. We capture key in $1 and | ||||||||||||||||||||||||||||
| 133 | # value in $2, and then use the uncaptured right side ($') to start the process | ||||||||||||||||||||||||||||
| 134 | # for the next key/value pair. | ||||||||||||||||||||||||||||
| 135 | 12 | $subject =~m/^(?:(?:(?:([^,=]*)=([^,]*[^=]*?))|) (?:$|,\s*(?=[^,]*?=)))/x; | |||||||||||||||||||||||||||
| 136 | 12 | ▶ | my $remainder = $' // ''; # $' is the uncaptured part of the source to the right of the match | ||||||||||||||||||||||||||
|
Condition100%2/2
$' // ""
MC/DC100%1/1
$' // ""
$'
Truth table100%2/2
A
A= $'
| |||||||||||||||||||||||||||||
| 137 | 12 | ▶ | last unless length($remainder) < length($subject); # if the remainder isn't getting shorter then bail | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 12 | $subject = $remainder; | |||||||||||||||||||||||||||
| 139 | 12 | my $key = $1; | |||||||||||||||||||||||||||
| 140 | 12 | my $value = $2; | |||||||||||||||||||||||||||
| 141 | 12 | ▶ | next unless $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 9 | ▶ | next unless $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 9 | ▶ | $result{$key} = [] unless exists $result{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 9 | push $result{$key}->@*, $value; | |||||||||||||||||||||||||||
| 145 | }; | ||||||||||||||||||||||||||||
| 146 | 7 | return \%result; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | ▶ | sub mark_type($self) { | |||||||||||||||||||||||||||
|
Subroutine
mark_type: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 151 | 0 | ▶ | return unless $self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | # Parse the subject:markType from the subject string | ||||||||||||||||||||||||||||
| 154 | # Ideally we could parse the structure, from this | ||||||||||||||||||||||||||||
| 155 | # my $subject_entries = $self->vmc_object->x509_object->subject_name->entries; | ||||||||||||||||||||||||||||
| 156 | # however the X509 object does not make this easy for a type that is not | ||||||||||||||||||||||||||||
| 157 | # compiled in, returning undef for an entry type it does not understand. | ||||||||||||||||||||||||||||
| 158 | # So we parse the string instead. | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | my $subject = $self->subject; | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | return unless $subject; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | my $subject_entries = $self->subject_entries($subject); | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | my $subject_mark_type_oid = SUBJECT_MARK_TYPE_OID; # can't use a constant as a hash key | |||||||||||||||||||||||||||
| 166 | 0 | ▶ | if (exists $subject_entries->{$subject_mark_type_oid}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | return $subject_entries->{$subject_mark_type_oid}->[0]; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if (exists $subject_entries->{'markType'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 0 | return $subject_entries->{'markType'}->[0]; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | 0 | return; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | ▶ | sub not_before($self) { | |||||||||||||||||||||||||||
|
Subroutine
not_before: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | return $self->vmc_object->x509_object->notBefore; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | ▶ | sub not_after($self) { | |||||||||||||||||||||||||||
|
Subroutine
not_after: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 0 | return $self->vmc_object->x509_object->notAfter; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | ▶ | sub issuer($self) { | |||||||||||||||||||||||||||
|
Subroutine
issuer: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | return $self->vmc_object->x509_object->issuer; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | ▶ | sub is_expired($self) { | |||||||||||||||||||||||||||
|
Subroutine
is_expired: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 0 | my $seconds = 0; | |||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ($self->vmc_object->x509_object->checkend($seconds)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | $self->log_verbose('Cert is expired'); | |||||||||||||||||||||||||||
| 199 | 0 | return 1; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||
| 202 | 0 | return 0; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | ▶ | sub alt_name($self) { | |||||||||||||||||||||||||||
|
Subroutine
alt_name: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 0 | my $exts = eval{ $self->vmc_object->x509_object->extensions_by_oid() }; | |||||||||||||||||||||||||||
| 210 | 0 | ▶ | return if !$exts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | return if !exists $exts->{'2.5.29.17'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 0 | my $alt_name = $exts->{'2.5.29.17'}->to_string; | |||||||||||||||||||||||||||
| 213 | 0 | $self->log_verbose('Cert alt name '.$alt_name); | |||||||||||||||||||||||||||
| 214 | 0 | return $alt_name; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | ▶ | sub is_valid_alt_name($self) { | |||||||||||||||||||||||||||
|
Subroutine
is_valid_alt_name: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 219 | 0 | ▶ | return 1 if !$self->check_domain; # Nothing to check against, default to allow | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | return 1 if $self->bimi_object->options->vmc_no_check_alt; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 0 | ▶ | return 0 if !$self->alt_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 0 | my @alt_names = split( ',', lc $self->alt_name ); | |||||||||||||||||||||||||||
| 223 | 0 | my $check_full_record = lc join('.', $self->check_selector, '_bimi', $self->check_domain ); | |||||||||||||||||||||||||||
| 224 | 0 | my $check_domain = lc $self->check_domain; | |||||||||||||||||||||||||||
| 225 | 0 | foreach my $alt_name ( @alt_names ) { | |||||||||||||||||||||||||||
| 226 | 0 | $alt_name =~ s/^\s+//; | |||||||||||||||||||||||||||
| 227 | 0 | $alt_name =~ s/\s+$//; | |||||||||||||||||||||||||||
| 228 | 0 | ▶ | next unless $alt_name =~ /^dns:/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 0 | $alt_name =~ s/^dns://; | |||||||||||||||||||||||||||
| 230 | 0 | ▶ | return 1 if $alt_name eq $check_domain; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return 1 if $alt_name eq $check_full_record; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | next if !$self->bimi_object->options->cert_subdomain_is_valid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 0 | my $alt_name_re = quotemeta($alt_name); | |||||||||||||||||||||||||||
| 234 | 0 | ▶ | return 1 if $check_domain =~ /\.$alt_name_re$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | 0 | return 0; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | ▶ | sub is_self_signed($self) { | |||||||||||||||||||||||||||
|
Subroutine
is_self_signed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 0 | ▶ | return $self->vmc_object->x509_object->is_selfsigned ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | ▶ | sub has_valid_usage($self) { | |||||||||||||||||||||||||||
|
Subroutine
has_valid_usage: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 247 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 0 | return $self->vmc_object->has_valid_usage; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | ▶ | sub is_experimental($self) { | |||||||||||||||||||||||||||
|
Subroutine
is_experimental: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 253 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 0 | return $self->vmc_object->is_experimental; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | ▶ | sub is_allowed_mark_type($self) { | |||||||||||||||||||||||||||
|
Subroutine
is_allowed_mark_type: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 259 | 0 | ▶ | my $mark_type = lc ($self->mark_type // ''); | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->mark_type // ""
MC/DC0%0/1
$self->mark_type // ""
$self->mark_type
Truth table0%0/2
A
A= $self->mark_type
| |||||||||||||||||||||||||||||
| 260 | 0 | my $allowed_mark_types = lc $self->bimi_object->options->allowed_mark_types; | |||||||||||||||||||||||||||
| 261 | 0 | for my $allowed_mark_type (split /, ?/, $allowed_mark_types) { | |||||||||||||||||||||||||||
| 262 | 0 | ▶ | return 1 if $allowed_mark_type eq '*'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | return 1 if $allowed_mark_type eq $mark_type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | 0 | return 0; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | ▶ | sub _build_indicator_uri($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_indicator_uri: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | return if !$self->vmc_object; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 0 | ▶ | return if !$self->vmc_object->indicator_asn; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 0 | my $uri; | |||||||||||||||||||||||||||
| 272 | eval{ | ||||||||||||||||||||||||||||
| 273 | 0 | $uri = $self->vmc_object->indicator_asn->{subjectLogo}->{direct}->{image}->[0]->{imageDetails}->{logotypeURI}->[0]; | |||||||||||||||||||||||||||
| 274 | 0 | 1; | |||||||||||||||||||||||||||
| 275 | 0 | ▶ | } || do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 0 | my $error = $@; | |||||||||||||||||||||||||||
| 277 | 0 | $self->add_error('VMC_PARSE_ERROR','Could not extract SVG from VMC'); | |||||||||||||||||||||||||||
| 278 | }; | ||||||||||||||||||||||||||||
| 279 | 0 | return $uri; | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | ▶ | sub _build_indicator($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_indicator: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 283 | # return if ! $self->_is_valid; | ||||||||||||||||||||||||||||
| 284 | 0 | ▶ | return if !$self->is_cert_valid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 0 | my $uri = $self->indicator_uri; | |||||||||||||||||||||||||||
| 286 | 0 | ▶ | return if !$uri; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | ## TODO MAKE THIS BETTER | ||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if ( $uri =~ /^data:image\/svg\+xml;base64,/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 0 | my ( $null, $base64 ) = split( ',', $uri ); | |||||||||||||||||||||||||||
| 290 | 0 | my $data = MIME::Base64::decode($base64); | |||||||||||||||||||||||||||
| 291 | 0 | return Mail::BIMI::Indicator->new( uri => $self->uri, data => $data, bimi_object => $self->bimi_object, source => 'VMC' ); | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | else { | ||||||||||||||||||||||||||||
| 294 | 0 | $self->add_error('VMC_PARSE_ERROR','Could not extract SVG from VMC'); | |||||||||||||||||||||||||||
| 295 | 0 | return; | |||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | ▶ | sub _build_is_valid($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_is_valid: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if ($self->data eq '' && $self->errors->@*) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->data eq "" and @{$self->errors}
MC/DC0%0/2
$self->data eq "" and @{$self->errors}
$self->data eq ""
@{$self->errors}
Truth table0%0/3
A and B
A= $self->data eq ""B= @{$self->errors}
| |||||||||||||||||||||||||||||
| 303 | # We already have a fetch error, do not validate further | ||||||||||||||||||||||||||||
| 304 | 0 | return 0; | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | ▶ | $self->add_error('VMC_EXPIRED','Expired') if $self->is_expired; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $self->add_error('VMC_VALIDATION_ERROR','Missing usage flag') if !$self->has_valid_usage; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | $self->add_error('VMC_VALIDATION_ERROR','Invalid alt name') if !$self->is_valid_alt_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | 0 | ▶ | $self->add_error('VMC_DISALLOWED_TYPE', 'VMC Mark Type not supported here' ) if !$self->is_allowed_mark_type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 0 | $self->is_cert_valid; | |||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if ( $self->chain_object && !$self->chain_object->is_valid ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->chain_object and not $self->chain_object->is_valid
MC/DC0%0/2
$self->chain_object and not $self->chain_object->is_valid
$self->chain_object
not $self->chain_object->is_valid
Truth table0%0/3
A and not(B)
A= $self->chain_objectB= not $self->chain_object->is_valid
| |||||||||||||||||||||||||||||
| 314 | 0 | $self->add_error_object( $self->chain_object->errors ); | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | ▶ | if ( $self->indicator && !$self->indicator->is_valid ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->indicator and not $self->indicator->is_valid
MC/DC0%0/2
$self->indicator and not $self->indicator->is_valid
$self->indicator
not $self->indicator->is_valid
Truth table0%0/3
A and not(B)
A= $self->indicatorB= not $self->indicator->is_valid
| |||||||||||||||||||||||||||||
| 318 | 0 | $self->add_error_object( $self->indicator->errors ); | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ( $self->bimi_object->options->no_experimental_vmc && $self->is_experimental ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->bimi_object->options->no_experimental_vmc and $self->is_experimental
MC/DC0%0/2
$self->bimi_object->options->no_experimental_vmc and $self->is_experimental
$self->bimi_object->options->no_experimental_vmc
$self->is_experimental
Truth table0%0/3
A and B
A= $self->bimi_object->options->no_experimental_vmcB= $self->is_experimental
| |||||||||||||||||||||||||||||
| 322 | 0 | $self->add_error('VMC_NO_EXPERIMENTAL','Experimental (V)MCs are not accepted here'); | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 0 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 326 | 0 | $self->log_verbose('VMC is valid'); | |||||||||||||||||||||||||||
| 327 | 0 | return 1; | |||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | ▶ | sub finish($self) { | |||||||||||||||||||||||||||
|
Subroutine
finish: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $self->indicator->finish if $self->indicator; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | 0 | $self->_write_cache; | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | ▶ | sub app_validate($self) { | |||||||||||||||||||||||||||
|
Subroutine
app_validate: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||
| 338 | 0 | ▶ | say 'VMC Returned: '.($self->is_valid ? GREEN."\x{2713}" : BRIGHT_RED."\x{26A0}").RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | ▶ | say YELLOW.' Subject '.WHITE.': '.CYAN.($self->subject//'-none-').RESET; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->subject // "-none-"
MC/DC0%0/1
$self->subject // "-none-"
$self->subject
Truth table0%0/2
A
A= $self->subject
| |||||||||||||||||||||||||||||
| 340 | 0 | ▶ | say YELLOW.' Mark Type '.WHITE.': '.CYAN.($self->mark_type//'-none-').RESET; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->mark_type // "-none-"
MC/DC0%0/1
$self->mark_type // "-none-"
$self->mark_type
Truth table0%0/2
A
A= $self->mark_type
| |||||||||||||||||||||||||||||
| 341 | 0 | ▶ | say YELLOW.' Is Allowed Type '.WHITE.': '.CYAN.($self->is_allowed_mark_type?GREEN.'Yes':BRIGHT_RED.'No').RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 342 | 0 | ▶ | say YELLOW.' Not Before '.WHITE.': '.CYAN.($self->not_before//'-none-').RESET; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->not_before // "-none-"
MC/DC0%0/1
$self->not_before // "-none-"
$self->not_before
Truth table0%0/2
A
A= $self->not_before
| |||||||||||||||||||||||||||||
| 343 | 0 | ▶ | say YELLOW.' Not After '.WHITE.': '.CYAN.($self->not_after//'-none-').RESET; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->not_after // "-none-"
MC/DC0%0/1
$self->not_after // "-none-"
$self->not_after
Truth table0%0/2
A
A= $self->not_after
| |||||||||||||||||||||||||||||
| 344 | 0 | ▶ | say YELLOW.' Issuer '.WHITE.': '.CYAN.($self->issuer//'-none-').RESET; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->issuer // "-none-"
MC/DC0%0/1
$self->issuer // "-none-"
$self->issuer
Truth table0%0/2
A
A= $self->issuer
| |||||||||||||||||||||||||||||
| 345 | 0 | ▶ | say YELLOW.' Expired '.WHITE.': '.($self->is_expired?BRIGHT_RED.'Yes':GREEN.'No').RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | 0 | ▶ | say YELLOW.' Alt Name '.WHITE.': '.CYAN.($self->alt_name//'-none-').RESET; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->alt_name // "-none-"
MC/DC0%0/1
$self->alt_name // "-none-"
$self->alt_name
Truth table0%0/2
A
A= $self->alt_name
| |||||||||||||||||||||||||||||
| 347 | 0 | ▶ | say YELLOW.' Alt Name Valid '.WHITE.': '.CYAN.($self->is_valid_alt_name?GREEN.'Yes':BRIGHT_RED.'No').RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | 0 | ▶ | say YELLOW.' Has Valid Usage '.WHITE.': '.CYAN.($self->has_valid_usage?GREEN.'Yes':BRIGHT_RED.'No').RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 349 | 0 | ▶ | say YELLOW.' Cert Valid '.WHITE.': '.CYAN.($self->is_cert_valid?GREEN.'Yes':BRIGHT_RED.'No').RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 350 | 0 | ▶ | say YELLOW.' Is Valid '.WHITE.': '.CYAN.($self->is_valid?GREEN.'Yes':BRIGHT_RED.'No').RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ( ! $self->is_valid ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 352 | 0 | say "Errors:"; | |||||||||||||||||||||||||||
| 353 | 0 | foreach my $error ( $self->errors->@* ) { | |||||||||||||||||||||||||||
| 354 | 0 | my $error_code = $error->code; | |||||||||||||||||||||||||||
| 355 | 0 | my $error_text = $error->description; | |||||||||||||||||||||||||||
| 356 | 0 | ▶ | my $error_detail = $error->detail // ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$error->detail // ""
MC/DC0%0/1
$error->detail // ""
$error->detail
Truth table0%0/2
A
A= $error->detail
| |||||||||||||||||||||||||||||
| 357 | 0 | $error_detail =~ s/\n/\n /g; | |||||||||||||||||||||||||||
| 358 | 0 | ▶ | say BRIGHT_RED." $error_code ".WHITE.': '.CYAN.$error_text.($error_detail?"\n ".$error_detail:'').RESET; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ($self->chain_object){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | 0 | say ''; | |||||||||||||||||||||||||||
| 363 | 0 | $self->chain_object->app_validate; | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 29 | 1; | |||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | __END__ | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | =pod | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | =head1 NAME | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | Mail::BIMI::VMC - Class to model a VMC | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | =head1 VERSION | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | version 3.20260302 | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | Class for representing, retrieving, validating, and processing a VMC Set | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | =head1 INPUTS | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | These values are used as inputs for lookups and verifications, they are typically set by the caller based on values found in the message being processed | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | =head2 check_domain | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | is=ro required | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | Domain to check the alt_name against | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | =head2 check_selector | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | is=ro required | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | Selector to check the alt_name against | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | =head2 data | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | is=rw | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | Raw data of the VMC contents; Fetched from authority URI if not given | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | =head2 uri | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | is=rw | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | URI of this VMC | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | These values are derived from lookups and verifications made based upon the input values, it is however possible to override these with other values should you wish to, for example, validate a record before it is published in DNS, or validate an Indicator which is only available locally | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | =head2 cache_backend | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | is=ro | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | =head2 cert_list | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | is=rw | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | ArrayRef of individual Certificates in the chain | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | =head2 chain_object | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | is=rw | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | Mail::BIMI::VMC::Chain object for this Chain | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | =head2 errors | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | is=rw | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | =head2 http_client | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | is=rw | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | HTTP::Tiny::Paranoid (or similar) object used for HTTP operations | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | =head2 indicator | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | is=rw | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | Mail::BIMI::Indicator object for the Indicator embedded in this VMC Set | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | =head2 indicator_uri | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | is=rw | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | The URI of the embedded Indicator | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | =head2 is_cert_valid | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | is=rw | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | Is this Certificate Set valid | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | =head2 is_valid | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | is=rw | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | Is this VMC valid | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | =head2 vmc_object | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | is=rw | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | Mail::BIMI::VMC::Cert object for this VMC Set | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | =head2 warnings | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | is=rw | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | =head1 CONSUMES | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | =over 4 | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | =item * L<Mail::BIMI::Role::Cacheable> | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =item * L<Mail::BIMI::Role::HasError> | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | =item * L<Mail::BIMI::Role::HasError|Mail::BIMI::Role::HasHTTPClient|Mail::BIMI::Role::Cacheable> | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | =item * L<Mail::BIMI::Role::HasHTTPClient> | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | =back | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | =head1 EXTENDS | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =over 4 | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | =item * L<Mail::BIMI::Base> | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | =back | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | =head1 METHODS | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | =head2 I<cache_valid_for()> | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | How long should the cache for this class be valid | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | =head2 I<http_client_max_fetch_size()> | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | Maximum permitted HTTP fetch | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | =head2 I<subject()> | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | Return the subject of the VMC | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | =head2 I<subject_entries> | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | exposes the subject string as a hash of key/[value] pairs. | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | =head2 I<mark_type()> | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | Return the subject:markType if available | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | =head2 I<not_before()> | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | Return not before of the vmc | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | =head2 I<not_after()> | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | Return not after of the vmc | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | =head2 I<issuer()> | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | Return the issuer string of the VMC | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | =head2 I<is_expired()> | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | Return true if this VMC has expired | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | =head2 I<alt_name()> | ||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | Return the alt name string for the VMC | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | =head2 I<is_valid_alt_name()> | ||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | Return true if the VMC has a valid alt name for the domain of the current operation | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | =head2 I<is_self_signed()> | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | Return true if this VMC is self signed | ||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | =head2 I<has_valid_usage()> | ||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | Return true if this VMC has a valid usage extension for BIMI | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | =head2 I<is_experimental()> | ||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | Return true if this (V)MC is experimental | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | =head2 I<is_allowed_mark_type()> | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | =head2 I<finish()> | ||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | Finish and clean up, write cache if enabled. | ||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||
| 565 | =head2 I<app_validate()> | ||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | Output human readable validation status of this object | ||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||
| 569 | =head1 REQUIRES | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | =over 4 | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | =item * L<File::Slurp|File::Slurp> | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | =item * L<MIME::Base64|MIME::Base64> | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | =item * L<Mail::BIMI::Indicator|Mail::BIMI::Indicator> | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | =item * L<Mail::BIMI::VMC::Chain|Mail::BIMI::VMC::Chain> | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | =item * L<Moose|Moose> | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | =item * L<Term::ANSIColor|Term::ANSIColor> | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | =back | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | Marc Bradshaw <marc@marcbradshaw.net> | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | This software is copyright (c) 2020 by Marc Bradshaw. | ||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 598 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | =cut | ||||||||||||||||||||||||||||