| 1 | package Mail::BIMI::Record; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Class to model a BIMI record | ||||||||||||||||||||||||||||||||||||||||||
| 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 Term::ANSIColor qw{ :constants }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 30 | ▶ | use Mail::BIMI::Record::Authority; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 29 | ▶ | use Mail::BIMI::Record::Location; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 29 | ▶ | use Mail::DMARC::PurePerl; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 29 | extends 'Mail::BIMI::Base'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 29 | with( | |||||||||||||||||||||||||||||||||||||||||
| 14 | 'Mail::BIMI::Role::HasError', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 'Mail::BIMI::Role::Cacheable', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 29 | has domain => ( is => 'rw', isa => 'Str', required => 1, traits => ['CacheKey'], | |||||||||||||||||||||||||||||||||||||||||
| 18 | documentation => 'inputs: Domain the for the record', ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 29 | has retrieved_domain => ( is => 'rw', isa => 'Str', traits => ['Cacheable'], | |||||||||||||||||||||||||||||||||||||||||
| 20 | documentation => 'Domain the record was retrieved from', ); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 29 | has retrieved_record => ( is => 'rw', traits => ['Cacheable'], | |||||||||||||||||||||||||||||||||||||||||
| 22 | documentation => 'Record as retrieved' ); | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 29 | has retrieved_selector => ( is => 'rw', isa => 'Str', traits => ['Cacheable'], | |||||||||||||||||||||||||||||||||||||||||
| 24 | documentation => 'Selector the record was retrieved from', ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 29 | has selector => ( is => 'rw', isa => 'Str', traits => ['CacheKey'], | |||||||||||||||||||||||||||||||||||||||||
| 26 | documentation => 'inputs: Selector used to retrieve the record; will become default if fallback was used', ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 29 | has version => ( is => 'rw', isa => 'Maybe[Str]', lazy => 1, builder => '_build_version', traits => ['Cacheable'], | |||||||||||||||||||||||||||||||||||||||||
| 28 | documentation => 'BIMI Version tag' ); | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 29 | has authority => ( is => 'rw', isa => 'Mail::BIMI::Record::Authority', lazy => 1, builder => '_build_authority', | |||||||||||||||||||||||||||||||||||||||||
| 30 | documentation => 'Mail::BIMI::Record::Authority object for this record' ); | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 29 | has location => ( is => 'rw', isa => 'Mail::BIMI::Record::Location', lazy => 1, builder => '_build_location', | |||||||||||||||||||||||||||||||||||||||||
| 32 | documentation => 'Mail::BIMI::Record::Location object for this record' ); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 29 | has record_hashref => ( is => 'rw', isa => 'HashRef', lazy => 1, builder => '_build_record_hashref', traits => ['Cacheable'], | |||||||||||||||||||||||||||||||||||||||||
| 34 | documentation => 'Hashref of record values' ); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 29 | has is_valid => ( is => 'rw', lazy => 1, builder => '_build_is_valid', traits => ['Cacheable'], | |||||||||||||||||||||||||||||||||||||||||
| 36 | documentation => 'Is this record valid' ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 6 | ▶ | sub cache_valid_for($self) { return 3600 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_valid_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | ▶ | sub _build_version($self) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_version: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 31 | ▶ | if ( !exists $self->record_hashref->{v} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 30 | return $self->record_hashref->{v}; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | ▶ | sub _build_authority($self) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_authority: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 36 | my $uri; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 36 | ▶ | if ( exists $self->record_hashref->{a} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | ▶ | $uri = $self->record_hashref->{a} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->record_hashref->{"a"} // ""
MC/DC0%0/1
$self->record_hashref->{"a"} // ""
$self->record_hashref->{"a"}
Truth table50%1/2
A
A= $self->record_hashref->{"a"}
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # TODO better parser here | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 36 | return Mail::BIMI::Record::Authority->new( uri => $uri, bimi_object => $self->bimi_object ); | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | ▶ | sub _build_location($self) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_location: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 30 | my $uri; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 30 | ▶ | if ( exists $self->record_hashref->{l} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 25 | ▶ | $uri = $self->record_hashref->{l} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->record_hashref->{"l"} // ""
MC/DC0%0/1
$self->record_hashref->{"l"} // ""
$self->record_hashref->{"l"}
Truth table50%1/2
A
A= $self->record_hashref->{"l"}
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # TODO better parser here | ||||||||||||||||||||||||||||||||||||||||||
| 64 | # Need to decode , and ; as per spec> | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 30 | my $location = Mail::BIMI::Record::Location->new( uri => $uri, is_relevant => $self->location_is_relevant, bimi_object => $self->bimi_object ); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 30 | return $location; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | ▶ | sub location_is_relevant($self) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
location_is_relevant: called CC=4 SCAR=25.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | # True if we don't have a relevant authority OR if we are checking VMC AND Location | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 56 | ▶ | return 1 unless $self->bimi_object->options->no_location_with_vmc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( $self->authority && $self->authority->is_relevant ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->authority and $self->authority->is_relevant
MC/DC0%0/2
$self->authority and $self->authority->is_relevant
$self->authority
$self->authority->is_relevant
Truth table0%0/3
A and B
A= $self->authorityB= $self->authority->is_relevant
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $self->log_verbose('Location is not relevant'); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | ▶ | sub _build_is_valid($self) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_is_valid: called CC=28 SCAR=51.7
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 37 | ▶ | return 0 if ! keys $self->record_hashref->%*; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 31 | ▶ | if ( !defined $self->version ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | $self->add_error('MISSING_V_TAG'); | |||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 30 | ▶ | $self->add_error('EMPTY_V_TAG') if lc $self->version eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 30 | ▶ | $self->add_error('INVALID_V_TAG') if lc $self->version ne 'bimi1'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 30 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 26 | ▶ | if ($self->authority->is_relevant && !$self->authority->is_valid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->authority->is_relevant and not $self->authority->is_valid
MC/DC0%0/2
$self->authority->is_relevant and not $self->authority->is_valid
$self->authority->is_relevant
not $self->authority->is_valid
Truth table33%1/3
A and not(B)
A= $self->authority->is_relevantB= not $self->authority->is_valid
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $self->add_error_object( $self->authority->errors ); | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 26 | ▶ | if ($self->location_is_relevant && !$self->location->is_valid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->location_is_relevant and not $self->location->is_valid
MC/DC50%1/2
$self->location_is_relevant and not $self->location->is_valid
$self->location_is_relevant
not $self->location->is_valid
Truth table66%2/3
A and not(B)
A= $self->location_is_relevantB= not $self->location->is_valid
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | $self->add_error_object( $self->location->errors ); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 26 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 23 | ▶ | if ( $self->bimi_object->options->require_vmc ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | unless ( $self->authority && $self->authority->vmc && $self->authority->vmc->is_valid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->authority and $self->authority->vmc and $self->authority->vmc->is_valid
$self->authority and $self->authority->vmc
MC/DC0%0/3
$self->authority and $self->authority->vmc and $self->authority->vmc->is_valid
$self->authority
$self->authority->vmc
$self->authority->vmc->is_valid
Truth table0%0/4
A and B and C
A= $self->authorityB= $self->authority->vmcC= $self->authority->vmc->is_valid
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $self->add_error('VMC_REQUIRED'); | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 23 | ▶ | if ( $self->authority && $self->authority->is_relevant ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->authority and $self->authority->is_relevant
MC/DC0%0/2
$self->authority and $self->authority->is_relevant
$self->authority
$self->authority->is_relevant
Truth table33%1/3
A and B
A= $self->authorityB= $self->authority->is_relevant
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | # Check the SVG payloads are identical | ||||||||||||||||||||||||||||||||||||||||||
| 109 | ## Compare raw? or Uncompressed? | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ( !$self->authority->vmc ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | # We could not get a vmc to check, return an error. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $self->add_error('VMC_PARSE_ERROR'); | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | elsif ( !$self->authority->vmc->indicator ) { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | # We could not get an indicator from the vmc to check, return an error. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $self->add_error('VMC_PARSE_ERROR','Could not extract SVG from VMC'); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | ▶ | elsif ( $self->location_is_relevant && !$self->location ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->location_is_relevant and not $self->location
MC/DC0%0/2
$self->location_is_relevant and not $self->location
$self->location_is_relevant
not $self->location
Truth table0%0/3
A and not(B)
A= $self->location_is_relevantB= not $self->location
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | # We could not get a location to check against, return an error. | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $self->add_error('SVG_MISMATCH'); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | ▶ | elsif ( $self->location_is_relevant && !$self->location->indicator ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->location_is_relevant and not $self->location->indicator
MC/DC0%0/2
$self->location_is_relevant and not $self->location->indicator
$self->location_is_relevant
not $self->location->indicator
Truth table0%0/3
A and not(B)
A= $self->location_is_relevantB= not $self->location->indicator
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | # We could not get an indicator from the location to check against, return an error. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->add_error('SVG_MISMATCH'); | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | ▶ | elsif ( $self->location_is_relevant && $self->authority->vmc->indicator->data_uncompressed_normalized ne $self->location->indicator->data_uncompressed_normalized ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->location_is_relevant and $self->authority->vmc->indicator->data_uncompressed_normalized ne $self->location->indicator->data_uncompressed_normalized
MC/DC0%0/2
$self->location_is_relevant and $self->authority->vmc->indicator->data_uncompressed_normalized ne $self->location->indicator->data_uncompressed_normalized
$self->location_is_relevant
$self->authority->vmc->indicator->data_uncompressed_normalized ne $self->location->indicator->data_uncompressed_normalized
Truth table0%0/3
A and B
A= $self->location_is_relevantB= $self->authority->vmc->indicator->data_uncompressed_normalized ne $self->location->indicator->data_uncompressed_normalized
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->add_error('SVG_MISMATCH'); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | ▶ | elsif ( $self->location_is_relevant && $self->authority->vmc->indicator->data_uncompressed ne $self->location->indicator->data_uncompressed ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->location_is_relevant and $self->authority->vmc->indicator->data_uncompressed ne $self->location->indicator->data_uncompressed
MC/DC0%0/2
$self->location_is_relevant and $self->authority->vmc->indicator->data_uncompressed ne $self->location->indicator->data_uncompressed
$self->location_is_relevant
$self->authority->vmc->indicator->data_uncompressed ne $self->location->indicator->data_uncompressed
Truth table0%0/3
A and B
A= $self->location_is_relevantB= $self->authority->vmc->indicator->data_uncompressed ne $self->location->indicator->data_uncompressed
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $self->add_warning('Line encoding for SVG in bimi-location did not match SVG in VMC'); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 23 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 23 | $self->log_verbose('Record is valid'); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 23 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | ▶ | sub _build_record_hashref($self) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_record_hashref: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 26 | my $domain = $self->domain; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 26 | my $selector = $self->selector; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 26 | my $fallback_selector = $self->selector; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 26 | my $fallback_domain = Mail::DMARC::PurePerl->new->get_organizational_domain($domain); | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 26 | my @records; | |||||||||||||||||||||||||||||||||||||||||
| 146 | eval { | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 26 | @records = $self->_get_from_dns($selector,$domain); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 25 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 26 | ▶ | } || do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | $error =~ s/ at \/.*$//s; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | $self->add_error('DNS_ERROR',$error); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 154 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 25 | @records = grep { $_ =~ /^v\s*=\s*bimi1;/i } @records; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 25 | ▶ | if ( !@records ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 6 | ▶ | if ( $domain eq $fallback_domain && $selector eq $fallback_selector ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$domain eq $fallback_domain and $selector eq $fallback_selector
MC/DC50%1/2
$domain eq $fallback_domain and $selector eq $fallback_selector
$domain eq $fallback_domain
$selector eq $fallback_selector
Truth table66%2/3
A and B
A= $domain eq $fallback_domainB= $selector eq $fallback_selector
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | # nothing to fall back to | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | $self->add_error('NO_BIMI_RECORD'); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | $self->log_verbose('Trying fallback domain'); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | my @records; | |||||||||||||||||||||||||||||||||||||||||
| 167 | eval { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | @records = $self->_get_from_dns($fallback_selector,$fallback_domain); | |||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | ▶ | } || do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | $error =~ s/ at \/.*$//; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | $self->add_error('DNS_ERROR',$error); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 175 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | @records = grep { $_ =~ /^v\s*=\s*bimi1;/i } @records; | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | ▶ | if ( !@records ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->add_error('NO_BIMI_RECORD'); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | elsif ( scalar @records > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | $self->add_error('MULTI_BIMI_RECORD'); | |||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | # We have one record, let's use that. | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | $self->retrieved_record($records[0]); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | $self->retrieved_domain($fallback_domain); | |||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | $self->retrieved_selector($fallback_selector); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | return $self->_parse_record($records[0]); | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | elsif ( scalar @records > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | $self->add_error('MULTI_BIMI_RECORD'); | |||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 200 | # We have one record, let's use that. | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 18 | $self->retrieved_record($records[0]); | |||||||||||||||||||||||||||||||||||||||||
| 202 | 18 | $self->retrieved_domain($domain); | |||||||||||||||||||||||||||||||||||||||||
| 203 | 18 | $self->retrieved_selector($selector); | |||||||||||||||||||||||||||||||||||||||||
| 204 | 18 | return $self->_parse_record($records[0]); | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | ▶ | sub _get_from_dns($self,$selector,$domain) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_from_dns: called CC=11 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 30 | my @matches; | |||||||||||||||||||||||||||||||||||||||||
| 210 | my $cname; | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 30 | ▶ | if ($self->bimi_object->options->force_record) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->log_verbose('Using fake record'); | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | push @matches, $self->bimi_object->options->force_record; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | return @matches; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 30 | my $res = $self->bimi_object->resolver; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 30 | ▶ | my $query = $res->query( "$selector._bimi.$domain", 'TXT' ) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | return @matches; | |||||||||||||||||||||||||||||||||||||||||
| 219 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 22 | for my $rr ( $query->answer ) { | |||||||||||||||||||||||||||||||||||||||||
| 221 | 24 | ▶ | $cname = $rr->cname if $rr->type eq 'CNAME'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 24 | ▶ | next if $rr->type ne 'TXT'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 23 | push @matches, scalar $rr->txtdata; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 22 | ▶ | if (!@matches && $cname) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not @matches and $cname
MC/DC50%1/2
not @matches and $cname
not @matches
$cname
Truth table66%2/3
not(A) and B
A= not @matchesB= $cname
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | # follow a single CNAME | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | ▶ | $query = $res->query( $cname, 'TXT' ) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return @matches; | |||||||||||||||||||||||||||||||||||||||||
| 230 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | for my $rr ( $query->answer ) { | |||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | ▶ | next if $rr->type ne 'TXT'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | push @matches, scalar $rr->txtdata; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 22 | return @matches; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | ▶ | sub _parse_record($self,$record) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_record: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 36 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 36 | my @parts = split ';', $record; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 36 | foreach my $part ( @parts ) { | |||||||||||||||||||||||||||||||||||||||||
| 244 | 74 | $part =~ s/^ +//; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 74 | $part =~ s/ +$//; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 74 | my ( $key, $value ) = split '\s*=\s*', $part, 2; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 74 | $key = lc $key; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 74 | ▶ | if ( exists $data->{ $key } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | $self->add_error('DUPLICATE_KEY'); | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 74 | ▶ | if ( grep { $key eq $_ } ( qw{ v l a } ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 74 | $data->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 36 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | ▶ | sub finish($self) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | ▶ | $self->authority->finish if $self->authority; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | ▶ | $self->location->finish if $self->location; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 5 | $self->_write_cache; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | ▶ | sub app_validate($self) { | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
app_validate: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | say 'Record Returned: '.($self->is_valid ? GREEN."\x{2713}" : BRIGHT_RED."\x{26A0}").RESET; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $self->is_valid; # To set retrieved record and retrieved domain/selector | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | say YELLOW.' Record : '.($self->retrieved_record//'-none-').RESET; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->retrieved_record // "-none-"
MC/DC0%0/1
$self->retrieved_record // "-none-"
$self->retrieved_record
Truth table0%0/2
A
A= $self->retrieved_record
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ($self->retrieved_record){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | say YELLOW.' Version '.WHITE.': '.CYAN.($self->version//'-none-').RESET; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->version // "-none-"
MC/DC0%0/1
$self->version // "-none-"
$self->version
Truth table0%0/2
A
A= $self->version
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | say YELLOW.' Domain '.WHITE.': '.CYAN.($self->retrieved_domain//'-none-').RESET; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->retrieved_domain // "-none-"
MC/DC0%0/1
$self->retrieved_domain // "-none-"
$self->retrieved_domain
Truth table0%0/2
A
A= $self->retrieved_domain
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | say YELLOW.' Selector '.WHITE.': '.CYAN.($self->retrieved_selector//'-none-').RESET; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->retrieved_selector // "-none-"
MC/DC0%0/1
$self->retrieved_selector // "-none-"
$self->retrieved_selector
Truth table0%0/2
A
A= $self->retrieved_selector
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | say YELLOW.' Authority '.WHITE.': '.CYAN.($self->authority->uri//'-none-').RESET if $self->authority; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->authority->uri // "-none-"
MC/DC0%0/1
$self->authority->uri // "-none-"
$self->authority->uri
Truth table0%0/2
A
A= $self->authority->uri
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | say YELLOW.' Location '.WHITE.': '.CYAN.($self->location->uri//'-none-').RESET if $self->location_is_relevant && $self->location; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$self->location_is_relevant and $self->location
$self->location->uri // "-none-"
MC/DC0%0/2
$self->location_is_relevant and $self->location
$self->location_is_relevant
$self->location
MC/DC0%0/1
$self->location->uri // "-none-"
$self->location->uri
Truth table0%0/3
A and B
A= $self->location_is_relevantB= $self->location
Truth table0%0/2
A
A= $self->location->uri
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | say YELLOW.' Is Valid '.WHITE.': '.($self->is_valid?GREEN.'Yes':BRIGHT_RED.'No').RESET; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ( $self->warnings->@* ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | say "Warnings:"; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | foreach my $warning ( $self->warnings->@* ) { | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | say CYAN.' '.$warning.RESET; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ( ! $self->is_valid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | say "Errors:"; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | foreach my $error ( $self->errors->@* ) { | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $error_code = $error->code; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $error_text = $error->description; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $error_detail =~ s/\n/\n /g; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | say BRIGHT_RED." $error_code ".WHITE.': '.CYAN.$error_text.($error_detail?"\n ".$error_detail:'').RESET; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 29 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | Mail::BIMI::Record - Class to model a BIMI record | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | version 3.20260302 | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | Class for representing, retrieving, validating, and processing a BIMI Record | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | =head1 INPUTS | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 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 | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | =head2 domain | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | is=rw required | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | Domain the for the record | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | =head2 selector | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | Selector used to retrieve the record; will become default if fallback was used | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 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 | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | =head2 authority | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | Mail::BIMI::Record::Authority object for this record | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | =head2 cache_backend | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | is=ro | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | =head2 errors | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | =head2 is_valid | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | Is this record valid | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | =head2 location | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | Mail::BIMI::Record::Location object for this record | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | =head2 record_hashref | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | Hashref of record values | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | =head2 retrieved_domain | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | Domain the record was retrieved from | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | =head2 retrieved_record | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | Record as retrieved | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | =head2 retrieved_selector | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | Selector the record was retrieved from | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | =head2 version | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | BIMI Version tag | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | =head2 warnings | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | is=rw | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | =head1 CONSUMES | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | =item * L<Mail::BIMI::Role::Cacheable> | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | =item * L<Mail::BIMI::Role::HasError> | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | =item * L<Mail::BIMI::Role::HasError|Mail::BIMI::Role::Cacheable> | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | =head1 EXTENDS | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | =item * L<Mail::BIMI::Base> | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | =head2 I<cache_valid_for()> | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | How long should the cache for this class be valid | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | =head2 I<location_is_relevant()> | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | Return true is the location is relevant to the validation of the record. | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | If we don't have a relevant authority, or we are checking BOTH authority and location. | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | =head2 I<finish()> | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | Finish and clean up, write cache if enabled. | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | =head2 I<app_validate()> | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | Output human readable validation status of this object | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | =head1 REQUIRES | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | =item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | =item * L<Mail::BIMI::Record::Authority|Mail::BIMI::Record::Authority> | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | =item * L<Mail::BIMI::Record::Location|Mail::BIMI::Record::Location> | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | =item * L<Mail::DMARC::PurePerl|Mail::DMARC::PurePerl> | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | =item * L<Moose|Moose> | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | =item * L<Term::ANSIColor|Term::ANSIColor> | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | Marc Bradshaw <marc@marcbradshaw.net> | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | This software is copyright (c) 2020 by Marc Bradshaw. | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 465 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | =cut | ||||||||||||||||||||||||||||||||||||||||||