Branch Coverage

blib/lib/Mail/Milter/Authentication/Handler/DMARC.pm
Criterion Covered Total %
branch 185 348 53.1


line true false branch
48 112 8 unless exists $config->{'whitelisted'}
55 0 10 if ($entry =~ /^dnswl:/u) { }
2 8 elsif ($entry =~ /^dkim:/u) { }
0 8 elsif ($entry =~ /^spf:/u) { }
57 0 0 if ($type eq 'spf') { }
0 0 elsif ($type eq 'dkim') { }
0 0 elsif ($type eq 'ip') { }
60 0 0 if ($spf)
62 0 0 if ($got_spf_result eq "pass")
64 0 0 if ($self->rbl_check_domain($got_spf_domain, $rbl))
76 0 0 if ($self->rbl_check_domain($dkim_domain, $rbl))
83 0 0 if ($self->rbl_check_ip($ip_obj, $rbl))
92 2 0 if (exists $dkim_handler->{'valid_domains'}{lc $dkim_domain})
101 0 0 if ($spf)
103 0 0 if ($got_spf_result eq "pass")
105 0 0 if (lc $got_spf_domain eq lc $spf_domain)
116 0 8 if (not $whitelisted_obj) { }
121 0 6 if ($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)
133 4 6 if $whitelisted
143 0 40 if (exists $config->{'config_file'})
144 0 0 unless -e $config->{'config_file'}
149 40 0 if ($psl) { }
162 0 33 if (exists $config->{'config_file'})
163 0 0 unless -e $config->{'config_file'}
167 0 33 if ($now > $PSL_CHECKED_TIME + $check_time)
169 0 0 if ($dmarc->can('check_public_suffix_list')) { }
170 0 0 if ($dmarc->check_public_suffix_list) { }
193 0 10 if $config->{'no_report'}
214 2 0 if ($env_domain_from ne "")
218 0 2 if (my $error = $@)
226 2 0 unless ($config->{'hide_report_to'})
230 0 2 if (my $error = $@)
237 0 2 if (my $error = $@)
246 2 0 if ($spf) { }
248 0 2 if ($spf->{'spfu_detected'}) { }
0 2 elsif ($spf->{'dmarc_result'} eq 'pass' and lc $spf->{'dmarc_domain'} eq lc $header_domain) { }
1 1 elsif (my $arc_spf = $self->get_handler('ARC')->get_trusted_spf_results) { }
284 0 2 if (my $error = $@)
293 1 1 if ($arc_values)
300 0 2 if ($dkim_handler->{'has_dkim'})
302 0 0 if ($dkim_object)
317 0 120 if (exists $self->{'processed'}{"$env_domain_from $header_domain"})
323 0 120 if ($config->{'reject_on_multifrom'})
324 0 0 if (scalar keys %{$$self{'processed'}} == $config->{'reject_on_multifrom'}) { }
0 0 elsif (scalar keys %{$$self{'processed'}} > $config->{'reject_on_multifrom'}) { }
335 0 120 if ($config->{'quarantine_on_multifrom'})
336 0 0 if (scalar keys %{$$self{'processed'}} == $config->{'quarantine_on_multifrom'}) { }
0 0 elsif (scalar keys %{$$self{'processed'}} > $config->{'quarantine_on_multifrom'}) { }
347 0 120 if ($config->{'skip_on_multifrom'})
348 0 0 if (scalar keys %{$$self{"processed"}} >= $config->{'skip_on_multifrom'})
360 116 4 if ($env_domain_from ne "")
364 2 114 if (my $error = $@)
371 120 0 unless ($config->{'hide_report_to'})
375 0 120 if (my $error = $@)
383 0 120 if (my $error = $@)
395 10 110 if ($have_arc)
397 0 10 unless $self->get_handler("ARC")->can("get_trusted_arc_authentication_results")
399 110 10 unless $config->{'use_arc'}
404 120 0 if ($spf) { }
415 0 120 if (my $error = $@)
423 0 120 if ($dkim_handler->{'failmode'}) { }
41 79 elsif ($dkim_handler->{'has_dkim'}) { }
428 41 0 if ($dkim_object) { }
445 110 10 unless $dmarc_results
453 0 120 if (my $error = $@)
455 0 0 if ($dmarc_code ne "pass")
462 6 114 $is_subdomain ? :
467 39 81 unless $dmarc_policy
471 120 0 unless $dmarc_sub_policy
478 2 118 if ($have_arc and $dmarc_code eq "fail")
482 0 2 unless defined $arc_aware_result
490 120 0 if ($spf)
495 6 114 if ($dmarc_code eq "pass" and $spfu_mitigation)
503 6 0 if ($env_domain_from ne "")
511 0 6 if ($dkim_handler->{'failmode'}) { }
0 6 elsif ($dkim_handler->{'has_dkim'}) { }
515 0 0 if ($dkim_object) { }
524 6 0 if ($spfu_result->result ne "pass" and $dmarc_disposition ne $spfu_result->disposition)
541 30 90 if ($dmarc_code eq "fail")
543 1 29 if ($arc_aware_result eq 'pass') { }
4 25 elsif ($is_whitelisted) { }
0 25 elsif ($config->{'no_list_reject'} and $self->{'is_list'}) { }
552 1 0 if ($arc_handler)
553 1 0 if ($arc_handler->{'arc_result'} eq "pass")
562 0 2 if $signature->instance ne $instance
591 0 0 if ($config->{'arc_before_list'} and $have_arc and $self->get_handler('ARC')->get_trusted_arc_authentication_results) { }
604 14 16 if ($dmarc_disposition eq "reject")
605 2 12 if ($config->{'hard_reject'}) { }
619 12 108 if ($dmarc_disposition eq "quarantine")
627 0 0 if ($config->{'policy_rbl_lookup'} and $dmarc_code eq 'pass' || $arc_aware_result eq 'pass')
632 0 0 if ($rbl_result)
635 0 0 exists $rbl_data->{'results'}{'*'} ? :
0 0 exists $rbl_data->{'results'}{$rbl_result} ? :
644 120 0 if ($dmarc_policy)
648 0 120 if ($dmarc_sub_policy ne "default")
652 1 92 if ($config->{'detect_list_id'} and $self->{'is_list'})
655 120 0 if ($dmarc_disposition)
659 120 0 if ($dmarc_disposition_evaluated)
663 22 98 if ($policy_override)
667 2 118 if ($arc_aware_result)
672 120 0 if (@comments)
676 0 120 $is_subdomain && $dmarc_sub_policy ne 'default' ? :
687 1 119 $self->{'is_list'} ? :
4 116 $is_whitelisted ? :
2 118 $arc_aware_result ? :
6 114 $is_subdomain ? :
698 62 58 if ($rua)
699 62 0 if (not $config->{'no_report'}) { }
700 62 0 if (not $self->{'skip_report'}) { }
717 19 120 if ($dmarc)
734 0 243 if (exists $config->{'config_file'})
735 0 0 unless -e $config->{'config_file'}
738 243 0 if ($dmarc->can("set_resolver"))
742 106 0 if ($self->config->{'debug'} and $self->config->{'logtoerr'})
747 0 243 if (my $error = $@)
762 123 0 if not $self->{'report_queue'}
773 8 115 if $self->is_local_ip_address
774 2 113 if $self->is_trusted_ip_address
775 0 113 if $self->is_authenticated
782 1 112 if $env_from eq "<>"
784 0 113 unless ($self->is_handler_loaded("SPF"))
790 0 113 unless ($self->is_handler_loaded("DKIM"))
797 108 5 if ($env_from) { }
811 113 0 unless exists $config->{'report_skip_to'}
813 0 0 if (lc $address eq lc $env_to)
822 8 115 if $self->is_local_ip_address
823 2 113 if $self->is_trusted_ip_address
824 0 113 if $self->is_authenticated
832 117 956 if $self->is_local_ip_address
833 30 926 if $self->is_trusted_ip_address
834 0 926 if $self->is_authenticated
835 0 926 if $self->{'failmode'}
837 1 925 if (lc $header eq "list-id")
841 0 926 if (lc $header eq "list-post")
846 115 811 if (lc $header eq "from")
847 4 111 if (exists $self->{'from_header'})
853 115 0 if ($domain)
862 16 99 if ($org_domain and $org_domain ne $domain)
878 1 29 if ($self->is_handler_loaded("ARC"))
889 8 115 if $self->is_local_ip_address
890 2 113 if $self->is_trusted_ip_address
891 0 113 if $self->is_authenticated
892 0 113 if $self->{'failmode'}
896 5 108 unless @$env_domains_from
917 0 120 if (my $error = $@)
919 0 0 if ($error =~ /invalid header_from at /u) { }
936 110 3 if (@{$self->{'dmarc_ar_headers'};}) { }
938 111 5 unless ($config->{'hide_none'} and $dmarc_header->value eq "none")
954 8 0 if $header eq "dmarc"
967 4 4 if ($result_a ne $result_b)
968 0 4 if $result_a eq "fail"
969 4 0 if $result_b eq "fail"
970 0 0 if $result_a eq "none"
971 0 0 if $result_b eq "none"
975 2 2 if ($policy_a ne $policy_b)
976 0 2 if $policy_a eq "reject"
977 0 2 if $policy_b eq "reject"
978 2 0 if $policy_a eq "quarantine"
979 0 0 if $policy_b eq "quarantine"
994 4 116 if exists $unique_strings->{$as_string}
1018 41 0 if ($report) { }
1022 41 0 if ($report->can("set_resolver"))
1032 0 41 if (exists $config->{'report_suppression_list'})
1033 0 0 if ($self->rbl_check_domain($org_domain, $config->{'report_suppression_list'}))
1045 0 41 if (my $Error = $@)
1048 0 0 if ($Type)
1049 0 0 if ($Type eq "Timeout")
1051 0 0 if ($self->get_time_remaining > 0) { }
1075 43 75 unless $self->{'report_queue'}
1080 56 0 if ($report->can("set_resolver"))
1088 0 75 if (my $Error = $@)
1091 0 0 if ($Type)
1092 0 0 if ($Type eq "Timeout")
1094 0 0 if ($self->get_time_remaining > 0)