line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DMARC::Report::Aggregate::Record::Auth_Results::SPF; |
2
|
|
|
|
|
|
|
our $VERSION = '1.20210927'; |
3
|
13
|
|
|
13
|
|
258
|
use strict; |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
394
|
|
4
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
71
|
use Carp; |
|
13
|
|
|
|
|
37
|
|
|
13
|
|
|
|
|
741
|
|
6
|
13
|
|
|
13
|
|
564
|
use parent 'Mail::DMARC::Base'; |
|
13
|
|
|
|
|
378
|
|
|
13
|
|
|
|
|
93
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
64
|
|
|
64
|
0
|
176
|
my ( $class, @args ) = @_; |
10
|
|
|
|
|
|
|
|
11
|
64
|
|
|
|
|
156
|
my $self = bless {}, $class; |
12
|
|
|
|
|
|
|
|
13
|
64
|
50
|
|
|
|
178
|
if (0 == scalar @args) { |
14
|
0
|
|
|
|
|
0
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# a bare hash |
18
|
64
|
100
|
|
|
|
174
|
return $self->_from_hash(@args) if scalar @args > 1; |
19
|
|
|
|
|
|
|
|
20
|
57
|
|
|
|
|
107
|
my $spf = shift @args; |
21
|
57
|
100
|
|
|
|
211
|
return $spf if ref $spf eq $class; |
22
|
|
|
|
|
|
|
|
23
|
47
|
50
|
|
|
|
175
|
return $self->_from_hashref($spf) if 'HASH' eq ref $spf; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
croak "invalid spf argument"; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub domain { |
29
|
53
|
50
|
|
53
|
0
|
152
|
return $_[0]->{domain} if 1 == scalar @_; |
30
|
53
|
|
|
|
|
137
|
return $_[0]->{domain} = $_[1]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub result { |
34
|
53
|
50
|
|
53
|
0
|
137
|
return $_[0]->{result} if 1 == scalar @_; |
35
|
53
|
50
|
|
|
|
189
|
croak if !$_[0]->is_valid_spf_result( $_[1] ); |
36
|
53
|
|
|
|
|
155
|
return $_[0]->{result} = $_[1]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub scope { |
40
|
53
|
50
|
|
53
|
0
|
133
|
return $_[0]->{scope} if 1 == scalar @_; |
41
|
53
|
50
|
|
|
|
202
|
croak if ! $_[0]->is_valid_spf_scope( $_[1] ); |
42
|
53
|
|
|
|
|
169
|
return $_[0]->{scope} = $_[1]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _from_hash { |
46
|
54
|
|
|
54
|
|
210
|
my ($self, %args) = @_; |
47
|
|
|
|
|
|
|
|
48
|
54
|
|
|
|
|
163
|
foreach my $key ( keys %args ) { |
49
|
|
|
|
|
|
|
# scope is frequently absent on received reports |
50
|
160
|
50
|
66
|
|
|
471
|
next if ($key eq 'scope' && !$args{$key}); |
51
|
160
|
|
|
|
|
453
|
$self->$key( $args{$key} ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
53
|
|
|
|
|
170
|
$self->is_valid; |
55
|
53
|
|
|
|
|
223
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _from_hashref { |
59
|
47
|
|
|
47
|
|
106
|
return $_[0]->_from_hash(%{ $_[1] }); |
|
47
|
|
|
|
|
206
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub is_valid { |
63
|
53
|
|
|
53
|
0
|
90
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
53
|
|
|
|
|
113
|
foreach my $f (qw/ domain result scope /) { |
66
|
159
|
50
|
|
|
|
345
|
next if $self->{$f}; |
67
|
0
|
0
|
|
|
|
0
|
if ($f ne 'scope') { |
68
|
|
|
|
|
|
|
# quite a few DMARC reporters don't include scope |
69
|
0
|
|
|
|
|
0
|
warn "SPF $f is required but missing!\n"; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
0
|
return 0; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
53
|
50
|
66
|
|
|
396
|
if ( $self->{result} =~ /^pass$/i && !$self->{domain} ) { |
75
|
0
|
|
|
|
|
0
|
warn "SPF pass MUST include the RFC5321.MailFrom domain!\n"; |
76
|
0
|
|
|
|
|
0
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
53
|
|
|
|
|
104
|
return 1; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |