Branch Coverage

blib/lib/Mojolicious/Plugin/TrustedProxy.pm
Criterion Covered Total %
branch 45 54 83.3


line true false branch
24 0 8 unless ref $conf->{'ip_headers'} eq 'ARRAY'
28 0 8 unless ref $conf->{'scheme_headers'} eq 'ARRAY'
32 0 8 unless ref $conf->{'https_values'} eq 'ARRAY'
38 1 7 unless ref $conf->{'trusted_sources'} eq 'ARRAY'
46 3 13 unless @_
54 0 13 if (ref $trust eq 'ARRAY') { }
72 0 24 unless is_ip($ip) and $cidr and $cidr->isa('Net::CIDR::Lite')
73 0 24 if is_ipv4_mapped_ipv6($ip)
84 0 24 unless defined $conf
88 4 20 unless (defined $src_addr and $c->is_trusted_source($src_addr))
97 9 24 if (my $ip = $c->req->headers->header($header))
99 5 4 if (lc $header eq 'x-forwarded-for')
106 8 1 if is_ip($ip)
114 6 31 if (my $scheme = $c->req->headers->header($header))
116 4 2 if (not !$scheme and grep {$scheme eq lc $_;} @{$$conf{'https_values'};})
127 5 15 if (my $fwd = $c->req->headers->header('forwarded'))
128 5 0 if ($conf->{'parse_rfc7239'})
139 4 4 if ($param =~ /(for|by)=($ipv4_mask|$ipv6_mask)/i) { }
2 2 elsif ($param =~ /proto=(https?)/i) { }
2 0 elsif ($param =~ /host=((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]))$/i) { }
140 2 2 if lc $1 eq 'for'
141 2 2 if lc $1 eq 'by'
148 2 3 if ($fwd_for and is_ip($fwd_for))
155 2 3 if ($fwd_by and is_ip($fwd_by))
161 2 3 if ($fwd_proto)
167 2 3 if ($fwd_host)
177 1 19 unless (not $conf->{'hide_headers'})