Branch Coverage

blib/lib/Mail/SpamAssassin/Plugin/SPF.pm
Criterion Covered Total %
branch 57 240 23.7


line true false branch
242 0 4 unless $scanner->{'spf_checked'}
248 4 0 unless $scanner->{'spf_checked'}
254 0 0 unless $scanner->{'spf_checked'}
260 0 4 unless $scanner->{'spf_checked'}
261 0 4 if ($scanner->{'spf_failure_comment'})
269 0 4 unless $scanner->{'spf_checked'}
275 0 0 unless $scanner->{'spf_checked'}
281 0 0 unless $scanner->{'spf_checked'}
287 0 4 unless $scanner->{'spf_helo_checked'}
293 4 0 unless $scanner->{'spf_helo_checked'}
299 0 0 unless $scanner->{'spf_helo_checked'}
305 0 4 unless $scanner->{'spf_helo_checked'}
306 0 4 if ($scanner->{'spf_helo_failure_comment'})
314 0 4 unless $scanner->{'spf_helo_checked'}
320 0 0 unless $scanner->{'spf_helo_checked'}
326 0 0 unless $scanner->{'spf_helo_checked'}
332 81 0 unless $scanner->{'spf_whitelist_from_checked'}
338 81 0 unless $scanner->{'def_spf_whitelist_from_checked'}
356 0 8 if ($scanner->{'conf'}{'ignore_received_spf_header'}) { }
4 4 elsif ($scanner->{'checked_for_received_spf_header'}) { }
365 0 4 if ($scanner->{'conf'}{'use_newest_received_spf_header'}) { }
374 0 17 if ($hdr =~ /^received-spf:/i) { }
0 17 elsif ($hdr =~ /^Authentication-Results:.*;\s*SPF\s*=\s*([^;]*)/i) { }
393 0 0 if ($hdr =~ /^received-spf:\s*(pass|neutral|(?:soft)?fail|(?:temp|perm)error|none)\b(?:.*\bidentity=(\S+?);?\b)?/i) { }
397 0 0 if (defined $2) { }
399 0 0 if ($identity eq 'mfrom' or $identity eq 'mailfrom') { }
0 0 elsif ($identity eq 'helo') { }
400 0 0 if $scanner->{'spf_checked'}
403 0 0 if $scanner->{'spf_helo_checked'}
410 0 0 if $scanner->{'spf_checked'}
426 0 0 $identity ? :
430 0 0 if $scanner->{'spf_checked'} and $scanner->{'spf_helo_checked'}
443 0 0 if ($tmphdr =~ /^(pass|neutral|(?:hard|soft)?fail|(?:temp|perm)error|none)(?:[^;]*?\bsmtp\.(\S+)\s*=[^;]+)?/i) { }
445 0 0 if $result eq 'hardfail'
448 0 0 if (defined $2) { }
450 0 0 if ($identity eq 'mfrom' or $identity eq 'mailfrom') { }
0 0 elsif ($identity eq 'helo') { }
451 0 0 if $scanner->{'spf_checked'}
454 0 0 if $scanner->{'spf_helo_checked'}
461 0 0 if $scanner->{'spf_checked'}
477 0 0 $identity ? :
481 0 0 if $scanner->{'spf_checked'} and $scanner->{'spf_helo_checked'}
490 0 4 if $ishelo and $scanner->{'spf_helo_checked'} or not $ishelo and $scanner->{'spf_checked'}
494 0 8 unless $scanner->is_dns_available
495 0 8 if $self->{'no_spf_module'}
498 1 7 unless (defined $self->{'has_mail_spf'})
501 0 1 if $scanner->{'conf'}{'do_not_use_mail_spf'}
504 0 1 if (not defined $Mail::SPF::VERSION or $Mail::SPF::VERSION < 2.001)
505 0 0 defined $Mail::SPF::VERSION ? :
516 0 1 unless (eval { do { die "Mail::SPF disabled by admin setting\n" if $scanner->{'conf'}{'do_not_use_mail_spf'}; require Mail::SPF; if (not defined $Mail::SPF::VERSION or $Mail::SPF::VERSION < 2.001) { die 'Mail::SPF 2.001 or later required, this is ' . (defined $Mail::SPF::VERSION ? $Mail::SPF::VERSION : 'unknown') . "\n"; } ; $self->{'spf_server'} = 'Mail::SPF::Server'->new('hostname', $scanner->get_tag('HOSTNAME'), 'dns_resolver', $self->{'main'}{'resolver'}, 'max_dns_interactive_terms', 20); 1 } })
517 0 0 $@ ne '' ? :
520 1 0 if (not defined $eval_stat) { }
532 0 0 if $scanner->{'conf'}{'do_not_use_mail_spf_query'}
535 0 0 if (not defined $Mail::SPF::Query::VERSION or $Mail::SPF::Query::VERSION < 1.996)
536 0 0 defined $Mail::SPF::Query::VERSION ? :
540 0 0 unless (eval { do { die "Mail::SPF::Query disabled by admin setting\n" if $scanner->{'conf'}{'do_not_use_mail_spf_query'}; require Mail::SPF::Query; if (not defined $Mail::SPF::Query::VERSION or $Mail::SPF::Query::VERSION < 1.996) { die 'Mail::SPF::Query 1.996 or later required, this is ' . (defined $Mail::SPF::Query::VERSION ? $Mail::SPF::Query::VERSION : 'unknown') . "\n"; } ; 1 } })
541 0 0 $@ ne '' ? :
544 0 0 if (not defined $eval_stat) { }
560 0 8 if $scanner->check_for_from_dns
562 4 4 if ($ishelo) { }
587 8 0 unless (defined $lasthop)
588 4 4 $ishelo ? :
595 0 0 unless $scanner->{'sender_got'}
597 0 0 if ($ishelo) { }
598 0 0 unless ($helo)
604 0 0 unless $scanner->{'sender_got'}
611 0 0 unless ($scanner->{'sender'})
616 0 0 $helo ? :
621 0 0 if ($ishelo and $helo =~ /^[\[!]?\d+\.\d+\.\d+\.\d+[\]!]?$/ || $helo =~ /^[^.]+$/)
626 0 0 if ($helo and $scanner->server_failed_to_respond_for_domain($helo))
635 0 0 if ($self->{'has_mail_spf'}) { }
638 0 0 $ishelo ? :
640 0 0 unless ($identity)
641 0 0 $ishelo ? :
0 0 $ishelo ? :
649 0 0 $ishelo ? :
654 0 0 unless (eval { do { $request = 'Mail::SPF::Request'->new('scope', $ishelo ? 'helo' : 'mfrom', 'identity', $identity, 'ip_address', $ip, 'helo_identity', $helo); 1 } })
655 0 0 $@ ne '' ? :
669 0 0 if $query->can('authority_explanation')
677 0 0 unless ($helo)
692 0 0 unless (eval { do { $query = 'Mail::SPF::Query'->new('ip', $ip, 'sender', $scanner->{'sender'}, 'helo', $helo, 'debug', 0, 'trusted', 0); 1 } })
693 0 0 $@ ne '' ? :
710 0 0 if ($err)
723 0 0 if ($ishelo) { }
724 0 0 if ($result eq 'pass') { }
0 0 elsif ($result eq 'neutral') { }
0 0 elsif ($result eq 'none') { }
0 0 elsif ($result eq 'fail') { }
0 0 elsif ($result eq 'softfail') { }
0 0 elsif ($result eq 'permerror') { }
0 0 elsif ($result eq 'temperror') { }
0 0 elsif ($result eq 'error') { }
733 0 0 if ($result eq 'fail')
737 0 0 if ($result eq 'pass') { }
0 0 elsif ($result eq 'neutral') { }
0 0 elsif ($result eq 'none') { }
0 0 elsif ($result eq 'fail') { }
0 0 elsif ($result eq 'softfail') { }
0 0 elsif ($result eq 'permerror') { }
0 0 elsif ($result eq 'temperror') { }
0 0 elsif ($result eq 'error') { }
746 0 0 if ($result eq 'fail')
769 14 63 if (defined $relay)
773 0 77 if ($sender) { }
779 28 49 if ($scanner->{'num_relays_trusted'} > 0 and not $scanner->{'conf'}{'always_trust_envelope_sender'})
791 48 1 unless ($sender)
807 4 77 if ($scanner->{'spf_checked'} and not $scanner->{'spf_pass'})
812 33 44 unless $scanner->{'sender_got'}
814 76 1 unless ($scanner->{'sender'})
820 1 0 unless ($scanner->{'spf_whitelist_from'})
825 0 1 if ($scanner->{'spf_whitelist_from'}) { }
826 0 0 if ($self->check_for_spf_pass($scanner)) { }
845 4 77 if ($scanner->{'spf_checked'} and not $scanner->{'spf_pass'})
850 44 33 unless $scanner->{'sender_got'}
852 76 1 unless ($scanner->{'sender'})
858 1 0 unless ($scanner->{'def_spf_whitelist_from'})
863 0 1 if ($scanner->{'def_spf_whitelist_from'}) { }
864 0 0 if ($self->check_for_spf_pass($scanner)) { }
877 0 4 if (defined $scanner->{'conf'}{$param}{$scanner->{'sender'}}) { }
882 0 0 if ($scanner->{'sender'} =~ qr/$regexp/i)