Branch Coverage

blib/lib/Mail/DMARC/Iterator.pm
Criterion Covered Total %
branch 140 354 39.5


line true false branch
41 2 0 if @_ == 1
44 0 0 if ($_[$i] eq 'DebugFunc' or $_[$i] eq 'Debug')
50 0 0 if @_ > 1
83 0 7 if ($args{'spf_result'}) { }
4 3 elsif ($args{'ip'} and $args{'mailfrom'} and $args{'helo'}) { }
0 3 elsif (exists $args{'spf_result'}) { }
96 0 7 if ($args{'dkim_result'}) { }
2 5 elsif ($args{'dkim_sub'}) { }
127 0 60 if $self->{'result'}
128 34 26 unless @input
135 12 14 unless (ref $data)
136 0 12 if $Mail::DMARC::Iterator::DEBUG
137 8 4 if (not $self->{'domain'} and defined $self->{'_hdrbuf'})
141 10 2 if ($self->{'dkim'})
152 0 14 if (not UNIVERSAL::isa($data, 'Net::DNS::Packet')) { }
155 0 0 if $Mail::DMARC::Iterator::DEBUG
158 0 14 if $Mail::DMARC::Iterator::DEBUG
165 0 14 unless ($cb)
168 0 0 unless defined $cb
174 0 14 if $self->{'dnscache'}
182 0 35 if $self->{'result'}
183 8 27 unless $self->{'domain'}
189 7 20 unless my $rec = $self->{'record'}
192 2 18 if ($self->{'dkim_sub'} and my $r = $self->{'dkim_result'}[0] = $self->{'dkim_sub'}->())
194 2 0 if $self->{'domrx'}
196 20 0 if ($self->{'dkim_result'})
197 4 16 if ($self->{'dkim'} and not $self->{'dkim_result'}[1])
199 0 4 unless $self->{'dkim_result'}[0]
200 0 4 if $Mail::DMARC::Iterator::DEBUG
203 1 19 unless $self->{'dkim_result'}[0]
204 0 19 if $Mail::DMARC::Iterator::DEBUG
207 6 0 if ($st == 1) { }
0 0 elsif ($st == -2 or $st == -1) { }
0 0 elsif ($st == 0) { }
225 0 14 unless my $sr = $self->{'spf_result'}
226 9 5 unless defined $sr->[0]
232 0 5 $rec->{'aspf'} eq 's' ? :
1 4 if ($rec->{'aspf'} eq 's' ? lc $from ne $rec->{'domain'} : !($from =~ /^([\w\-\.]+\.)?\Q$rec->{'domain'}\E/i))
236 0 1 if $Mail::DMARC::Iterator::DEBUG
244 0 4 if $Mail::DMARC::Iterator::DEBUG
246 1 3 if ($sr->[0] eq 'Pass')
253 0 0 $sr->[0] eq 'TempError' ? :
0 0 $sr->[0] eq 'PermError' ? :
0 0 $sr->[0] eq 'SoftFail' ? :
3 0 $sr->[0] eq 'Fail' ? :
260 1 0 if ($dkim_result || !$self->{'dkim'} and $spf_result || !$self->{'spf'})
267 0 0 $dkim_result ? :
0 0 $spf_result ? :
0 1 if $Mail::DMARC::Iterator::DEBUG
271 2 0 unless defined $_->[0]
272 0 0 if (not $best) { }
0 0 elsif ($_->[0] and $_->[0] > $best->[0]) { }
278 1 0 if ($self->{'dkim_sub'} and !$best || $best->[0] != 1 and !$self->{'dkim_result'}[0] || grep({not $_->status;} @{$$self{'dkim_result'}[0];}))
281 0 1 if $Mail::DMARC::Iterator::DEBUG
297 8 19 if (not $self->{'domain'}) { }
7 12 elsif (my $dom = $self->{'_dmarc_domain'}) { }
299 0 8 if $Mail::DMARC::Iterator::DEBUG
303 0 7 if $Mail::DMARC::Iterator::DEBUG
313 15 12 unless $self->{'record'}
315 12 0 if ($self->{'dkim'})
319 0 12 if (not $self->{'dkim_result'}[1]) { }
321 0 0 if $Mail::DMARC::Iterator::DEBUG
329 12 8 if (ref $todo) { }
330 0 12 if $Mail::DMARC::Iterator::DEBUG
333 0 8 if $Mail::DMARC::Iterator::DEBUG
345 6 6 if ($self->{'spf'}) { }
0 6 elsif (not $self->{'spf_result'}) { }
349 1 5 if ($self->{'spf_result'}[0]) { }
352 0 1 if $Mail::DMARC::Iterator::DEBUG
362 0 5 if $Mail::DMARC::Iterator::DEBUG
369 0 0 if $Mail::DMARC::Iterator::DEBUG
376 19 7 if $need_data
383 0 19 if ($self->{'dnscache'} and my $cached = $self->{'dnscache'}{$q->qtype . ':' . $q->qname}) { }
386 0 0 if $Mail::DMARC::Iterator::DEBUG
392 0 19 if $Mail::DMARC::Iterator::DEBUG
396 0 26 if @input
398 0 26 if ($Mail::DMARC::Iterator::DEBUG)
400 0 0 if (not ref $_) { }
413 0 7 unless $self->{'result'}
414 7 0 unless (defined $self->{'result'}[2])
415 0 7 if ($self->{'result'}[0] == 0) { }
416 0 0 if ($rec->{'sp'} and $rec->{'domain'} ne $self->{'domain'}[0]) { }
425 0 7 if ($Mail::DMARC::Iterator::DEBUG)
431 0 0 unless $self->{'result'}
451 0 7 if $error
460 0 7 unless $_->type eq 'TXT'
463 0 7 unless $txt =~ /^\s*v=DMARC1[\s;]/
464 0 7 if $Mail::DMARC::Iterator::DEBUG
465 0 7 unless my $v = parse_taglist($txt, \$error)
466 0 7 unless $v = _check_dmarc_record($v)
470 0 7 unless @record
476 0 7 if ($record[0]{'pct'} < 100 and rand 100 < $record[0]{'pct'})
478 0 0 if $Mail::DMARC::Iterator::DEBUG
487 0 7 if (@{$self->{'domain'};} > 1 and $dom ne $self->{'domain'}[0])
492 0 7 if $Mail::DMARC::Iterator::DEBUG
496 7 0 if ($record[0]{'adkim'} eq 'r') { }
504 5 2 if ($self->{'dkim'}) { }
2 0 elsif ($self->{'dkim_result'}) { }
514 0 7 if ($self->{'spf_result'} and ref $self->{'spf_result'}[0] eq 'ARRAY')
517 0 0 $record[0]{'aspf'} eq 'r' ? :
0 0 $record[0]{'aspf'} eq $record[0]{'adkim'} ? :
522 0 0 unless my $from = $_->[1]{'envelope-from'}
525 0 0 unless $from =~ /$domrx/
528 0 0 if (@aligned > 1) { }
0 0 elsif (@aligned) { }
531 0 0 unless my(@a) = grep({$_->[0] eq $_;} @aligned)
535 0 0 if $Mail::DMARC::Iterator::DEBUG
537 0 0 if $Mail::DMARC::Iterator::DEBUG
539 0 0 if $Mail::DMARC::Iterator::DEBUG
541 0 0 !@aligned ? :
549 0 0 @$dom > 1 ? :
0 0 if $Mail::DMARC::Iterator::DEBUG
556 0 0 if (@$dom) { }
564 0 0 if $Mail::DMARC::Iterator::DEBUG
566 0 0 $error ? :
591 21 56 if (defined $v->{$k}) { }
42 14 elsif (defined $default) { }
592 0 21 unless ($v->{$k} =~ /$rx/)
593 0 0 if $Mail::DMARC::Iterator::DEBUG
598 0 42 if (ref $default)
599 0 0 if $Mail::DMARC::Iterator::DEBUG
610 0 4 if ($error) { }
611 0 0 if $Mail::DMARC::Iterator::DEBUG
614 4 0 $_->type eq 'TXT' ? :
615 0 4 if $Mail::DMARC::Iterator::DEBUG
622 0 3 if ($error) { }
628 3 0 if (not defined $rv[0] or $rv[0] ne '') { }
647 0 8 if $data eq ''
662 7 24 if ($2)
664 0 7 if $Mail::DMARC::Iterator::DEBUG
671 0 8 if @hdr and defined $self->{'_hdrbuf'}
679 31 0 $self->{'spf'} || $self->{'spf_result'} ? :
24 7 unless $self->{'spf'} || $self->{'spf_result'} ? s/^(From)\s*:\s*//i : s/^(?:(From)\s*|Received-SPF):\s*//i
682 7 0 if ($1) { }
684 0 7 if $Mail::DMARC::Iterator::DEBUG
688 0 0 if $Mail::DMARC::Iterator::DEBUG
694 1 7 if (defined $self->{'_hdrbuf'})
695 1 0 if $data ne ''
701 7 0 unless ($self->{'domain'})
703 0 7 if (not $from) { }
0 7 elsif (@$from != 1) { }
704 0 0 if $Mail::DMARC::Iterator::DEBUG
708 0 0 if $Mail::DMARC::Iterator::DEBUG
714 7 0 if (my $dom = organizational_domain($from->[0]))
715 0 7 if $dom ne $from->[0]
719 0 7 if $Mail::DMARC::Iterator::DEBUG
723 0 7 if (not $self->{'spf_result'} || $self->{'spf'})
725 0 0 unless delete $self->{'_spfr'}
726 0 0 unless my($result, $hash) = _parse_spfreceived($_)
727 0 0 unless (my $from = $hash->{'envelope-from'})
728 0 0 if $Mail::DMARC::Iterator::DEBUG
733 0 0 unless @dom == 1
735 0 0 if $Mail::DMARC::Iterator::DEBUG
738 0 0 @records ? :
750 14 0 if (not @state) { }
0 0 elsif ($state[-1] eq '<') { }
0 0 elsif ($state[-1] eq '"') { }
0 0 elsif ($state[-1] eq '(') { }
751 0 14 unless /\G ([^<,\"\(]*) (?: ([<\(\"]) | (,) | \z) /cgx
752 0 14 if ($2) { }
7 7 elsif ($1 ne '') { }
7 0 elsif (not $3) { }
755 7 0 if (my $x = $1) =~ /^\s*$addr\s*\z/
761 0 0 unless /\G(?: $addr | (?:[^>]*) ) > /cgx
763 0 0 if $1
766 0 0 unless /\G (?:[^"\\]+|\\.)* \"/cgx
770 0 0 unless /\G .*? ([()]) /cgsx
771 0 0 if ($1 eq ')') { }
778 0 7 if $Mail::DMARC::Iterator::DEBUG
799 0 0 unless /\G($res)\s+/cig
804 0 0 if ($comment) { }
0 0 elsif (/\G($key)$fws?=$fws?($val)\s*(;\s*)?/cg) { }
0 0 elsif (not %hash || defined $comment and /\G\(/cg) { }
805 0 0 unless /\G[^()]*([()])\s*/cg
806 0 0 $1 eq '(' ? :
809 0 0 if $v =~ s/\A\"(.*)\"\z/$1/
811 0 0 unless $delim