« blib/lib/Mail/DMARC/Report/Aggregate/Record/Row/Policy_Evaluated.pm
↑ Summary
lib/Mail/DMARC/Report/Store/SQL/Grammars/PostgreSQL.pm »
| 1 | package Mail::DMARC::Policy; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use feature 'signatures'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | no warnings 'experimental::args_array_with_signatures'; ## no critic (ProhibitNoWarnings) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 16 | our $VERSION = '2.20260827'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 16 | ▶ | use Mail::DMARC::Report::URI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 182 | ▶ | sub new( $class, @args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 182 | ▶ | my $package = ref $class ? ref $class : $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 182 | my $self = bless {}, $package; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 182 | ▶ | return $self if !@args; # no args, empty pol | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 125 | ▶ | if ( 1 == @args ) { # a string | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 90 | my $policy = $self->parse( $args[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 20 | 90 | $self->is_valid($policy); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 88 | return $policy; | |||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 35 | ▶ | croak "invalid arguments" if @args % 2 != 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 35 | my $policy = {@args}; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 35 | bless $policy, $package; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 35 | ▶ | croak "invalid policy" if !$self->is_valid($policy); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 32 | return bless $policy, $package; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 180 | ▶ | sub parse( $self, $str, @junk ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=12 SCAR=26.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 180 | ▶ | croak "invalid parse request" if @junk; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 180 | my $cleaned = $str; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 180 | $cleaned =~ s/\s//g; # remove whitespace | |||||||||||||||||||||||||||||||||||||||||
| 35 | 180 | $cleaned =~ s/\\;/;/g; # replace \; with ; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 180 | $cleaned =~ s/;;/;/g; # replace ;; with ; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 180 | $cleaned =~ s/;0;/;/g; # replace ;0; with ; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 180 | ▶ | chop $cleaned if ';' eq substr $cleaned, -1, 1; # remove a trailing ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 180 | my @tag_vals = split /;/, $cleaned; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 180 | my %policy; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 180 | my $warned = 0; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 180 | foreach my $tv (@tag_vals) { | |||||||||||||||||||||||||||||||||||||||||
| 44 | 976 | my ( $tag, $value ) = split /=|:|-/, $tv, 2; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 976 | ▶ | if ( !defined $tag || !defined $value || $value eq '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not defined $tag && defined $value or $value eq ""
defined $tag && defined $value
MC/DC33%1/3
not defined $tag && defined $value or $value eq ""
defined $tag
defined $value
$value eq ""
Truth table50%2/4
not(A && B) or C
A= defined $tagB= defined $valueC= $value eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | if ( !$warned ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | #warn "tv: $tv\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | warn "invalid DMARC record, please post this message to\n" | |||||||||||||||||||||||||||||||||||||||||
| 50 | . "\thttps://github.com/msimerson/mail-dmarc/issues/39\n" | ||||||||||||||||||||||||||||||||||||||||||
| 51 | . "\t$str\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | $warned++; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 974 | $policy{ lc $tag } = $value; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | # RFC 9989: an unrecognized value for an optional tag is ignored (the tag | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # reverts to its default); it MUST NOT invalidate the whole record. The | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # setters croak, so normalize here on the parse-from-DNS path instead. | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 180 | ▶ | if ( defined $policy{psd} && $policy{psd} !~ /^[ynu]$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $policy{"psd"} and not $policy{"psd"} =~ /^[ynu]$/i
MC/DC0%0/2
defined $policy{"psd"} and not $policy{"psd"} =~ /^[ynu]$/i
defined $policy{"psd"}
not $policy{"psd"} =~ /^[ynu]$/i
Truth table66%2/3
A and not(B)
A= defined $policy{"psd"}B= not $policy{"psd"} =~ /^[ynu]$/i
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | warn "ignoring invalid psd ($policy{psd})\n"; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | delete $policy{psd}; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 180 | ▶ | if ( defined $policy{t} && $policy{t} !~ /^[yn]$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $policy{"t"} and not $policy{"t"} =~ /^[yn]$/i
MC/DC0%0/2
defined $policy{"t"} and not $policy{"t"} =~ /^[yn]$/i
defined $policy{"t"}
not $policy{"t"} =~ /^[yn]$/i
Truth table66%2/3
A and not(B)
A= defined $policy{"t"}B= not $policy{"t"} =~ /^[yn]$/i
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | warn "ignoring invalid t ($policy{t})\n"; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | delete $policy{t}; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 180 | return bless \%policy, ref $self; # inherited defaults + overrides | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | ▶ | sub stringify($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | my %dmarc_record = %{$self}; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | delete $dmarc_record{domain}; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | my $dmarc_txt = 'v=' . ( delete $dmarc_record{v} ); # "v" tag must be first | |||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | foreach my $key ( keys %dmarc_record ) { | |||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | $dmarc_txt .= "; $key=$dmarc_record{$key}"; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | return $dmarc_txt; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 11 | ▶ | sub apply_defaults($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_defaults: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 11 | ▶ | $self->adkim('r') if !defined $self->adkim; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 11 | ▶ | $self->aspf('r') if !defined $self->aspf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 11 | ▶ | $self->fo(0) if !defined $self->fo; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | # rf, ri, pct are deprecated in DMARCbis (RFC 9989) and MUST be ignored | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 11 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 7 | ▶ | sub v( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
v: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 7 | ▶ | return $self->{v} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 5 | ▶ | croak "unsupported DMARC version" if 'DMARC1' ne uc $val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 4 | return $self->{v} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 198 | ▶ | sub p( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
p: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 198 | ▶ | return $self->{p} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 14 | ▶ | croak "invalid p" if !$self->is_valid_p($val); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 10 | return $self->{p} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 83 | ▶ | sub sp( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sp: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 83 | ▶ | return $self->{sp} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 9 | ▶ | croak "invalid sp ($val)" if !$self->is_valid_p($val); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 6 | return $self->{sp} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 73 | ▶ | sub np( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
np: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 73 | ▶ | return $self->{np} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 10 | ▶ | croak "invalid np ($val)" if !$self->is_valid_p($val); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 7 | return $self->{np} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 141 | ▶ | sub psd( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psd: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 141 | ▶ | return $self->{psd} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 10 | ▶ | croak "invalid psd ($val)" if 0 == grep {/^\Q$val\E$/i} qw/ y n u /; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 7 | return $self->{psd} = lc $val; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 40 | ▶ | sub t( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
t: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 40 | ▶ | return $self->{t} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 8 | ▶ | croak "invalid t ($val)" if 0 == grep {/^\Q$val\E$/i} qw/ y n /; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | return $self->{t} = lc $val; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 58 | ▶ | sub adkim( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adkim: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 58 | ▶ | return $self->{adkim} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 16 | ▶ | croak "invalid adkim" if 0 == grep {/^\Q$val\E$/ix} qw/ r s /; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 14 | return $self->{adkim} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 85 | ▶ | sub aspf( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
aspf: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 85 | ▶ | return $self->{aspf} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 17 | ▶ | croak "invalid aspf" if 0 == grep {/^\Q$val\E$/ix} qw/ r s /; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 15 | return $self->{aspf} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 34 | ▶ | sub fo( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fo: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 34 | ▶ | return $self->{fo} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 23 | ▶ | croak "invalid fo: $val" if $val !~ /^[01ds](:[01ds])*$/ix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 19 | return $self->{fo} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 78 | ▶ | sub rua( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rua: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 78 | ▶ | return $self->{rua} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 28 | ▶ | croak "invalid rua" if !$self->is_valid_uri_list($val); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 26 | return $self->{rua} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | ▶ | sub ruf( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ruf: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | ▶ | return $self->{ruf} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | ▶ | croak "invalid rua" if !$self->is_valid_uri_list($val); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | return $self->{ruf} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | ▶ | sub rf( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rf: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | ▶ | return $self->{rf} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | foreach my $f ( split /,/, $val ) { | |||||||||||||||||||||||||||||||||||||||||
| 163 | 7 | ▶ | croak "invalid format: $f" if !$self->is_valid_rf($f); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | return $self->{rf} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 18 | ▶ | sub ri( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ri: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 18 | ▶ | return $self->{ri} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | ▶ | croak "not numeric ($val)!" if $val =~ /\D/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | ▶ | croak "not an integer!" if $val != int $val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | ▶ | croak "out of range" if ( $val < 0 || $val > 4294967295 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$val < 0 or $val > 4294967295
MC/DC50%1/2
$val < 0 or $val > 4294967295
$val < 0
$val > 4294967295
Truth table66%2/3
A or B
A= $val < 0B= $val > 4294967295
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | return $self->{ri} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 12 | ▶ | sub pct( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pct: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 12 | ▶ | return $self->{pct} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 11 | ▶ | croak "not numeric ($val)!" if $val =~ /\D/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 6 | ▶ | croak "not an integer!" if $val != int $val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 6 | ▶ | croak "out of range" if $val < 0 || $val > 100; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$val < 0 or $val > 100
MC/DC50%1/2
$val < 0 or $val > 100
$val < 0
$val > 100
Truth table66%2/3
A or B
A= $val < 0B= $val > 100
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | return $self->{pct} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 126 | ▶ | sub domain( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
domain: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 126 | ▶ | return $self->{domain} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 14 | return $self->{domain} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 12 | ▶ | sub is_valid_rf( $self, $f ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_rf: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 12 | ▶ | return ( grep {/^\Q$f\E$/i} qw/ iodef afrf / ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 254 | ▶ | sub is_valid_p( $self, $p ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_p: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 254 | ▶ | croak "unspecified p" if !defined $p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 253 | ▶ | return ( grep {/^\Q$p\E$/i} qw/ none reject quarantine / ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 32 | ▶ | sub is_valid_uri_list( $self, $str ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_uri_list: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 32 | ▶ | $self->{uri} ||= Mail::DMARC::Report::URI->new; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"uri"} ||= "Mail::DMARC::Report::URI"->new
MC/DC0%0/2
$self->{"uri"} ||= "Mail::DMARC::Report::URI"->new
$self->{"uri"}
"Mail::DMARC::Report::URI"->new
Truth table66%2/3
A ||= B
A= $self->{"uri"}B= "Mail::DMARC::Report::URI"->new
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 32 | my $uris = $self->{uri}->parse($str); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 32 | return scalar @$uris; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 165 | ▶ | sub is_valid( $self, $obj = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=14 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 165 | ▶ | $obj = $self if !$obj; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 165 | ▶ | croak "missing version specifier" if !$obj->{v}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 164 | ▶ | croak "invalid version" if 'DMARC1' ne uc $obj->{v}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | # psd=y domains (PSDs) are not required to have a p= tag | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 164 | ▶ | my $is_psd = defined $obj->{psd} && lc $obj->{psd} eq 'y'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $obj->{'psd'} && lc $obj->{'psd'} eq 'y'
MC/DC100%2/2
defined $obj->{'psd'} && lc $obj->{'psd'} eq 'y'
defined $obj->{'psd'}
lc $obj->{'psd'} eq 'y'
Truth table100%3/3
A && B
A= defined $obj->{'psd'}B= lc $obj->{'psd'} eq 'y'
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 164 | ▶ | if ( !$obj->{p} && !$is_psd ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$obj->{"p"} or $is_psd
MC/DC100%2/2
$obj->{"p"} or $is_psd
$obj->{"p"}
$is_psd
Truth table100%3/3
A or B
A= $obj->{"p"}B= $is_psd
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 4 | ▶ | if ( $obj->{rua} && $self->is_valid_uri_list( $obj->{rua} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$obj->{"rua"} and $self->is_valid_uri_list($obj->{"rua"})
MC/DC100%2/2
$obj->{"rua"} and $self->is_valid_uri_list($obj->{"rua"})
$obj->{"rua"}
$self->is_valid_uri_list($obj->{"rua"})
Truth table100%3/3
A and B
A= $obj->{"rua"}B= $self->is_valid_uri_list($obj->{"rua"})
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | $obj->{p} = 'none'; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | croak "missing policy action (p=)"; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 161 | ▶ | if ( $obj->{p} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 158 | ▶ | croak "invalid policy action" if !$self->is_valid_p( $obj->{p} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 160 | ▶ | if ( defined $obj->{np} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 8 | ▶ | croak "invalid np" if !$self->is_valid_p( $obj->{np} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | # everything else is optional | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 159 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | Mail::DMARC::Policy - a DMARC policy in object format | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | version 2.20260827 | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | my $pol = Mail::DMARC::Policy->new( | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 'v=DMARC1; p=none; rua=mailto:dmarc@example.com' | ||||||||||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | print "not a valid DMARC version!" if $pol->v ne 'DMARC1'; | ||||||||||||||||||||||||||||||||||||||||||
| 252 | print "take no action" if $pol->p eq 'none'; | ||||||||||||||||||||||||||||||||||||||||||
| 253 | print "reject that unaligned message" if $pol->p eq 'reject'; | ||||||||||||||||||||||||||||||||||||||||||
| 254 | print "do not send aggregate reports" if ! $pol->rua; | ||||||||||||||||||||||||||||||||||||||||||
| 255 | print "do not send forensic reports" if ! $pol->ruf; | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | A DMARC record in DNS format looks like this: | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | v=DMARC1; p=reject; adkim=s; aspf=s; rua=mailto:dmarc@example.com; | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | DMARC records are stored in TXT resource records in the DNS, at _dmarc.example.com. To retrieve a DMARC record for a domain: | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | =head2 dig | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | dig +short _dmarc.example.com TXT | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | =head2 perlishly | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | print $_->txtdata."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 272 | for Net::DNS::Resolver->new(dnsrch=>0)->send('_dmarc.example.com','TXT')->answer; | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | =head2 dmarc_lookup | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | dmarc_lookup example.com | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | All methods validate their input against the DMARC specification (RFC 7489 / DMARCbis RFC 9989). Attempts to set invalid values will throw exceptions. | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | Create a new empty policy: | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | my $pol = Mail::DMARC::Policy->new; | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | Create a new policy from named arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | my $pol = Mail::DMARC::Policy->new( | ||||||||||||||||||||||||||||||||||||||||||
| 291 | v => 'DMARC1', | ||||||||||||||||||||||||||||||||||||||||||
| 292 | p => 'none', | ||||||||||||||||||||||||||||||||||||||||||
| 293 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | Create a new policy from a DMARC DNS resource record: | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | my $pol = Mail::DMARC::Policy->new( | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 'v=DMARC1; p=reject; rua=mailto:dmarc@example.com;' | ||||||||||||||||||||||||||||||||||||||||||
| 299 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | If a policy is passed in (the latter two examples), the resulting policy object will be an exact representation of the record as returned from DNS. | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | =head2 apply_defaults | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | The DMARC tags C<adkim>, C<aspf>, and C<fo> have default values when not specified in the published DNS record. Calling I<apply_defaults> will apply those defaults to tags not present in the DNS record. | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | C<rf>, C<ri>, and C<pct> are deprecated in DMARCbis (RFC 9989) and MUST be ignored; C<apply_defaults> no longer sets them. | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | =head2 parse | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | Accepts a string containing a DMARC Resource Record, as it would be retrieved | ||||||||||||||||||||||||||||||||||||||||||
| 312 | via DNS. | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | my $pol = Mail::DMARC::Policy->new; | ||||||||||||||||||||||||||||||||||||||||||
| 315 | $pol->parse( 'v=DMARC1; p=none; rua=mailto:dmarc@example.com' ); | ||||||||||||||||||||||||||||||||||||||||||
| 316 | $pol->parse( 'v=DMARC1' ); # external reporting record | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | =head2 stringify | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | Returns the textual representation of the DMARC record. | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | my $pol = Mail::DMARC::Policy->new('v=DMARC1; p=none;'); | ||||||||||||||||||||||||||||||||||||||||||
| 323 | print $pol->stringify; | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | =head1 Record Tags | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | =head2 Tag Overview | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | v=DMARC1; (version) | ||||||||||||||||||||||||||||||||||||||||||
| 330 | p=none; (disposition policy : reject, quarantine, none (monitor)) | ||||||||||||||||||||||||||||||||||||||||||
| 331 | sp=reject; (subdomain policy: same as p) | ||||||||||||||||||||||||||||||||||||||||||
| 332 | adkim=s; (dkim alignment: s=strict, r=relaxed) | ||||||||||||||||||||||||||||||||||||||||||
| 333 | aspf=r; (spf alignment: s=strict, r=relaxed) | ||||||||||||||||||||||||||||||||||||||||||
| 334 | rua=mailto:dmarc-feedback@example.com; (aggregate reports) | ||||||||||||||||||||||||||||||||||||||||||
| 335 | ruf=mailto:dmarc-feedback@example.com; (forensic reports) | ||||||||||||||||||||||||||||||||||||||||||
| 336 | rf=afrf; (DEPRECATED in DMARCbis: report format) | ||||||||||||||||||||||||||||||||||||||||||
| 337 | ri=8400; (DEPRECATED in DMARCbis: report interval) | ||||||||||||||||||||||||||||||||||||||||||
| 338 | pct=50; (DEPRECATED in DMARCbis: percent of messages to filter) | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | =head2 Tags in Detail | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | The descriptions of each DMARC record tag and its corresponding values is from the March 31, 2013 draft of the DMARC spec: | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | https://datatracker.ietf.org/doc/draft-kucherawy-dmarc-base/?include_text=1 | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | Each tag has a mutator that's a setter and getter. To set any of the tag values, pass in the new value. Examples: | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | $pol->p('none'); set policy action to none | ||||||||||||||||||||||||||||||||||||||||||
| 349 | print "do nothing" if $pol->p eq 'none'; get policy action | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | =head2 v | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | Version (plain-text; REQUIRED). Identifies the record retrieved | ||||||||||||||||||||||||||||||||||||||||||
| 354 | as a DMARC record. It MUST have the value of "DMARC1". The value | ||||||||||||||||||||||||||||||||||||||||||
| 355 | of this tag MUST match precisely; if it does not or it is absent, | ||||||||||||||||||||||||||||||||||||||||||
| 356 | the entire retrieved record MUST be ignored. It MUST be the first | ||||||||||||||||||||||||||||||||||||||||||
| 357 | tag in the list. | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | =head2 p | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | Requested Mail Receiver policy (plain-text; REQUIRED for policy | ||||||||||||||||||||||||||||||||||||||||||
| 362 | records). Indicates the policy to be enacted by the Receiver at | ||||||||||||||||||||||||||||||||||||||||||
| 363 | the request of the Domain Owner. Policy applies to the domain | ||||||||||||||||||||||||||||||||||||||||||
| 364 | queried and to sub-domains unless sub-domain policy is explicitly | ||||||||||||||||||||||||||||||||||||||||||
| 365 | described using the "sp" tag. This tag is mandatory for policy | ||||||||||||||||||||||||||||||||||||||||||
| 366 | records only, but not for third-party reporting records (see | ||||||||||||||||||||||||||||||||||||||||||
| 367 | Section 8.2). | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | =head2 sp | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | {R6} Requested Mail Receiver policy for subdomains (plain-text; | ||||||||||||||||||||||||||||||||||||||||||
| 372 | OPTIONAL). Indicates the policy to be enacted by the Receiver at | ||||||||||||||||||||||||||||||||||||||||||
| 373 | the request of the Domain Owner. It applies only to subdomains of | ||||||||||||||||||||||||||||||||||||||||||
| 374 | the domain queried and not to the domain itself. Its syntax is | ||||||||||||||||||||||||||||||||||||||||||
| 375 | identical to that of the "p" tag defined above. If absent, the | ||||||||||||||||||||||||||||||||||||||||||
| 376 | policy specified by the "p" tag MUST be applied for subdomains. | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | =head2 adkim | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | (plain-text; OPTIONAL, default is "r".) Indicates whether or | ||||||||||||||||||||||||||||||||||||||||||
| 381 | not strict DKIM identifier alignment is required by the Domain | ||||||||||||||||||||||||||||||||||||||||||
| 382 | Owner. If and only if the value of the string is "s", strict mode | ||||||||||||||||||||||||||||||||||||||||||
| 383 | is in use. See Section 4.3.1 for details. | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | =head2 aspf | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | (plain-text; OPTIONAL, default is "r".) Indicates whether or | ||||||||||||||||||||||||||||||||||||||||||
| 388 | not strict SPF identifier alignment is required by the Domain | ||||||||||||||||||||||||||||||||||||||||||
| 389 | Owner. If and only if the value of the string is "s", strict mode | ||||||||||||||||||||||||||||||||||||||||||
| 390 | is in use. See Section 4.3.2 for details. | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | =head2 fo | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | Failure reporting options (plain-text; OPTIONAL, default "0")) | ||||||||||||||||||||||||||||||||||||||||||
| 395 | Provides requested options for generation of failure reports. | ||||||||||||||||||||||||||||||||||||||||||
| 396 | Report generators MAY choose to adhere to the requested options. | ||||||||||||||||||||||||||||||||||||||||||
| 397 | This tag's content MUST be ignored if a "ruf" tag (below) is not | ||||||||||||||||||||||||||||||||||||||||||
| 398 | also specified. The value of this tag is a colon-separated list | ||||||||||||||||||||||||||||||||||||||||||
| 399 | of characters that indicate failure reporting options as follows: | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0: Generate a DMARC failure report if all underlying | ||||||||||||||||||||||||||||||||||||||||||
| 402 | authentication mechanisms failed to produce an aligned "pass" | ||||||||||||||||||||||||||||||||||||||||||
| 403 | result. | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 1: Generate a DMARC failure report if any underlying | ||||||||||||||||||||||||||||||||||||||||||
| 406 | authentication mechanism failed to produce an aligned "pass" | ||||||||||||||||||||||||||||||||||||||||||
| 407 | result. | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | d: Generate a DKIM failure report if the message had a signature | ||||||||||||||||||||||||||||||||||||||||||
| 410 | that failed evaluation, regardless of its alignment. DKIM- | ||||||||||||||||||||||||||||||||||||||||||
| 411 | specific reporting is described in [AFRF-DKIM]. | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | s: Generate an SPF failure report if the message failed SPF | ||||||||||||||||||||||||||||||||||||||||||
| 414 | evaluation, regardless of its alignment. SPF-specific | ||||||||||||||||||||||||||||||||||||||||||
| 415 | reporting is described in [AFRF-SPF]. | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | =head2 rua | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | Addresses to which aggregate feedback is to be sent (comma- | ||||||||||||||||||||||||||||||||||||||||||
| 420 | separated plain-text list of DMARC URIs; OPTIONAL). {R11} A comma | ||||||||||||||||||||||||||||||||||||||||||
| 421 | or exclamation point that is part of such a DMARC URI MUST be | ||||||||||||||||||||||||||||||||||||||||||
| 422 | encoded per Section 2.1 of [URI] so as to distinguish it from the | ||||||||||||||||||||||||||||||||||||||||||
| 423 | list delimiter or an OPTIONAL size limit. Section 8.2 discusses | ||||||||||||||||||||||||||||||||||||||||||
| 424 | considerations that apply when the domain name of a URI differs | ||||||||||||||||||||||||||||||||||||||||||
| 425 | from that of the domain advertising the policy. See Section 15.6 | ||||||||||||||||||||||||||||||||||||||||||
| 426 | for additional considerations. Any valid URI can be specified. A | ||||||||||||||||||||||||||||||||||||||||||
| 427 | Mail Receiver MUST implement support for a "mailto:" URI, i.e. the | ||||||||||||||||||||||||||||||||||||||||||
| 428 | ability to send a DMARC report via electronic mail. If not | ||||||||||||||||||||||||||||||||||||||||||
| 429 | provided, Mail Receivers MUST NOT generate aggregate feedback | ||||||||||||||||||||||||||||||||||||||||||
| 430 | reports. URIs not supported by Mail Receivers MUST be ignored. | ||||||||||||||||||||||||||||||||||||||||||
| 431 | The aggregate feedback report format is described in Section 8.3. | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | =head2 ruf | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | Addresses to which message-specific failure information is to | ||||||||||||||||||||||||||||||||||||||||||
| 436 | be reported (comma-separated plain-text list of DMARC URIs; | ||||||||||||||||||||||||||||||||||||||||||
| 437 | OPTIONAL). {R11} If present, the Domain Owner is requesting Mail | ||||||||||||||||||||||||||||||||||||||||||
| 438 | Receivers to send detailed failure reports about messages that | ||||||||||||||||||||||||||||||||||||||||||
| 439 | fail the DMARC evaluation in specific ways (see the "fo" tag | ||||||||||||||||||||||||||||||||||||||||||
| 440 | above). The format of the message to be generated MUST follow | ||||||||||||||||||||||||||||||||||||||||||
| 441 | that specified in the "rf" tag. Section 8.2 discusses | ||||||||||||||||||||||||||||||||||||||||||
| 442 | considerations that apply when the domain name of a URI differs | ||||||||||||||||||||||||||||||||||||||||||
| 443 | from that of the domain advertising the policy. A Mail Receiver | ||||||||||||||||||||||||||||||||||||||||||
| 444 | MUST implement support for a "mailto:" URI, i.e. the ability to | ||||||||||||||||||||||||||||||||||||||||||
| 445 | send a DMARC report via electronic mail. If not provided, Mail | ||||||||||||||||||||||||||||||||||||||||||
| 446 | Receivers MUST NOT generate failure reports. See Section 15.6 for | ||||||||||||||||||||||||||||||||||||||||||
| 447 | additional considerations. | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | =head2 rf | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | B<Deprecated in DMARCbis (RFC 9989).> This tag MUST be ignored; it is documented here for historical reference only. | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | Format to be used for message-specific failure reports (comma- | ||||||||||||||||||||||||||||||||||||||||||
| 454 | separated plain-text list of values; OPTIONAL; default "afrf"). | ||||||||||||||||||||||||||||||||||||||||||
| 455 | The value of this tag is a list of one or more report formats as | ||||||||||||||||||||||||||||||||||||||||||
| 456 | requested by the Domain Owner to be used when a message fails both | ||||||||||||||||||||||||||||||||||||||||||
| 457 | [SPF] and [DKIM] tests to report details of the individual | ||||||||||||||||||||||||||||||||||||||||||
| 458 | failure. The values MUST be present in the registry of reporting | ||||||||||||||||||||||||||||||||||||||||||
| 459 | formats defined in Section 14; a Mail Receiver observing a | ||||||||||||||||||||||||||||||||||||||||||
| 460 | different value SHOULD ignore it, or MAY ignore the entire DMARC | ||||||||||||||||||||||||||||||||||||||||||
| 461 | record. Initial default values are "afrf" (defined in [AFRF]) and | ||||||||||||||||||||||||||||||||||||||||||
| 462 | "iodef" (defined in [IODEF]). See Section 8.4 for details. | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | =head2 ri | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | B<Deprecated in DMARCbis (RFC 9989).> This tag MUST be ignored; it is documented here for historical reference only. | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | Interval requested between aggregate reports (plain-text, 32-bit | ||||||||||||||||||||||||||||||||||||||||||
| 469 | unsigned integer; OPTIONAL; default 86400). {R14} Indicates a | ||||||||||||||||||||||||||||||||||||||||||
| 470 | request to Receivers to generate aggregate reports separated by no | ||||||||||||||||||||||||||||||||||||||||||
| 471 | more than the requested number of seconds. DMARC implementations | ||||||||||||||||||||||||||||||||||||||||||
| 472 | MUST be able to provide daily reports and SHOULD be able to | ||||||||||||||||||||||||||||||||||||||||||
| 473 | provide hourly reports when requested. However, anything other | ||||||||||||||||||||||||||||||||||||||||||
| 474 | than a daily report is understood to be accommodated on a best- | ||||||||||||||||||||||||||||||||||||||||||
| 475 | effort basis. | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | =head2 pct | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | B<Deprecated in DMARCbis (RFC 9989).> This tag MUST be ignored; it is documented here for historical reference only. | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | (plain-text integer between 0 and 100, inclusive; OPTIONAL; | ||||||||||||||||||||||||||||||||||||||||||
| 482 | default is 100). {R8} Percentage of messages from the DNS domain's | ||||||||||||||||||||||||||||||||||||||||||
| 483 | mail stream to which the DMARC mechanism is to be applied. | ||||||||||||||||||||||||||||||||||||||||||
| 484 | However, this MUST NOT be applied to the DMARC-generated reports, | ||||||||||||||||||||||||||||||||||||||||||
| 485 | all of which must be sent and received unhindered. The purpose of | ||||||||||||||||||||||||||||||||||||||||||
| 486 | the "pct" tag is to allow Domain Owners to enact a slow rollout | ||||||||||||||||||||||||||||||||||||||||||
| 487 | enforcement of the DMARC mechanism. The prospect of "all or | ||||||||||||||||||||||||||||||||||||||||||
| 488 | nothing" is recognized as preventing many organizations from | ||||||||||||||||||||||||||||||||||||||||||
| 489 | experimenting with strong authentication-based mechanisms. See | ||||||||||||||||||||||||||||||||||||||||||
| 490 | Section 7.1 for details. | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | Matt Simerson <msimerson@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | Davide Migliavacca <shari@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | Marc Bradshaw <marc@marcbradshaw.net> | ||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | This software is copyright (c) 2026 by Matt Simerson. | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 515 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | =cut | ||||||||||||||||||||||||||||||||||||||||||