| 1 | package Mail::Milter::Authentication::Handler::DMARC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 42 | ▶ | use 5.20.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 42 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 42 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 42 | ▶ | use Mail::Milter::Authentication::Pragmas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Handler class for DMARC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 42 | our $VERSION = '4.20261116'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 42 | ▶ | use base 'Mail::Milter::Authentication::Handler'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 42 | ▶ | use List::MoreUtils qw{ uniq }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 42 | ▶ | use List::Util qw{ min }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 42 | ▶ | use Email::Address::XS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 42 | ▶ | use Mail::DMARC::PurePerl 1.20160612; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 42 | ▶ | use Net::IP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 42 | my $PSL_CHECKED_TIME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub default_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | 'hide_none' => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 'use_arc' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 'hard_reject' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 'no_list_reject' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 'arc_before_list' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 'whitelisted' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 'policy_rbl_lookup' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 'detect_list_id' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 'report_skip_to' => [ 'my_report_from_address@example.com' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 'report_suppression_list' => 'rbl.example.com', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 'report_suppression_email_list' => 'rbl.example.com', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 'no_report' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 'hide_report_to' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 'config_file' => '/etc/mail-dmarc.ini', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 'no_reject_disposition' => 'quarantine', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 'no_list_reject_disposition' => 'none', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 'reject_on_multifrom' => 30, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 'quarantine_on_multifrom' => 20, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 'skip_on_multifrom' => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 'strict_multifrom' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | sub grafana_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grafana_rows: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | my @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | push @rows, $self->get_json( 'DMARC_metrics' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | return \@rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 270 | ▶ | sub is_whitelisted { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_whitelisted: called CC=26 SCAR=51.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 270 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 270 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 270 | ▶ | return 0 if not exists( $config->{'whitelisted'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 8 | my $ip_obj = $top_handler->{'ip_object'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 8 | my $whitelisted = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | foreach my $entry ( @{ $config->{'whitelisted'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # This does not consider dkim/spf results added by a passing arc chain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # we consider this out of scope at this point. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 10 | ▶ | if ( $entry =~ /^dnswl:/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my ( $dummy, $type, $rbl ) = split( /:/, $entry, 3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( $type eq 'spf' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $spf = $self->get_handler('SPF'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( $spf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $got_spf_result = $spf->{'dmarc_result'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( $got_spf_result eq 'pass' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $got_spf_domain = $spf->{'dmarc_domain'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ( $self->rbl_check_domain( $got_spf_domain, $rbl ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->dbgout( 'DMARCReject', "Whitelist hit " . $entry, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $whitelisted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | elsif ( $type eq 'dkim' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $dkim_handler = $self->get_handler('DKIM'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | foreach my $dkim_domain( sort keys %{ $dkim_handler->{'valid_domains'}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( $self->rbl_check_domain( $dkim_domain, $rbl ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $self->dbgout( 'DMARCReject', "Whitelist hit " . $entry, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $whitelisted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | elsif ( $type eq 'ip' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ( $self->rbl_check_ip( $ip_obj, $rbl ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->dbgout( 'DMARCReject', "Whitelist hit " . $entry, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $whitelisted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | elsif ( $entry =~ /^dkim:/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | my ( $dummy, $dkim_domain ) = split( /:/, $entry, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | my $dkim_handler = $self->get_handler('DKIM'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | if ( exists( $dkim_handler->{'valid_domains'}->{ lc $dkim_domain } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | $self->dbgout( 'DMARCReject', "Whitelist hit " . $entry, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | $whitelisted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif ( $entry =~ /^spf:/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my ( $dummy, $spf_domain ) = split( /:/, $entry, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $spf = $self->get_handler('SPF'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ( $spf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $got_spf_result = $spf->{'dmarc_result'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ( $got_spf_result eq 'pass' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $got_spf_domain = $spf->{'dmarc_domain'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ( lc $got_spf_domain eq lc $spf_domain ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $self->dbgout( 'DMARCReject', "Whitelist hit " . $entry, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $whitelisted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 8 | my $whitelisted_obj = Net::IP->new($entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 8 | ▶ | if ( !$whitelisted_obj ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $self->log_error( 'DMARC: Could not parse whitelist IP '.$entry ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 8 | ▶ | my $is_overlap = $ip_obj->overlaps($whitelisted_obj) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ip_obj->overlaps($whitelisted_obj) || 0
MC/DC100%1/1
$ip_obj->overlaps($whitelisted_obj) || 0
$ip_obj->overlaps($whitelisted_obj)
Truth table100%2/2
A
A= $ip_obj->overlaps($whitelisted_obj)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 8 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_A_IN_B_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_B_IN_A_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_PARTIAL_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_IDENTICAL
$is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_A_IN_B_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_B_IN_A_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_PARTIAL_OVERLAP
$is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_A_IN_B_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_B_IN_A_OVERLAP
MC/DC25%1/4
$is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_A_IN_B_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_B_IN_A_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_PARTIAL_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_IDENTICAL
$is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_A_IN_B_OVERLAP
$is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_B_IN_A_OVERLAP
$is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_PARTIAL_OVERLAP
$is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_IDENTICAL
Truth table40%2/5
A or B or C or D
A= $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_A_IN_B_OVERLAPB= $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_B_IN_A_OVERLAPC= $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_PARTIAL_OVERLAPD= $is_overlap == $Mail::Milter::Authentication::Handler::DMARC::IP_IDENTICAL
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | $is_overlap == $IP_A_IN_B_OVERLAP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | || $is_overlap == $IP_B_IN_A_OVERLAP # Should never happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | || $is_overlap == $IP_PARTIAL_OVERLAP # Should never happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | || $is_overlap == $IP_IDENTICAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | $self->dbgout( 'DMARCReject', "Whitelist hit " . $entry, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | $whitelisted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 10 | ▶ | return $whitelisted if $whitelisted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | return $whitelisted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 64 | ▶ | sub pre_loop_setup { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pre_loop_setup: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 64 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 64 | $PSL_CHECKED_TIME = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 64 | my $dmarc = Mail::DMARC::PurePerl->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 64 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 64 | ▶ | if ( exists ( $config->{ 'config_file' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | $self->log_error( 'DMARC config file does not exist' ) if ! -e $config->{ 'config_file' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | $dmarc->config( $config->{ 'config_file' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 64 | my $psl = eval { $dmarc->get_public_suffix_list(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 64 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 64 | ▶ | if ( $psl ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 64 | $self->{'thischild'}->loginfo( 'DMARC Preloaded PSL' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $self->{'thischild'}->logerror( 'DMARC Could not preload PSL' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 31 | ▶ | sub pre_fork_setup { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pre_fork_setup: called CC=6 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 31 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 31 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 31 | my $dmarc = Mail::DMARC::PurePerl->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 31 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 31 | ▶ | if ( exists ( $config->{ 'config_file' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | $self->log_error( 'DMARC config file does not exist' ) if ! -e $config->{ 'config_file' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $dmarc->config( $config->{ 'config_file' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 31 | my $check_time = 60*10; # Check no more often than every 10 minutes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 31 | ▶ | if ( $now > $PSL_CHECKED_TIME + $check_time ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $PSL_CHECKED_TIME = $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if ( $dmarc->can( 'check_public_suffix_list' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ( $dmarc->check_public_suffix_list() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->{'thischild'}->loginfo( 'DMARC PSL file has changed and has been reloaded' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $self->{'thischild'}->loginfo( 'DMARC PSL file has not changed since last loaded' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->{'thischild'}->loginfo( 'DMARC PSL file update checking not available' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 64 | ▶ | sub register_metrics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_metrics: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 64 | 'dmarc_total' => 'The number of emails processed for DMARC', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 'dmarc_reports_total' => { type => 'gauge', help => 'The number of pending DMARC reports' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 10 | ▶ | sub metrics_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
metrics_callback: called CC=2 SCAR=8.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 10 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 10 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 10 | ▶ | return if $config->{'no_report'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 10 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 10 | my $time = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 10 | my $backend = Mail::DMARC::Report::Store->new()->backend; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $current = $backend->query("SELECT COUNT(1) AS c FROM report WHERE end >= $time")->[0]->{c}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $pending = $backend->query("SELECT COUNT(1) AS c FROM report WHERE end < $time")->[0]->{c}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $self->metric_set( 'dmarc_reports_total', { 'state' => 'current' }, $current ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $self->metric_set( 'dmarc_reports_total', { 'state' => 'pending' }, $pending ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | ▶ | sub _process_arc_dmarc_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_arc_dmarc_for: called CC=16 SCAR=33.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | my ( $self, $env_domain_from, $header_domain ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | my $original_dmarc = $self->get_object('dmarc'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | my $dmarc = $self->new_dmarc_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | $dmarc->source_ip( $self->ip_address() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Set the DMARC Envelope From Domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | ▶ | if ( $env_domain_from ne q{} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | $dmarc->envelope_from( $env_domain_from ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->set_object('dmarc', $original_dmarc,1 ); # Restore original saved DMARC object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # Add the Envelope To | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | ▶ | unless ( $config->{'hide_report_to'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | $dmarc->envelope_to( lc $self->get_domain_from( $self->{'env_to'} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # Add the From Header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | eval { $dmarc->header_from( $header_domain ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->set_object('dmarc', $original_dmarc,1 ); # Restore original saved DMARC object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # Add the SPF Results Object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | my $spf = $self->get_handler('SPF'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | if ( $spf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | ▶ | if ( $spf->{'spfu_detected' } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # We detected a possible SPF upgrade, do not trust any SPF results for re-evaluation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $dmarc->{'spf'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | ▶ | elsif ( $spf->{'dmarc_result'} eq 'pass' && lc $spf->{'dmarc_domain'} eq lc $header_domain ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$spf->{"dmarc_result"} eq "pass" and lc $spf->{"dmarc_domain"} eq lc $header_domain
MC/DC0%0/2
$spf->{"dmarc_result"} eq "pass" and lc $spf->{"dmarc_domain"} eq lc $header_domain
$spf->{"dmarc_result"} eq "pass"
lc $spf->{"dmarc_domain"} eq lc $header_domain
Truth table33%1/3
A and B
A= $spf->{"dmarc_result"} eq "pass"B= lc $spf->{"dmarc_domain"} eq lc $header_domain
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # Have a matching local entry, use it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ## TODO take org domains into consideration here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | $dmarc->spf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 'domain' => $spf->{'dmarc_domain'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 'scope' => $spf->{'dmarc_scope'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | 'result' => $spf->{'dmarc_result'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | elsif ( my $arc_spf = $self->get_handler('ARC')->get_trusted_spf_results() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # Pull from ARC if we can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | push @$arc_spf, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 'domain' => $spf->{'dmarc_domain'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 'scope' => $spf->{'dmarc_scope'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | 'result' => $spf->{'dmarc_result'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | $dmarc->spf( $arc_spf ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # Nothing else matched, use the local entry anyway | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | $dmarc->spf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 'domain' => $spf->{'dmarc_domain'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 'scope' => $spf->{'dmarc_scope'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | 'result' => $spf->{'dmarc_result'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $dmarc->{'spf'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 2 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $dmarc->{'spf'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # Add the DKIM Results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | my $dkim_handler = $self->get_handler('DKIM'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | my @dkim_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | my $arc_values = $self->get_handler('ARC')->get_trusted_dkim_results(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | ▶ | if ( $arc_values ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | foreach my $arc_value ( @$arc_values ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | push @dkim_values, $arc_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 2 | $dmarc->{'dkim'} = \@dkim_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # Add the local DKIM object is it exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | ▶ | if ( $dkim_handler->{'has_dkim'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $dkim_object = $self->get_object('dkim'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if ( $dkim_object ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $dmarc->dkim( $dkim_object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # Run the Validator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 2 | my $dmarc_result = $dmarc->validate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | return $dmarc_result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 281 | ▶ | sub _process_dmarc_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_dmarc_for: called CC=96 SCAR=56.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 281 | my ( $self, $env_domain_from, $header_domain ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 281 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 281 | ▶ | if ( exists $self->{'processed'}->{ "$env_domain_from $header_domain" } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $self->log_error( "DMARC already processed for $env_domain_from $header_domain" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 281 | $self->{'processed'}->{ "$env_domain_from $header_domain" } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # Get a fresh DMARC object each time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 281 | $self->destroy_object('dmarc'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 281 | my $dmarc = $self->get_dmarc_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 281 | $dmarc->source_ip( $self->ip_address() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # Set the DMARC Envelope From Domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 281 | ▶ | if ( $env_domain_from ne q{} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 272 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 272 | $dmarc->envelope_from( $env_domain_from ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 272 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $self->log_error( 'DMARC Mail From Error for <' . $env_domain_from . '> ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # Add the Envelope To | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 281 | ▶ | unless ( $config->{'hide_report_to'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 281 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 281 | $dmarc->envelope_to( lc $self->get_domain_from( $self->{'env_to'} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 281 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $self->log_error( 'DMARC Rcpt To Error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # Add the From Header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 281 | eval { $dmarc->header_from( $header_domain ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 281 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 11 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 11 | $self->log_error( 'DMARC Header From Error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 11 | $self->metric_count( 'dmarc_total', { 'result' => 'permerror' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 11 | my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'dmarc' )->safe_set_value( 'permerror' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 11 | $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'from header invalid' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 11 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.from' )->safe_set_value( $header_domain ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 11 | $self->_add_dmarc_header( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 11 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 270 | my $have_arc = ( $self->is_handler_loaded( 'ARC' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 270 | ▶ | if ( $have_arc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # Does our ARC handler have the necessary methods? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 11 | ▶ | $have_arc = 0 unless $self->get_handler('ARC')->can( 'get_trusted_arc_authentication_results' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 270 | ▶ | $have_arc = 0 if ! $config->{ 'use_arc' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # Add the SPF Results Object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 270 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 270 | my $spf = $self->get_handler('SPF'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 270 | ▶ | if ( $spf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | $dmarc->spf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 'domain' => $spf->{'dmarc_domain'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 'scope' => $spf->{'dmarc_scope'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 270 | 'result' => $spf->{'dmarc_result'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $dmarc->{'spf'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 270 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $self->log_error( 'DMARC SPF Error: ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $dmarc->{'spf'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # Add the DKIM Results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 270 | my $dkim_handler = $self->get_handler('DKIM'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 270 | ▶ | if ( $dkim_handler->{'failmode'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $dmarc->{'dkim'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | elsif ( $dkim_handler->{'has_dkim'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 43 | my $dkim_object = $self->get_object('dkim'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 43 | ▶ | if ( $dkim_object ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 43 | $dmarc->dkim( $dkim_object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $dmarc->{'dkim'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 227 | $dmarc->{'dkim'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # Run the Validator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 270 | my $dmarc_result = $dmarc->validate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 270 | my $is_subdomain = $dmarc->is_subdomain(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 270 | $self->set_object('dmarc_result', $dmarc_result, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 270 | my $dmarc_results = $self->get_object('dmarc_results'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 270 | ▶ | $dmarc_results = [] if ! $dmarc_results; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 270 | push @$dmarc_results, $dmarc_result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 270 | $self->set_object('dmarc_results',$dmarc_results,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 270 | my $dmarc_code = $dmarc_result->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 270 | $self->dbgout( 'DMARCCode', $dmarc_code, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # Work around Mail::DMARC::PurePerl returning 'none' instead of 'permerror' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # when multiple DMARC records are found (RFC 7489 Section 6.6.3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 270 | ▶ | if ( my $reasons = $dmarc_result->reason ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 270 | for my $reason ( @$reasons ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 174 | ▶ | if ( ( $reason->comment // '' ) eq 'too many policies' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$reason->comment // ""
MC/DC0%0/1
$reason->comment // ""
$reason->comment
Truth table50%1/2
A
A= $reason->comment
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $self->log_error( 'DMARC permerror: multiple DMARC records found for ' . $header_domain ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $self->metric_count( 'dmarc_total', { 'result' => 'permerror' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'dmarc' )->safe_set_value( 'permerror' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'multiple DMARC records' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.from' )->safe_set_value( $header_domain ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $self->_add_dmarc_header( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 270 | my $dmarc_disposition = eval { $dmarc_result->disposition() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 270 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | if ( $dmarc_code ne 'pass' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $self->log_error( 'DMARCPolicyError ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 270 | $self->dbgout( 'DMARCDisposition', $dmarc_disposition, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 270 | my $dmarc_disposition_evaluated = $dmarc_disposition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 270 | ▶ | $self->dbgout( 'DMARCSubdomain', $is_subdomain ? 'yes' : 'no', LOG_DEBUG ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 270 | my $dmarc_policy = eval{ $dmarc_result->published()->p(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 270 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # If we didn't get a result, set to none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 270 | ▶ | $dmarc_policy = 'none' if ! $dmarc_policy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 270 | my $dmarc_sub_policy = eval{ $dmarc_result->published()->sp(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 270 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # If we didn't get a result, set to none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 270 | ▶ | $dmarc_sub_policy = 'default' if ! $dmarc_sub_policy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 270 | $self->dbgout( 'DMARCPolicy', "$dmarc_policy $dmarc_sub_policy", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 270 | my $policy_override; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 270 | my $arc_aware_result = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # Re-evaluate non passes taking ARC into account if possible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 270 | ▶ | if ( $have_arc && $dmarc_code eq 'fail' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$have_arc and $dmarc_code eq "fail"
MC/DC100%2/2
$have_arc and $dmarc_code eq "fail"
$have_arc
$dmarc_code eq "fail"
Truth table100%3/3
A and B
A= $have_arcB= $dmarc_code eq "fail"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 2 | my $arc_result = $self->_process_arc_dmarc_for( $env_domain_from, $header_domain ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 2 | $arc_aware_result = eval{$arc_result->result}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 2 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | ▶ | $arc_aware_result = '' if not defined $arc_aware_result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 270 | my $have_arc_dmarc_pass = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 270 | ▶ | if ( $have_arc && $dmarc_code eq 'fail' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$have_arc and $dmarc_code eq "fail"
MC/DC100%2/2
$have_arc and $dmarc_code eq "fail"
$have_arc
$dmarc_code eq "fail"
Truth table100%3/3
A and B
A= $have_arcB= $dmarc_code eq "fail"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 2 | ▶ | if (my $arc_dmarc_results = $self->get_handler('ARC')->get_trusted_dmarc_results() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | for my $arc_dmarc_result ($arc_dmarc_results->@*) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | next unless $arc_dmarc_result->{result} eq 'pass'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $have_arc_dmarc_pass = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # Re-evaluate in the case of detected SPF upgrade | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 270 | my $spfu_mitigation_triggered = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 270 | my $spfu_mitigation = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 270 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 270 | my $spf = $self->get_handler('SPF'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 270 | ▶ | if ( $spf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 270 | $spfu_mitigation = $spf->{'dmarc_spfu_downgrade'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 270 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 270 | ▶ | if ( $dmarc_code eq 'pass' && $spfu_mitigation ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$dmarc_code eq "pass" and $spfu_mitigation
MC/DC100%2/2
$dmarc_code eq "pass" and $spfu_mitigation
$dmarc_code eq "pass"
$spfu_mitigation
Truth table100%3/3
A and B
A= $dmarc_code eq "pass"B= $spfu_mitigation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # We have a pass, and also detected a possible spfu attack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # and we are configured to mitigate such attacks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # save the original dmarc object so we can reinstate it when done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 6 | my $original_dmarc = $self->get_object('dmarc'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 6 | my $spf_dmarc = $self->new_dmarc_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 6 | $spf_dmarc->source_ip( $self->ip_address() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 6 | ▶ | if ( $env_domain_from ne q{} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 6 | eval { $spf_dmarc->envelope_from( $env_domain_from ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 6 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 6 | eval { $spf_dmarc->header_from( $header_domain ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 6 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 6 | $spf_dmarc->{'spf'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 6 | my $dkim_handler = $self->get_handler('DKIM'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 6 | ▶ | if ( $dkim_handler->{'failmode'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $spf_dmarc->{'dkim'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } elsif ( $dkim_handler->{'has_dkim'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $dkim_object = $self->get_object('dkim'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | if ( $dkim_object ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $spf_dmarc->dkim( $dkim_object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $spf_dmarc->{'dkim'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 6 | $spf_dmarc->{'dkim'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 6 | my $spfu_result = $spf_dmarc->validate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 6 | ▶ | if ( $spfu_result->result ne 'pass' && $dmarc_disposition ne $spfu_result->disposition ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$spfu_result->result ne "pass" and $dmarc_disposition ne $spfu_result->disposition
MC/DC0%0/2
$spfu_result->result ne "pass" and $dmarc_disposition ne $spfu_result->disposition
$spfu_result->result ne "pass"
$dmarc_disposition ne $spfu_result->disposition
Truth table33%1/3
A and B
A= $spfu_result->result ne "pass"B= $dmarc_disposition ne $spfu_result->disposition
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # spfu mitigation has changed the resulting disposition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 6 | $self->dbgout( 'DMARCReject', "Policy downgraded by spfu mitigation", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 6 | $dmarc_disposition = $spfu_result->disposition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 6 | $policy_override = 'local_policy'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 6 | $dmarc_result->reason( 'type' => $policy_override, 'comment' => 'Policy downgraded due to SPF upgrade mitigation' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # Note, this may be overridden further below, for example, local policy reject->quarantine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | # Reporting of DMARC overrides is not rich enough to support all cases, so we do the best we can. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 6 | $dmarc_result->disposition($dmarc_disposition); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 6 | $spfu_mitigation_triggered = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 6 | $self->set_object('dmarc', $original_dmarc,1 ); # Restore original saved DMARC object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 270 | my $is_whitelisted = $self->is_whitelisted(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # Reject mail and/or set policy override reasons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 270 | ▶ | if ( $dmarc_code eq 'fail' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | # Policy override decisions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 40 | ▶ | if ( $arc_aware_result eq 'pass' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 1 | $dmarc_result->disposition('none'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 1 | $dmarc_disposition = 'none'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 1 | my $comment = 'Policy overriden using trusted ARC chain'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # arc=pass as[2].d=d2.example as[2].s=s2 as[1].d=d1.example as[1].s=s3 remote-ip[1]=2001:DB8::1A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | my $arc_object = $self->get_object('arc'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | my $arc_signatures = $arc_object->{'signatures'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 1 | my $arc_handler = $self->get_handler('ARC'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 1 | ▶ | if ( $arc_handler ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | ▶ | if ( $arc_handler->{ 'arc_result' } eq 'pass' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # If it wasn't a pass then we wouldn't be in here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 1 | $comment = 'arc=pass'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | my $arc_auth_results = $arc_handler->{'arc_auth_results'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | foreach my $instance ( reverse sort { $a <=> $b } keys %$arc_auth_results ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 1 | my $domain = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 1 | my $selector = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 1 | my $remote_ip = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | foreach my $signature ( @$arc_signatures ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | ▶ | next if $signature->instance() ne $instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | $domain = $signature->domain(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 2 | $selector = $signature->selector(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 1 | my $aar = $arc_auth_results->{$instance}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 1 | $remote_ip = eval{ $aar->search({ 'isa' => 'entry', 'key' => 'iprev' })->children()->[0]->search({ 'isa' => 'subentry', 'key' => 'smtp.remote-ip'})->children()->[0]->value(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | ▶ | $remote_ip //= eval{ $aar->search({ 'isa' => 'entry', 'key' => 'iprev' })->children()->[0]->search({ 'isa' => 'subentry', 'key' => 'policy.iprev'})->children()->[0]->value(); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$remote_ip //= eval {
do {
$aar->search({"isa", "entry", "key", "iprev"})->children->[0]->search({"isa", "subentry", "key", "policy.iprev"})->children->[0]->value
}
}
MC/DC0%0/2
$remote_ip //= eval {
do {
$aar->search({"isa", "entry", "key", "iprev"})->children->[0]->search({"isa", "subentry", "key", "policy.iprev"})->children->[0]->value
}
}
$remote_ip
eval {
do {
$aar->search({"isa", "entry", "key", "iprev"})->children->[0]->search({"isa", "subentry", "key", "policy.iprev"})->children->[0]->value
}
}
Truth table33%1/3
A //= B
A= $remote_ipB= eval {
do {
$aar->search({"isa", "entry", "key", "iprev"})->children->[0]->search({"isa", "subentry", "key", "policy.iprev"})->children->[0]->value
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 1 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1 | ▶ | $domain //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$domain //= ""
MC/DC0%0/1
$domain //= ""
$domain
Truth table50%1/2
A
A= $domain
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 1 | ▶ | $selector //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$selector //= ""
MC/DC0%0/1
$selector //= ""
$selector
Truth table50%1/2
A
A= $selector
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 1 | ▶ | $remote_ip //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$remote_ip //= ""
MC/DC0%0/1
$remote_ip //= ""
$remote_ip
Truth table50%1/2
A
A= $remote_ip
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 1 | $comment .= ' as['.$instance.'].d='.$domain.' as['.$instance.'].s='.$selector.' remote-ip['.$instance.']='.$remote_ip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | $self->dbgout( 'DMARCReject', "Policy overridden using ARC Chain: $comment", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 1 | $dmarc_result->reason( 'type' => 'local_policy', 'comment' => $comment ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | elsif ( $have_arc_dmarc_pass ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | $self->dbgout( 'DMARCReject', "Policy reject overridden by DMARC pass in trusted ARC chain", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $policy_override = 'trusted_forwarder'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $dmarc_result->reason( 'type' => $policy_override, 'comment' => 'Policy ignored due to DMARC pass in trusted ARC chain' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $dmarc_result->disposition('none'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $dmarc_disposition = 'none'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | elsif ( $is_whitelisted ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 4 | $self->dbgout( 'DMARCReject', "Policy reject overridden by whitelist", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 4 | $policy_override = 'trusted_forwarder'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 4 | $dmarc_result->reason( 'type' => $policy_override, 'comment' => 'Policy ignored due to local white list' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 4 | $dmarc_result->disposition('none'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 4 | $dmarc_disposition = 'none'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | ▶ | elsif ( $config->{'no_list_reject'} && $self->{'is_list'} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$config->{"no_list_reject"} and $self->{"is_list"}
MC/DC0%0/2
$config->{"no_list_reject"} and $self->{"is_list"}
$config->{"no_list_reject"}
$self->{"is_list"}
Truth table33%1/3
A and B
A= $config->{"no_list_reject"}B= $self->{"is_list"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | if ( $config->{'arc_before_list'} && $have_arc && $self->get_handler('ARC')->get_trusted_arc_authentication_results ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$config->{"arc_before_list"} and $have_arc and $self->get_handler("ARC")->get_trusted_arc_authentication_results
$config->{"arc_before_list"} and $have_arc
MC/DC0%0/3
$config->{"arc_before_list"} and $have_arc and $self->get_handler("ARC")->get_trusted_arc_authentication_results
$config->{"arc_before_list"}
$have_arc
$self->get_handler("ARC")->get_trusted_arc_authentication_results
Truth table0%0/4
A and B and C
A= $config->{"arc_before_list"}B= $have_arcC= $self->get_handler("ARC")->get_trusted_arc_authentication_results
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $self->dbgout( 'DMARCReject', "Policy reject not overridden for list mail with trusted ARC chain", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $self->dbgout( 'DMARCReject', "Policy reject overridden for list mail", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $policy_override = 'mailing_list'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $dmarc_result->reason( 'type' => $policy_override, 'comment' => 'Policy ignored due to local mailing list policy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | my $no_list_reject_disposition = $config->{ 'no_list_reject_disposition' } // 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->{"no_list_reject_disposition"} // "none"
MC/DC0%0/1
$config->{"no_list_reject_disposition"} // "none"
$config->{"no_list_reject_disposition"}
Truth table0%0/2
A
A= $config->{"no_list_reject_disposition"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $dmarc_result->disposition( $no_list_reject_disposition ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $dmarc_disposition = $no_list_reject_disposition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 40 | ▶ | if ( $dmarc_disposition eq 'reject' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 23 | ▶ | if ( $config->{'hard_reject'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 10 | $self->reject_mail( '550 5.7.0 DMARC policy violation' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 10 | $self->dbgout( 'DMARCReject', "Policy reject", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 13 | $policy_override = 'local_policy'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 13 | $dmarc_result->reason( 'type' => $policy_override, 'comment' => 'Reject ignored due to local policy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 13 | ▶ | my $no_reject_disposition = $config->{ 'no_reject_disposition' } // 'quarantine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"no_reject_disposition"} // "quarantine"
MC/DC0%0/1
$config->{"no_reject_disposition"} // "quarantine"
$config->{"no_reject_disposition"}
Truth table50%1/2
A
A= $config->{"no_reject_disposition"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 13 | $dmarc_result->disposition( $no_reject_disposition ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 13 | $dmarc_disposition = $no_reject_disposition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 270 | ▶ | if ($self->{strict_multifrom_disposition}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 11 | $self->dbgout( 'DMARCReject', "Policy downgraded by strict rfc5322 from checks", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 11 | $dmarc_disposition = $self->{strict_multifrom_disposition}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 11 | $policy_override = 'local_policy'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 11 | $dmarc_result->reason( 'type' => $policy_override, 'comment' => 'Policy downgraded due to multiple rfc5322 from entries' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 11 | $dmarc_result->disposition($dmarc_disposition); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 270 | ▶ | if ( $dmarc_disposition eq 'quarantine' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 19 | $self->quarantine_mail( 'Quarantined due to DMARC policy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # Add the AR Header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 270 | my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'dmarc' )->safe_set_value( $dmarc_code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # Do any RBL lookups | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 270 | ▶ | if ( $config->{'policy_rbl_lookup'} && ( $dmarc_code eq 'pass' || $arc_aware_result eq 'pass' )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$config->{"policy_rbl_lookup"} and $dmarc_code eq "pass" || $arc_aware_result eq "pass"
$dmarc_code eq "pass" or $arc_aware_result eq "pass"
MC/DC0%0/3
$config->{"policy_rbl_lookup"} and $dmarc_code eq "pass" || $arc_aware_result eq "pass"
$config->{"policy_rbl_lookup"}
$dmarc_code eq "pass"
$arc_aware_result eq "pass"
Truth table25%1/4
A and B or C
A= $config->{"policy_rbl_lookup"}B= $dmarc_code eq "pass"C= $arc_aware_result eq "pass"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | foreach my $rbl ( sort keys $config->{'policy_rbl_lookup'}->%* ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | my $rbl_data = $config->{'policy_rbl_lookup'}->{$rbl}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my $rbl_domain = $rbl_data->{'rbl'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $rbl_result = $self->rbl_check_domain( $header_domain, $rbl_domain ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | if ( $rbl_result ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | my $txt_result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | = exists( $rbl_data->{'results'}->{$rbl_result} ) ? $rbl_data->{'results'}->{$rbl_result} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | : exists( $rbl_data->{'results'}->{'*'} ) ? $rbl_data->{'results'}->{'*'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | : 'pass'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.'.$rbl )->safe_set_value( $txt_result ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | # What comments can we add? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 270 | my @comments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 270 | ▶ | if ( $dmarc_policy ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 270 | push @comments, $self->format_header_entry( 'p', $dmarc_policy ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 270 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.published-domain-policy' )->safe_set_value( $dmarc_policy ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 270 | ▶ | if ( $dmarc_sub_policy ne 'default' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | push @comments, $self->format_header_entry( 'sp', $dmarc_sub_policy ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.published-subdomain-policy' )->safe_set_value( $dmarc_sub_policy ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 270 | ▶ | if ( $config->{'detect_list_id'} && $self->{'is_list'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$config->{"detect_list_id"} and $self->{"is_list"}
MC/DC100%2/2
$config->{"detect_list_id"} and $self->{"is_list"}
$config->{"detect_list_id"}
$self->{"is_list"}
Truth table100%3/3
A and B
A= $config->{"detect_list_id"}B= $self->{"is_list"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 1 | push @comments, 'has-list-id=yes'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 270 | ▶ | if ( $dmarc_disposition ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 270 | push @comments, $self->format_header_entry( 'd', $dmarc_disposition ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 270 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.applied-disposition' )->safe_set_value( $dmarc_disposition ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 270 | ▶ | if ( $dmarc_disposition_evaluated ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 270 | push @comments, $self->format_header_entry( 'd.eval', $dmarc_disposition_evaluated ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 270 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.evaluated-disposition' )->safe_set_value( $dmarc_disposition_evaluated ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 270 | ▶ | if ( $policy_override ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 34 | push @comments, $self->format_header_entry( 'override', $policy_override ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 34 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.override-reason' )->safe_set_value( $policy_override ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 270 | ▶ | if ( $arc_aware_result ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 2 | push @comments, $self->format_header_entry( 'arc_aware_result', $arc_aware_result ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 2 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.arc-aware-result' )->safe_set_value( $arc_aware_result ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 270 | ▶ | if ( @comments ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 270 | $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( join( ',', @comments ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 270 | ▶ | my $policy_used = ( $is_subdomain && $dmarc_sub_policy ne 'default' ) ? 'sp' : 'p'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_subdomain and $dmarc_sub_policy ne "default"
MC/DC0%0/2
$is_subdomain and $dmarc_sub_policy ne "default"
$is_subdomain
$dmarc_sub_policy ne "default"
Truth table66%2/3
A and B
A= $is_subdomainB= $dmarc_sub_policy ne "default"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 270 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.policy-from' )->safe_set_value( $policy_used ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 270 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.from' )->safe_set_value( $header_domain ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 270 | ▶ | if ( $config->{'log_dns_record'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 2 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 2 | my $dmarc_dns_name = '_dmarc.' . $header_domain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 2 | my $resolver = $self->get_object('resolver'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 2 | my $reply = $resolver->query( $dmarc_dns_name, 'TXT' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 2 | ▶ | if ( $reply ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 2 | my @txt_parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 2 | for my $rr ( $reply->answer ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 2 | ▶ | next unless $rr->type eq 'TXT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 2 | push @txt_parts, join( '', $rr->txtdata ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 2 | ▶ | if ( @txt_parts ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2 | $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'x-dns-record=' . $self->escape_non_printable_ascii( join( ' ', @txt_parts ) ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 2 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 270 | $self->_add_dmarc_header( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # Write Metrics | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | my $metric_data = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 'result' => $dmarc_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 'disposition' => $dmarc_disposition, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 'policy' => $dmarc_policy, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 270 | ▶ | 'is_list' => ( $self->{'is_list'} ? '1' : '0' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 'is_whitelisted' => ( $is_whitelisted ? '1' : '0'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 'arc_aware_result' => $arc_aware_result, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 'used_arc' => ( $arc_aware_result ? '1' : '0' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 'is_subdomain' => ( $is_subdomain ? '1' : '0' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 270 | $self->metric_count( 'dmarc_total', $metric_data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # Try as best we can to save a report, but don't stress if it fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 270 | my $rua = eval { $dmarc_result->published()->rua(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 270 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 270 | ▶ | if ($rua) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 77 | ▶ | if ( ! $config->{'no_report'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 77 | ▶ | if ( ! $self->{'skip_report'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 77 | $self->dbgout( 'DMARCReportTo', $rua, LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 77 | push @{ $self->{'report_queue'} }, $dmarc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $self->dbgout( 'DMARCReportTo (skipped flag)', $rua, LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $self->dbgout( 'DMARCReportTo (skipped)', $rua, LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 302 | ▶ | sub get_dmarc_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_dmarc_object: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 302 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 302 | my $dmarc = $self->get_object('dmarc'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 302 | ▶ | if ( $dmarc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 20 | return $dmarc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 282 | $dmarc = $self->new_dmarc_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 282 | $self->set_object('dmarc', $dmarc,1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 282 | return $dmarc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 552 | ▶ | sub _build_dmarc_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_dmarc_object: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 552 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 552 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 552 | my $dmarc = Mail::DMARC::PurePerl->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 552 | ▶ | if ( exists ( $config->{ 'config_file' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 5 | ▶ | $self->log_error( 'DMARC config file does not exist' ) if ! -e $config->{ 'config_file' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 5 | $dmarc->config( $config->{ 'config_file' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 552 | ▶ | if ( $dmarc->can('set_resolver') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 552 | my $resolver = $self->get_object('resolver'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 552 | $dmarc->set_resolver($resolver); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 552 | ▶ | if ( $self->config()->{'debug'} && $self->config()->{'logtoerr'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->config->{"debug"} and $self->config->{"logtoerr"}
MC/DC50%1/2
$self->config->{"debug"} and $self->config->{"logtoerr"}
$self->config->{"debug"}
$self->config->{"logtoerr"}
Truth table66%2/3
A and B
A= $self->config->{"debug"}B= $self->config->{"logtoerr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 385 | $dmarc->verbose(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 552 | return $dmarc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 512 | ▶ | sub new_dmarc_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_dmarc_object: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 512 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 512 | my $dmarc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 512 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 512 | $dmarc = $self->_build_dmarc_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 512 | $self->set_object('dmarc', $dmarc,1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 512 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | $self->log_error( 'DMARC IP Error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'dmarc' )->safe_set_value( 'permerror' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'DMARC IP error' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | $self->add_auth_header( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | $self->metric_count( 'dmarc_total', { 'result' => 'permerror' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | $self->{'failmode'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 512 | return $dmarc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 166 | ▶ | sub helo_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
helo_callback: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 166 | my ( $self, $helo_host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 166 | $self->{'helo_name'} = $helo_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 166 | ▶ | $self->{'report_queue'} = [] if ! $self->{'report_queue'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 54 | ▶ | sub envfrom_requires { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
envfrom_requires: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 54 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 54 | my @requires = qw{ SPF }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 54 | return \@requires; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 166 | ▶ | sub envfrom_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
envfrom_callback: called CC=8 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 166 | my ( $self, $env_from ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 166 | ▶ | return if ( $self->is_local_ip_address() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 158 | ▶ | return if ( $self->is_trusted_ip_address() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 156 | ▶ | return if ( $self->is_authenticated() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 156 | delete $self->{'from_header'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 156 | $self->{'processed'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 156 | $self->{'from_lookup_count'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 156 | $self->{'is_list'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 156 | $self->{'skip_report'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 156 | $self->{'failmode'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 156 | $self->{'strict_multifrom_disposition'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 156 | ▶ | $env_from = q{} if $env_from eq '<>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 156 | ▶ | if ( ! $self->is_handler_loaded( 'SPF' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | $self->log_error( 'DMARC Config Error: SPF is missing '); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | $self->metric_count( 'dmarc_total', { 'result' => 'error' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | $self->{'failmode'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 156 | ▶ | if ( ! $self->is_handler_loaded( 'DKIM' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | $self->log_error( 'DMARC Config Error: DKIM is missing '); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | $self->metric_count( 'dmarc_total', { 'result' => 'error' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | $self->{'failmode'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 156 | ▶ | if ( $env_from ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 151 | $self->{ 'env_from' } = $env_from; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 5 | $self->{ 'env_from' } = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 156 | $self->{ 'from_headers' } = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 156 | ▶ | sub check_skip_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_skip_address: called CC=4 SCAR=20.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 156 | my ( $self, $env_to ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 156 | $env_to = lc $self->get_address_from( $env_to ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 156 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 156 | ▶ | return 0 if not exists( $config->{'report_skip_to'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | foreach my $address ( @{ $config->{'report_skip_to'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | if ( lc $address eq lc $env_to ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | $self->dbgout( 'DMARCReportSkip', 'Skip address detected: ' . $env_to, LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | $self->{'skip_report'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 166 | ▶ | sub envrcpt_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
envrcpt_callback: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 166 | my ( $self, $env_to ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 166 | ▶ | return if ( $self->is_local_ip_address() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 158 | ▶ | return if ( $self->is_trusted_ip_address() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 156 | ▶ | return if ( $self->is_authenticated() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 156 | $self->{ 'env_to' } = $env_to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 156 | $self->check_skip_address( $env_to ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 1359 | ▶ | sub header_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_callback: called CC=14 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 1359 | my ( $self, $header, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 1359 | ▶ | return if ( $self->is_local_ip_address() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 1242 | ▶ | return if ( $self->is_trusted_ip_address() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 1212 | ▶ | return if ( $self->is_authenticated() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 1212 | ▶ | return if ( $self->{'failmode'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 1212 | ▶ | if ( lc $header eq 'list-id' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1 | $self->dbgout( 'DMARCListId', 'List ID detected: ' . $value, LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 1 | $self->{'is_list'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 1212 | ▶ | if ( lc $header eq 'list-post' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $self->dbgout( 'DMARCListId', 'List Post detected: ' . $value, LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | $self->{'is_list'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 1212 | ▶ | if ( lc $header eq 'from' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 311 | ▶ | if ( exists $self->{'from_header'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 157 | $self->dbgout( 'DMARCFail', 'Multiple RFC5322 from fields', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 311 | $self->{'from_header'} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 311 | push @{ $self->{ 'from_headers' } }, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 311 | my $domain = lc $self->get_domain_from( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 311 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | # Unlike DKIM and XGoogleDKIM there is no separate early_lookup_limit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | # here. skip_on_multifrom already bounds how many From domains are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | # evaluated, and a message with more is quarantined or rejected, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | # early lookups are only started for domains we will go on to look up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # anyway, at most two (domain and org domain) per From header. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | # Duplicates are not skipped, they count towards the same bound. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 311 | ▶ | my $lookup_limit = $config->{'skip_on_multifrom'} || 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$config->{'skip_on_multifrom'} || 10
MC/DC100%1/1
$config->{'skip_on_multifrom'} || 10
$config->{'skip_on_multifrom'}
Truth table100%2/2
A
A= $config->{'skip_on_multifrom'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 311 | ▶ | if ( $domain && $self->{'from_lookup_count'}++ < $lookup_limit ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$domain and $self->{"from_lookup_count"}++ < $lookup_limit
MC/DC100%2/2
$domain and $self->{"from_lookup_count"}++ < $lookup_limit
$domain
$self->{"from_lookup_count"}++ < $lookup_limit
Truth table100%3/3
A and B
A= $domainB= $self->{"from_lookup_count"}++ < $lookup_limit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 222 | my $lookup = '_dmarc.'.$domain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 222 | my $resolver = $self->get_object('resolver'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 222 | eval{ $resolver->bgsend( $lookup, 'TXT' ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 222 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 222 | $self->dbgout( 'DNSEarlyLookup', "$lookup TXT", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 222 | my $dmarc = $self->new_dmarc_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 222 | my $org_domain = eval{ $dmarc->get_organizational_domain( $domain ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 222 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 222 | ▶ | if ( $org_domain && ($org_domain ne $domain) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$org_domain and $org_domain ne $domain
MC/DC50%1/2
$org_domain and $org_domain ne $domain
$org_domain
$org_domain ne $domain
Truth table66%2/3
A and B
A= $org_domainB= $org_domain ne $domain
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 101 | my $lookup = '_dmarc.'.$org_domain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 101 | my $resolver = $self->get_object('resolver'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 101 | eval{ $resolver->bgsend( $lookup, 'TXT' ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 101 | $self->handle_exception( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 101 | $self->dbgout( 'DNSEarlyLookup', "$lookup TXT", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 54 | ▶ | sub eom_requires { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eom_requires: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 54 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 54 | my @requires = qw{ DKIM }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 54 | ▶ | if ( $self->is_handler_loaded( 'ARC' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 2 | push @requires, 'ARC'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 54 | return \@requires; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 166 | ▶ | sub eom_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eom_callback: called CC=25 SCAR=32.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 166 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 166 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 166 | ▶ | return if ( $self->is_local_ip_address() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 158 | ▶ | return if ( $self->is_trusted_ip_address() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 156 | ▶ | return if ( $self->is_authenticated() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 156 | ▶ | return if ( $self->{'failmode'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 156 | my $env_from = $self->{ 'env_from' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 156 | my $env_domains_from = $self->get_domains_from($env_from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 156 | ▶ | $env_domains_from = [''] if ! @$env_domains_from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 156 | ▶ | my $from_headers = $self->{ 'from_headers' } // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"from_headers"} // []
MC/DC0%0/1
$self->{"from_headers"} // []
$self->{"from_headers"}
Truth table50%1/2
A
A= $self->{"from_headers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | # Build a list of all from header domains used | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 156 | my @header_domains; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 156 | my $from_incomplete = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 156 | foreach my $from_header ( @$from_headers ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 311 | my ( $from_header_header_domains, $complete ) = $self->_get_from_header_domains( $from_header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 311 | ▶ | $from_incomplete = 1 if ! $complete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 311 | push @header_domains, @$from_header_header_domains; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 156 | ▶ | if ( $config->{strict_multifrom} && ( scalar @$from_headers > 1 || scalar @header_domains > 1 ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$config->{"strict_multifrom"} and scalar @$from_headers > 1 || scalar @header_domains > 1
scalar @$from_headers > 1 or scalar @header_domains > 1
MC/DC100%3/3
$config->{"strict_multifrom"} and scalar @$from_headers > 1 || scalar @header_domains > 1
$config->{"strict_multifrom"}
scalar @$from_headers > 1
scalar @header_domains > 1
Truth table100%4/4
A and B or C
A= $config->{"strict_multifrom"}B= scalar @$from_headers > 1C= scalar @header_domains > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | # Multiple from headers, or domains, in strict mode? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | # Don't allow anything to have a passing disposition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 8 | ▶ | if ( $config->{'hard_reject'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 3 | $self->{strict_multifrom_disposition} = 'reject'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 3 | $self->reject_mail( '550 5.7.0 DMARC policy violation' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 3 | $self->dbgout( 'DMARCReject', "Strict Multifrom reject", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 5 | $self->{strict_multifrom_disposition} = 'quarantine'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 5 | $self->quarantine_mail( 'Quarantined due to DMARC policy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 156 | $self->{ 'dmarc_ar_headers' } = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 156 | my @unique_env_domains_from = uniq sort @$env_domains_from; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 156 | my @unique_header_domains = uniq sort @header_domains; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 156 | my $pair_count = scalar @unique_env_domains_from * scalar @unique_header_domains; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 156 | my $process_limit = $self->_check_multifrom_limits( $pair_count ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 156 | my $process_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | # There will usually be only one, however this could be a source route | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | # so we consider multiples just incase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 156 | foreach my $env_domain_from ( @unique_env_domains_from ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 157 | foreach my $header_domain ( @unique_header_domains ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 355 | ▶ | if ( defined $process_limit && $process_count >= $process_limit ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $process_limit and $process_count >= $process_limit
MC/DC100%2/2
defined $process_limit and $process_count >= $process_limit
defined $process_limit
$process_count >= $process_limit
Truth table100%3/3
A and B
A= defined $process_limitB= $process_count >= $process_limit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | # Never skip silently, a skipped domain must still be visible in the results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 74 | $self->log_error( "DMARC limit reached, skipping processing for $env_domain_from $header_domain" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 74 | $self->metric_count( 'dmarc_total', { 'result' => 'permerror' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 74 | my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'dmarc' )->safe_set_value( 'permerror' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 74 | $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( 'too many from domains' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 74 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.from' )->safe_set_value( $header_domain ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 74 | $self->_add_dmarc_header( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 74 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 281 | $process_count++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 281 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 281 | $self->_process_dmarc_for( $env_domain_from, $header_domain ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 281 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | if ( $error =~ /invalid header_from at / ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | $self->log_error( 'DMARC Error invalid header_from <' . $self->{'from_header'} . '>' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'dmarc' )->safe_set_value( 'permerror' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.from' )->safe_set_value( $header_domain ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | $self->_add_dmarc_header( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | $self->log_error( 'DMARC Error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'dmarc' )->safe_set_value( 'temperror' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.from' )->safe_set_value( $header_domain ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | $self->_add_dmarc_header( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 281 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 156 | ▶ | if ( $from_incomplete || ! @unique_header_domains ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$from_incomplete or not @unique_header_domains
MC/DC100%2/2
$from_incomplete or not @unique_header_domains
$from_incomplete
not @unique_header_domains
Truth table100%3/3
A or not(B)
A= $from_incompleteB= not @unique_header_domains
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | # A from header we could not fully parse may hide a domain which would | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | # otherwise have been evaluated, so we can not let this mail through unscathed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 18 | ▶ | my $comment = @unique_header_domains ? 'unparseable from header' : 'no parseable from domain'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 18 | $self->log_error( "DMARC $comment, quarantining" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 18 | $self->metric_count( 'dmarc_total', { 'result' => 'permerror' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 18 | my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'dmarc' )->safe_set_value( 'permerror' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 18 | $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( $comment ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 18 | $self->_add_dmarc_header( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 18 | $self->quarantine_mail( 'Quarantined due to DMARC policy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 156 | foreach my $dmarc_header ( @{ $self->_get_unique_dmarc_headers() } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 370 | ▶ | if ( !( $config->{'hide_none'} && $dmarc_header->value() eq 'none' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$config->{"hide_none"} and $dmarc_header->value eq "none"
MC/DC100%2/2
$config->{"hide_none"} and $dmarc_header->value eq "none"
$config->{"hide_none"}
$dmarc_header->value eq "none"
Truth table100%3/3
A and B
A= $config->{"hide_none"}B= $dmarc_header->value eq "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 365 | $self->add_auth_header( $dmarc_header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 156 | delete $self->{ 'dmarc_ar_headers' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | # Apply the multifrom limits based on the total number of DMARC entities in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | # message, before any are processed, so that the outcome can not depend on which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | # domains sort into the processed set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | # Returns the maximum number of entities to process, or undef for no limit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 156 | ▶ | sub _check_multifrom_limits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_multifrom_limits: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 156 | my ( $self, $pair_count ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 156 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 156 | my @limits = grep { $_ } map { $config->{ $_ } } qw{ skip_on_multifrom quarantine_on_multifrom reject_on_multifrom }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 156 | ▶ | return undef unless @limits; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 13 | my $process_limit = min @limits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 13 | ▶ | if ( $config->{'reject_on_multifrom'} && $pair_count > $config->{'reject_on_multifrom'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$config->{"reject_on_multifrom"} and $pair_count > $config->{"reject_on_multifrom"}
MC/DC50%1/2
$config->{"reject_on_multifrom"} and $pair_count > $config->{"reject_on_multifrom"}
$config->{"reject_on_multifrom"}
$pair_count > $config->{"reject_on_multifrom"}
Truth table66%2/3
A and B
A= $config->{"reject_on_multifrom"}B= $pair_count > $config->{"reject_on_multifrom"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 1 | $self->log_error( "DMARC limit reached ($pair_count entities), rejecting" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 1 | $self->reject_mail( '550 5.7.0 DMARC policy violation' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | elsif ( $pair_count > $process_limit ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | # We can not evaluate every entity, so we can not let this mail through unscathed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 8 | $self->log_error( "DMARC limit reached ($pair_count entities), quarantining" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 8 | $self->quarantine_mail( 'Quarantined due to DMARC policy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 13 | return $process_limit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 520 | ▶ | sub can_sort_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_sort_header: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 520 | my ( $self, $header ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 520 | ▶ | return 1 if $header eq 'dmarc'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 519 | ▶ | sub handler_header_sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_header_sort: called CC=11 SCAR=24.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 519 | my ( $self, $pa, $pb ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # ToDo, do this without stringify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 519 | my ( $result_a, $policy_a ) = $pa->as_string() =~ /^dmarc=([a-z]+) .*policy\.applied\-disposition=([a-z]+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 519 | my ( $result_b, $policy_b ) = $pb->as_string() =~ /^dmarc=([a-z]+) .*policy\.applied\-disposition=([a-z]+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | # Fail then None then Pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 519 | ▶ | if ( $result_a ne $result_b ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 76 | ▶ | return -1 if $result_a eq 'fail'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 73 | ▶ | return 1 if $result_b eq 'fail'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 67 | ▶ | return -1 if $result_a eq 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 47 | ▶ | return 1 if $result_b eq 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | # Reject then Quarantine then None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 443 | ▶ | if ( $policy_a ne $policy_b ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 2 | ▶ | return -1 if $policy_a eq 'reject'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 2 | ▶ | return 1 if $policy_b eq 'reject'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 2 | ▶ | return -1 if $policy_a eq 'quarantine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | ▶ | return 1 if $policy_b eq 'quarantine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 441 | return $pa cmp $pb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 156 | ▶ | sub _get_unique_dmarc_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_unique_dmarc_headers: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 156 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 156 | my $unique_strings = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 156 | my @unique_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | # Returns unique headers based on as_string for each header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 156 | foreach my $header ( @{ $self->{ 'dmarc_ar_headers' } } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 373 | my $as_string = $header->as_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 373 | ▶ | next if exists $unique_strings->{ $as_string }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 370 | $unique_strings->{ $as_string } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 370 | push @unique_headers, $header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 156 | return \@unique_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 373 | ▶ | sub _add_dmarc_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_dmarc_header: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 373 | my ( $self, $header ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 373 | push @{ $self->{ 'dmarc_ar_headers' } }, $header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | # Extract the domains from a from header for DMARC evaluation, returning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | # ( \@domains, $complete ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | # get_domains_from returns nothing if any part of the header fails to parse, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | # which would let a sender hide a domain from evaluation. Here we keep every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | # domain we can find, including from mailboxes the parser flags as invalid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | # and report whether the whole header was accounted for so the caller can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | # act on the remainder. Empty list members (RFC 5322 obs-mbox-list) are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | # skipped, they must be accepted and carry no mailbox. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 311 | ▶ | sub _get_from_header_domains { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_from_header_domains: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 311 | my ( $self, $from_header ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 311 | ▶ | return ( [], 0 ) if ! defined $from_header; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | # Restore the RFC 5322 CRLF folding which milter header values lose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 311 | $from_header =~ s/\015?\012/\015\012/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 311 | my @domains; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 311 | my $complete = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 311 | foreach my $address_object ( Email::Address::XS->parse( $from_header ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 366 | my $host = $address_object->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 366 | ▶ | if ( ! defined $host ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 12 | ▶ | next if ! defined $address_object->user && ( $address_object->original // q{} ) =~ /^\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not defined $address_object->user and ($address_object->original // "") =~ /^\s*$/u
$address_object->original // ""
MC/DC50%1/2
not defined $address_object->user and ($address_object->original // "") =~ /^\s*$/u
not defined $address_object->user
$address_object->original
Truth table66%2/3
not(A) and B
A= not defined $address_object->userB= $address_object->original
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 9 | $complete = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 9 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 354 | $host = lc $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | # As per get_address_xs_from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 354 | ▶ | if ( $host !~ /^[a-z0-9_\-]+(?:\.[a-z0-9_\-]+)*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 1 | $complete = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 353 | ▶ | $complete = 0 if ! $address_object->is_valid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 353 | push @domains, $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 311 | ▶ | $complete = 0 if ! @domains; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 311 | return ( \@domains, $complete ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 246 | ▶ | sub addheader_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addheader_callback: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 246 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 246 | my $handler = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | # Split a DMARC rua tag value into deliverable and malformed entries, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | # returning ( \@kept, \@bad ). Mail::DMARC::Policy and ::URI accept any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | # "mailto:..." string regardless of address shape, so junk like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | # "rua=mailto:0" from a publisher's _dmarc record would otherwise wedge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | # the sender queue: Sender::email croaks on a falsy $to ("0" is falsy in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | # Perl), the croak is uncaught, the row stays, and no report_error is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | # written. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 43 | ▶ | sub _filter_rua { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_rua: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 43 | my ( $self, $rua ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 43 | my @kept; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | my @bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 43 | ▶ | for my $rua_entry ( split /,/, $rua // '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$rua // ""
MC/DC0%0/1
$rua // ""
$rua
Truth table50%1/2
A
A= $rua
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 44 | $rua_entry =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | # RFC 7489 6.2: Remove the suffix before matching | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | # e.g. "mailto:foo@bar.com!10m" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 44 | my ($uri) = split /!/, $rua_entry, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 44 | ▶ | if ( $uri =~ /^mailto:(.+)$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 43 | ▶ | if ( $self->get_address_from($1) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 41 | push @kept, $rua_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 2 | push @bad, $rua_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | elsif ( $uri =~ m{^https?:}i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 1 | push @kept, $rua_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 43 | return ( \@kept, \@bad ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | # Reports are queued as plain data holding only what save_aggregate needs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 42 | my @queued_report_fields = qw{ source_ip envelope_to envelope_from header_from is_subdomain }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 42 | my @queued_result_fields = qw{ result disposition dkim dkim_align spf spf_align }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 60 | ▶ | sub _dmarc_report_to_queue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dmarc_report_to_queue: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 60 | my ( $self, $report ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 60 | my $result = $report->result(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 298 | ( map { $_ => $report->{$_} } grep { defined $report->{$_} } @queued_report_fields ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 41 | ▶ | 'dkim' => [ map { +{ %$_ } } @{ $report->dkim() // [] } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$report->dkim // []
MC/DC0%0/1
$report->dkim // []
$report->dkim
Truth table50%1/2
A
A= $report->dkim
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 60 | ▶ | 'spf' => [ map { +{ %$_ } } @{ $report->spf() // [] } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$report->spf // []
MC/DC0%0/1
$report->spf // []
$report->spf
Truth table50%1/2
A
A= $report->spf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 293 | 'result' => { map { $_ => $result->{$_} } grep { defined $result->{$_} } @queued_result_fields }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 14 | ▶ | 'reason' => [ map { +{ %$_ } } @{ $result->reason() // [] } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$result->reason // []
MC/DC0%0/1
$result->reason // []
$result->reason
Truth table50%1/2
A
A= $result->reason
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 60 | 'published' => { %{ $result->published() } }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 40 | ▶ | sub _dmarc_report_from_queue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dmarc_report_from_queue: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 40 | my ( $self, $data ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 40 | ▶ | return if ! $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 40 | my $report = $self->_build_dmarc_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 40 | for my $field ( @queued_report_fields ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 200 | ▶ | $report->$field( $data->{$field} ) if defined $data->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | # Plain hashes, as the handler supplies them, are converted on save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 40 | $report->{'dkim'} = $data->{'dkim'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 40 | $report->{'spf'} = $data->{'spf'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 40 | my $result = $report->result(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 40 | for my $field ( @queued_result_fields ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 240 | ▶ | $result->$field( $data->{'result'}->{$field} ) if defined $data->{'result'}->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 40 | $result->reason( %$_ ) for @{ $data->{'reason'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | # As Mail::DMARC::Policy->parse builds it, without the stricter validation of new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 40 | $result->published( bless { %{ $data->{'published'} } }, 'Mail::DMARC::Policy' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 40 | return $report; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 2 | ▶ | sub dequeue_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dequeue_callback: called CC=18 SCAR=44.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 2 | my $dequeue_list = $self->get_dequeue_list('dmarc_report'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | REPORT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 2 | for my $id ( $dequeue_list->@* ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 38 | my $report = eval { $self->_dmarc_report_from_queue( $self->get_dequeue($id) ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 38 | ▶ | unless ($report) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | ▶ | my $error = $@ ? ": $@" : q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | $self->log_error("DMARC Report dequeue failed for $id$error"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | $self->error_dequeue($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | next REPORT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 38 | my $save_report = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 38 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 38 | $self->set_handler_alarm( 5 * 1000000 ); # Allow no longer than 5 seconds for this! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 38 | my $domain = $report->{ 'header_from' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 38 | my $org_domain = eval{ $report->get_organizational_domain( $domain ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 38 | my $rua = $report->result()->published()->rua(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 38 | my ( $kept_rua, $bad_rua ) = $self->_filter_rua($rua); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 38 | ▶ | if ( @$bad_rua ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | $self->dbgout( 'DMARC Report rua has malformed entries', "$domain, $rua, bad: @$bad_rua", LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 38 | ▶ | if ( ! @$kept_rua ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | $self->dbgout( 'DMARC Report skipped, no valid rua', "$domain, $rua", LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | $save_report = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | elsif ( @$bad_rua ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | my $cleaned_rua = join ',', @$kept_rua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | $report->result()->published()->rua($cleaned_rua); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | $self->dbgout( 'DMARC Report rua rewritten', "$domain, $rua -> $cleaned_rua", LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 38 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 38 | ▶ | if ( exists ( $config->{ 'report_suppression_list' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | ▶ | if ( $self->rbl_check_domain( $org_domain, $config->{ 'report_suppression_list' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | $self->dbgout( 'Queued DMARC Report suppressed for', "$domain, $rua", LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | $save_report = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 38 | ▶ | if ( exists ( $config->{ 'report_suppression_email_list' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | RUA: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | for my $rua_entry (split /,/ , $rua) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | $rua_entry = lc $rua_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | $rua_entry =~ s/ //g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | ▶ | next RUA unless $rua_entry =~ /^mailto:/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | $rua_entry =~ s/^mailto://; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | if ( $self->rbl_check_email_address( $rua_entry, $config->{ 'report_suppression_email_list' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | $self->dbgout( 'Queued DMARC Report suppressed for', "$domain, $rua :: $rua_entry listed", LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | $save_report = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 38 | ▶ | if ($save_report) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 38 | $report->save_aggregate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 38 | $self->dbgout( 'Queued DMARC Report saved for', "$domain, $rua", LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 38 | $self->delete_dequeue($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 38 | $self->reset_alarm(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 38 | ▶ | if ( my $Error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 1 | $self->reset_alarm(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 0 | my $Type = $self->is_exception_type( $Error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | ▶ | if ( $Type ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | ▶ | if ( $Type eq 'Timeout' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | # We have a timeout, is it global or is it ours? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | ▶ | if ( $self->get_time_remaining() > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | # We have time left, but this aggregate save timed out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | # Log this and move on! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | $self->log_error("DMARC timeout saving reports for $id"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 0 | $self->handle_exception( $Error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | $self->log_error("DMARC Report save failed for $id: $Error"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | $self->error_dequeue($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 120 | ▶ | sub _save_aggregate_reports { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_aggregate_reports: called CC=7 SCAR=26.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 120 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 120 | ▶ | return if ! $self->{'report_queue'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | # Try as best we can to save a report, but don't stress if it fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 77 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 77 | $self->set_handler_alarm( 2 * 1000000 ); # Allow no longer than 2 seconds for this! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 77 | ▶ | while ( my $report = shift @{ $self->{'report_queue'} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 58 | $self->add_dequeue('dmarc_report',$self->_dmarc_report_to_queue($report)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 58 | $self->dbgout( 'DMARC Report queued for', $report->result()->published()->rua(), LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 77 | $self->reset_alarm(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 77 | ▶ | if ( my $Error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | $self->reset_alarm(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | my $Type = $self->is_exception_type( $Error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | ▶ | if ( $Type ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | ▶ | if ( $Type eq 'Timeout' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | # We have a timeout, is it global or is it ours? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | ▶ | if ( $self->get_time_remaining() > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | # We have time left, but the aggregate save timed out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | # Log this and move on! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | $self->log_error( 'DMARC timeout saving reports' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | $self->handle_exception( $Error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | $self->log_error( 'DMARC Report Error ' . $Error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 120 | ▶ | sub close_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close_callback: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 120 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 120 | $self->_save_aggregate_reports(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 120 | delete $self->{'helo_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 120 | delete $self->{'env_from'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 120 | delete $self->{'env_to'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 120 | delete $self->{'failmode'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 120 | delete $self->{'skip_report'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 120 | delete $self->{'is_list'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 120 | delete $self->{'from_header'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 120 | delete $self->{'from_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 120 | delete $self->{'report_queue'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 120 | delete $self->{'processed'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 120 | delete $self->{'from_lookup_count'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 120 | delete $self->{'strict_multifrom_disposition'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 120 | $self->destroy_object('dmarc'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 120 | $self->destroy_object('dmarc_result'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 120 | $self->destroy_object('dmarc_results'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 42 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||