Branch Coverage

blib/lib/Mail/SPF/Query.pm
Criterion Covered Total %
branch 97 340 28.5


line true false branch
232 0 165 if defined $$query{'ip'} and $$query{'ip'} =~ /$looks_like_ipv4/
234 0 165 if defined $$query{'ehlo'}
237 0 165 if $$query{'trusted'}
245 0 165 if $$query{'guess'}
247 165 0 if ($$query{'sanitize'} and not ref $$query{'sanitize'} or not defined $$query{'sanitize'})
254 0 165 unless ($$query{'ipv4'} and length $$query{'ipv4'})
266 0 165 if ($$query{'domain'} =~ /^\[\d+\.\d+\.\d+\.\d+\]$/)
270 0 165 unless ($$query{'helo'})
278 0 165 unless ($$query{'domain'})
284 0 165 unless (length $$query{'domain'})
291 147 18 unless length $$query{'localpart'}
295 0 0 $$query{'ipv6'} ? :
165 0 $$query{'ipv4'} ? :
298 165 0 unless ($$query{'myhostname'})
306 0 330 if (ref(my $domains_hash = $$query{$_}) eq 'HASH')
308 0 0 if ref $$domains_hash{$domain} eq 'HASH'
314 0 165 if $class->can('post_new')
418 0 165 $$query{'best_guess'} ? :
422 0 165 if $smtp_why eq 'default'
424 164 1 $smtp_explanation && $smtp_why ? :
442 165 0 if wantarray
456 1 164 if ($result eq 'pass' and $$query{'smtp_comment'} eq 'localhost is always allowed.')
461 164 0 if ($$query{'spf_source_type'} eq 'original-spf-record')
463 0 0 $result eq 'none' ? :
0 0 $result eq 'error' ? :
0 0 $result eq 'neutral' ? :
164 0 $result eq 'unknown' ? :
0 164 $result =~ /^unknown / ? :
0 164 $result eq 'softfail' ? :
0 164 $result eq 'fail' ? :
0 164 $result eq 'pass' ? :
495 0 165 $$query{'matched_mechanism'} ? :
0 165 $$query{'result'} eq 'error' ? :
0 165 $$query{'spf_source_type'} ne 'original-spf-record' ? :
507 0 165 if (wantarray)
571 9 4 unless ($$query{'result2'})
580 9 0 unless (defined $cache_result)
581 0 9 is_secondary_for($rhost, $$query{'ipv4'}) ? :
585 0 9 if ($cache_result eq 'yes') { }
597 0 9 if ($all_mx_secondary eq 'yes')
598 0 0 if wantarray
607 13 0 if wantarray
619 9 0 if ($resolver)
621 9 0 if ($mx)
627 6 0 if ($a)
629 6 0 if ($rra->type eq 'A')
630 0 6 if ($rra->address eq $addr)
664 0 9 unless ($$query{'result2'})
665 0 0 if ($$query{'is_mx_good'})
666 0 0 if wantarray
677 9 0 if wantarray
740 0 2024 if ($$query{'parent'})
775 0 0 if (defined $result and $result eq 'pass')
778 0 0 if wantarray
804 825 0 if (ref $$query{'sanitize'})
850 0 1696 if ref $query and not $$query{'debug'}
860 1696 0 if (exists $$query{'debuglog'} and ref $$query{'debuglog'} eq 'CODE') { }
883 1 164 if ($$query{'ipv4'} and $$query{'ipv4'} =~ /^127\./)
888 0 164 if ($query->is_looping)
889 0 164 if ($query->can_use_cached_result) { }
894 164 0 unless (defined $directive_set)
897 0 164 if ($$query{'domain'} ne $$query{'orig_domain'})
898 0 0 if ($$query{'error'})
903 164 0 if ($$query{'last_dns_error'} eq 'NXDOMAIN')
910 0 0 if ($$directive_set{'hard_syntax_error'})
921 0 0 if ($$query{'error'})
927 0 0 if (defined $result)
929 0 0 $result =~ /^unknown/ ? :
942 0 0 if ($$query{'directive_set'}->redirect)
988 0 164 if exists $$Domains_Queried{$cache_point} and not defined $$Domains_Queried{$cache_point}[0]
992 0 164 if $query->max_lookup_count and $query->top->{'lookup_count'} > $query->max_lookup_count
1007 0 164 if ($$Domains_Queried{$cache_point})
1010 0 0 if (not defined $CACHE_TIMEOUT or time - $cached[-1] > $CACHE_TIMEOUT)
1042 0 0 if ($$Domains_Queried{$cache_point})
1060 0 0 if $$query{'ptr_domain'}
1072 0 0 if ($ptr_to_a eq $$query{'ipv4'})
1085 0 27 if ($arg eq '%')
1086 0 27 if ($arg eq '_')
1087 0 27 if ($arg eq '-')
1093 27 0 unless length $delim
1098 0 27 if lc $field eq 'u'
1099 0 27 if lc $field eq 'l'
1100 0 27 if lc $field eq 'd'
1101 9 18 if lc $field eq 's'
1102 0 27 if lc $field eq 'o'
1103 9 18 if lc $field eq 'i'
1104 0 27 if lc $field eq 't'
1105 0 27 if lc $field eq 'h'
1106 0 27 if lc $field eq 'p'
1107 9 18 if lc $field eq 'r'
1108 0 0 $$query{'ipv4'} ? :
0 27 if lc $field eq 'v'
1114 27 0 if (length $delim)
1117 0 27 if $reverse
1119 0 27 if ($num)
1126 27 0 if $field ne lc $field
1147 0 164 if ($maxlen and length $arg > $maxlen)
1151 9 155 if $original ne $arg
1164 0 0 length $argument ? :
1175 0 0 unless length $modifier
1179 0 0 if ({map({$_, 1;} @KNOWN_MECHANISMS)}->{$mechanism}) { }
1185 0 0 unless $hit
1187 0 0 if $hit ne 'hit'
1189 0 0 if ($source)
1197 0 0 $modifier eq '+' ? :
0 0 $argument ? :
1225 0 164 if (/\.\./ or /^\./)
1236 0 164 if (not $resquery and $errorstring eq 'NOERROR')
1242 164 0 unless ($resquery)
1243 164 0 if ($errorstring eq 'NXDOMAIN')
1259 0 0 if ($sortby) { }
1262 0 0 unless (@toreturn)
1272 0 0 if ($method ne 'char_str_list')
1308 0 0 unless ($argument)
1327 0 0 if ($result eq 'pass')
1328 0 0 if ($result eq 'error')
1329 0 0 if ($result eq 'unknown')
1330 0 0 if ($result eq 'none')
1331 0 0 if ($result eq 'fail' or $result eq 'neutral' or $result eq 'softfail')
1347 0 0 $argument =~ s[ /(\d+)][]x ? :
1348 0 0 $argument =~ s[//(\d+)][]x ? :
1353 0 0 unless ($domain_to_use =~ / \. [a-z] (?: [a-z0-9-]* [a-z0-9] ) $ /xi)
1359 0 0 if ($a eq $$query{'ipv4'}) { }
0 0 elsif ($ip4_cidr_length < 32) { }
1368 0 0 if $cidr->find($$query{'ipv4'})
1383 0 0 $argument =~ s[ /(\d+)][]x ? :
1384 0 0 $argument =~ s[//(\d+)][]x ? :
1388 0 0 unless ($domain_to_use =~ / \. [a-z] (?: [a-z0-9-]* [a-z0-9] ) $ /xi)
1398 0 0 if ($a eq $$query{'ipv4'}) { }
0 0 elsif ($ip4_cidr_length < 32) { }
1407 0 0 if $cidr->find($$query{'ipv4'})
1424 0 0 if ($$query{'ipv6'})
1438 0 0 if ($ptr_to_a eq $$query{'ipv4'})
1442 0 0 if ($ptrdname =~ /(^|\.)\Q$domain_to_use\E$/i) { }
1463 0 0 unless $argument
1473 0 0 if (@txt)
1489 0 0 if ($cidr_spec eq '')
1495 0 0 if (not $network =~ /^\d+\.\d+\.\d+\.\d+$/ or defined $cidr_length and not $cidr_length =~ /^\d+$/)
1500 0 0 unless defined $cidr_length
1504 0 0 if ($@)
1508 0 0 if $cidr->find($$query{'ipv4'})
1575 0 0 if ($$query{'directive_set'}->explanation)
1588 0 0 unless exists $$query{$which_hash}
1598 0 0 $ancestor_level > 0 ? :
1600 0 0 if (my $record = $$query{$which_hash}{lc $match})
1602 0 0 wantarray ? :
1612 0 0 unless $record
1615 0 0 unless $record =~ /^v=spf1\b/i
1649 0 164 if ($override_text) { }
0 164 elsif (exists $$query{'override'}) { }
1659 164 0 unless (defined $txt)
1667 0 0 if /^v=spf1\s*(.*)$/
1671 164 0 if $$query{'error'} or $$query{'last_dns_error'} eq 'NXDOMAIN'
1675 0 164 if (not defined $txt and exists $$query{'fallback'})
1678 0 0 unless defined $txt
1682 0 164 if (not defined $txt and defined $default_record)
1690 164 0 unless defined $txt
1693 0 0 $txt =~ /^v=spf1/ ? :
1705 0 0 if ($word =~ /^v=(\S+)/i)
1709 0 0 if $version ne 'spf1'
1714 0 0 if (my($lhs, $rhs) = $word =~ m[^([^:/]+)=(\S*)$])
1724 0 0 if (my($prefix, $lhs, $rhs) = $word =~ m[^([-~+?]?)([\w_-]+)([/:]\S*)?$]i)
1735 0 0 if (my $rhs = delete $$directive_set{'modifiers'}{'default'})
1739 0 0 unless $$directive_set{'mechanisms'}
1740 0 0 if ($localpolicy)
1743 0 0 if ($$lastmech[0] eq '-' || $$lastmech[0] eq '?' and $$lastmech[1] eq 'all')
1748 0 0 if $$lastmech[0] ne $$mechanisms[$index][0]
1750 0 0 if ($index >= 0)
1755 0 0 if ($localset)
1760 0 0 $$_[1] eq 'include' ? :