| 1 | package Mail::BIMI::Record::Authority; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Class to model a BIMI authority | ||||||||||||||||||||||||||||
| 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 Mail::BIMI::VMC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 29 | extends 'Mail::BIMI::Base'; | |||||||||||||||||||||||||||
| 10 | 29 | with 'Mail::BIMI::Role::HasError'; | |||||||||||||||||||||||||||
| 11 | 29 | has is_authority_valid => ( is => 'rw', lazy => 1, builder => '_build_is_authority_valid' ); | |||||||||||||||||||||||||||
| 12 | 29 | has uri => ( is => 'rw', isa => 'Maybe[Str]', required => 1, | |||||||||||||||||||||||||||
| 13 | documentation => 'inputs: URI of VMC', ); | ||||||||||||||||||||||||||||
| 14 | 29 | has is_valid => ( is => 'rw', lazy => 1, builder => '_build_is_valid', | |||||||||||||||||||||||||||
| 15 | documentation => 'Is this Authority valid' ); | ||||||||||||||||||||||||||||
| 16 | 29 | has vmc => ( is => 'rw', lazy => 1, builder => '_build_vmc', | |||||||||||||||||||||||||||
| 17 | documentation => 'Mail::BIMI::VMC object for this Authority' ); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | ▶ | sub _build_is_authority_valid($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_is_authority_valid: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||
| 21 | 8 | ▶ | return 1 if !defined $self->uri; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | return 1 if $self->uri eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | return 1 if $self->uri eq 'self'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | if ( ! ( $self->uri =~ /^https:\/\// ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 1 | $self->add_error('INVALID_TRANSPORT_A'); | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | return 1; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | ▶ | sub is_relevant($self) { | |||||||||||||||||||||||||||
|
Subroutine
is_relevant: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 77 | ▶ | return 0 if !defined $self->uri; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 11 | ▶ | return 0 if $self->uri eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 3 | ▶ | return 0 if $self->uri eq 'self'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | return 0 if $self->bimi_object->options->no_validate_cert; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 1 | $self->log_verbose('Authority is relevant'); | |||||||||||||||||||||||||||
| 39 | 1 | return 1; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | ▶ | sub _build_is_valid($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_is_valid: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||
| 43 | 3 | ▶ | return 0 if !$self->is_authority_valid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 2 | ▶ | if ( $self->is_relevant && !$self->vmc->is_valid ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->is_relevant and not $self->vmc->is_valid
MC/DC0%0/2
$self->is_relevant and not $self->vmc->is_valid
$self->is_relevant
not $self->vmc->is_valid
Truth table33%1/3
A and not(B)
A= $self->is_relevantB= not $self->vmc->is_valid
| |||||||||||||||||||||||||||||
| 45 | 0 | $self->add_error_object( $self->vmc->errors ); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 2 | ▶ | return 0 if $self->errors->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 2 | $self->log_verbose('Authority is valid'); | |||||||||||||||||||||||||||
| 50 | 2 | return 1; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | ▶ | sub _build_vmc($self) { | |||||||||||||||||||||||||||
|
Subroutine
_build_vmc: called CC=3 SCAR=15.1
| |||||||||||||||||||||||||||||
| 54 | 5 | ▶ | return if !$self->is_authority_valid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 5 | ▶ | return if !$self->is_relevant; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | my $check_domain = $self->bimi_object->record->retrieved_domain; | |||||||||||||||||||||||||||
| 57 | 0 | my $check_selector = $self->bimi_object->record->retrieved_selector; | |||||||||||||||||||||||||||
| 58 | 0 | return Mail::BIMI::VMC->new( check_domain => $check_domain, check_selector => $check_selector, uri => $self->uri, bimi_object => $self->bimi_object ); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | ▶ | sub finish($self) { | |||||||||||||||||||||||||||
|
Subroutine
finish: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 5 | ▶ | $self->vmc->finish if $self->vmc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 29 | 1; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =pod | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head1 NAME | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | Mail::BIMI::Record::Authority - Class to model a BIMI authority | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 VERSION | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | version 3.20260302 | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Class for representing, validating, and processing a BIMI authority attribute | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 INPUTS | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 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 | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head2 uri | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | is=rw required | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | URI of VMC | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 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 | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head2 errors | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | is=rw | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head2 is_authority_valid | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | is=rw | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head2 is_valid | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | is=rw | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Is this Authority valid | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head2 vmc | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | is=rw | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | Mail::BIMI::VMC object for this Authority | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =head2 warnings | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | is=rw | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head1 CONSUMES | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =over 4 | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =item * L<Mail::BIMI::Role::HasError> | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =back | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =head1 EXTENDS | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =over 4 | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =item * L<Mail::BIMI::Base> | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =back | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =head1 METHODS | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =head2 I<is_relevant()> | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | Return true if this Authority is relevant to validation | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =head2 I<finish()> | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | Finish and clean up, write cache if enabled. | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | =head1 REQUIRES | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =over 4 | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =item * L<Mail::BIMI::VMC|Mail::BIMI::VMC> | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =item * L<Moose|Moose> | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =back | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | Marc Bradshaw <marc@marcbradshaw.net> | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | This software is copyright (c) 2020 by Marc Bradshaw. | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 171 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||