| 1 | package Mail::DMARC::Base; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 21 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 21 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 21 | ▶ | use feature 'signatures'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 21 | ▶ | no warnings 'experimental::args_array_with_signatures'; ## no critic (ProhibitNoWarnings) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 21 | our $VERSION = '2.20261110'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 21 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 21 | ▶ | use Config::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 21 | ▶ | use File::ShareDir; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 21 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 21 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 21 | ▶ | use Net::DNS::Resolver; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 21 | ▶ | use Socket; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 21 | require URI::_idna; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 304 | ▶ | sub new( $class, @args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 304 | ▶ | croak "invalid args" if @args % 2 != 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 304 | return bless { | |||||||||||||||||||||||||||||||||||||||||
| 21 | config_file => 'mail-dmarc.ini', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | @args, # this may override config_file | ||||||||||||||||||||||||||||||||||||||||||
| 23 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 21 | my $_fake_time; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 63 | ▶ | sub time ($self) { ## no critic | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | # Ability to return a fake time for testing | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 63 | ▶ | my $time | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | = defined $Mail::DMARC::Base::_fake_time | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ? $Mail::DMARC::Base::_fake_time | ||||||||||||||||||||||||||||||||||||||||||
| 33 | : time; | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 63 | return $time; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 20 | ▶ | sub set_fake_time ( $self, $time ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_fake_time: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 20 | $Mail::DMARC::Base::_fake_time = $time; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 7259 | ▶ | sub config( $self, $file = undef, @too_many ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 7259 | ▶ | croak "invalid args" if @too_many; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 7259 | ▶ | return $self->{config} if ref $self->{config} && !$file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $self->{"config"} and not $file
MC/DC100%2/2
ref $self->{"config"} and not $file
ref $self->{"config"}
not $file
Truth table100%3/3
A and not(B)
A= ref $self->{"config"}B= not $file
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 193 | return $self->{config} = $self->get_config($file); | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 62 | ▶ | sub get_prefix( $self, $subdir = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_prefix: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | return | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 62 | ▶ | map { $_ . ( $subdir ? $subdir : '' ) } qw[ /usr/local/ /opt/local/ / ./ ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 45 | ▶ | sub get_sharefile( $self, $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_sharefile: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 45 | my $match = File::ShareDir::dist_file( 'Mail-DMARC', $file ); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 45 | ▶ | print "using $match for $file\n" if $self->verbose; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 45 | return $match; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 195 | ▶ | sub get_config( $self, $file = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_config: called CC=11 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 195 | ▶ | $file ||= $ENV{MAIL_DMARC_CONFIG_FILE} || $self->{config_file}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$file ||= $ENV{"MAIL_DMARC_CONFIG_FILE"} || $self->{"config_file"}
$ENV{'MAIL_DMARC_CONFIG_FILE'} || $self->{'config_file'}
MC/DC0%0/3
$file ||= $ENV{"MAIL_DMARC_CONFIG_FILE"} || $self->{"config_file"}
$file
$ENV{'MAIL_DMARC_CONFIG_FILE'}
$self->{'config_file'}
Truth table0%0/4
A ||= B || C
A= $fileB= $ENV{'MAIL_DMARC_CONFIG_FILE'}C= $self->{'config_file'}
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 195 | ▶ | croak if !$file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 195 | ▶ | return Config::Tiny->read($file) if -r $file; # fully qualified | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | # search <prefix>/etc and the mail/ subdir where mail daemons (and | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # FreeBSD ports, e.g. authentication_milter) conventionally install it | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 46 | foreach my $d ( map { ( $_, "$_/mail" ) } $self->get_prefix('etc') ) { | |||||||||||||||||||||||||||||||||||||||||
| 67 | 368 | ▶ | next if !-d $d; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 94 | ▶ | next if !-e "$d/$file"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | ▶ | croak "unreadable file: $d/$file" if !-r "$d/$file"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | return Config::Tiny->read("$d/$file"); | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 45 | ▶ | if ( $file ne 'mail-dmarc.ini' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | croak "unable to find requested config file $file\n"; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 44 | carp "no mail-dmarc.ini found; using bundled defaults.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 44 | return Config::Tiny->read( $self->get_sharefile('mail-dmarc.ini') ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 81 | ▶ | sub any_inet_ntop( $self, $ip_bin ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_inet_ntop: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 81 | ▶ | $ip_bin or croak "missing IP in request"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 81 | ▶ | if ( length $ip_bin == 16 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 6 | return Socket::inet_ntop( AF_INET6, $ip_bin ); | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 75 | return Socket::inet_ntop( AF_INET, $ip_bin ); | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 52 | ▶ | sub any_inet_pton( $self, $ip_txt ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_inet_pton: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 52 | ▶ | $ip_txt or croak "missing IP in request"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 52 | ▶ | if ( $ip_txt =~ /:/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 4 | ▶ | return Socket::inet_pton( AF_INET6, $ip_txt ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
Socket::inet_pton(10, $ip_txt) || croak("invalid IPv6: $ip_txt")
MC/DC0%0/1
Socket::inet_pton(10, $ip_txt) || croak("invalid IPv6: $ip_txt")
Socket::inet_pton(10, $ip_txt)
Truth table50%1/2
A
A= Socket::inet_pton(10, $ip_txt)
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | || croak "invalid IPv6: $ip_txt"; | ||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 48 | ▶ | return Socket::inet_pton( AF_INET, $ip_txt ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
Socket::inet_pton(2, $ip_txt) || croak("invalid IPv4: $ip_txt")
MC/DC0%0/1
Socket::inet_pton(2, $ip_txt) || croak("invalid IPv4: $ip_txt")
Socket::inet_pton(2, $ip_txt)
Truth table50%1/2
A
A= Socket::inet_pton(2, $ip_txt)
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | || croak "invalid IPv4: $ip_txt"; | ||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 21 | my $public_suffixes; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 21 | my $public_suffixes_stamp; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 377 | ▶ | sub get_public_suffix_list($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_public_suffix_list: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 377 | ▶ | if ($public_suffixes) { return $public_suffixes; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 21 | ▶ | no warnings 'once'; ## no critic | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 10 | $Mail::DMARC::psl_loads++; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 10 | my $file = $self->find_psl_file(); | |||||||||||||||||||||||||||||||||||||||||
| 112 | 10 | $public_suffixes_stamp = ( stat($file) )[9]; | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 10 | ▶ | open my $fh, '<:encoding(UTF-8)', $file | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | or croak "unable to open $file for read: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | # load PSL into hash for fast lookups, esp. for long running daemons | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 124870 | my %psl = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||
| 119 | 165970 | grep { $_ !~ /^[\/\s]/ } # weed out comments & whitespace | |||||||||||||||||||||||||||||||||||||||||
| 120 | 10 | map { chomp($_); $_ } ## no critic, remove line endings | |||||||||||||||||||||||||||||||||||||||||
| 121 | <$fh>; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 10 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 10 | return $public_suffixes = \%psl; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | ▶ | sub check_public_suffix_list($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_public_suffix_list: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | my $file = $self->find_psl_file(); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | my $new_public_suffixes_stamp = ( stat($file) )[9]; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | if ( $new_public_suffixes_stamp != $public_suffixes_stamp ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | $public_suffixes = undef; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | $self->get_public_suffix_list(); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 21 | ▶ | sub is_public_suffix( $self, $zone ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_public_suffix: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 382 | ▶ | croak "missing zone name!" if !$zone; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 382 | my $public_suffixes = $self->get_public_suffix_list(); | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 382 | ▶ | $zone = URI::_idna::decode( $zone, 0 ) // $zone if $zone =~ /xn--/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
URI::_idna::decode($zone, 0) // $zone
MC/DC0%0/2
URI::_idna::decode($zone, 0) // $zone
URI::_idna::decode($zone, 0)
$zone
Truth table33%1/3
A // B
A= URI::_idna::decode($zone, 0)B= $zone
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | # Check for exception rules | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 382 | ▶ | return 0 if $public_suffixes->{"!$zone"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | # Check for direct match | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 381 | ▶ | return 1 if $public_suffixes->{$zone}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # Check for wildcard match | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 98 | my @labels = split /\./, $zone; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 98 | ▶ | if ( @labels > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 87 | my $wildcard = join '.', '*', (@labels)[ 1 .. scalar(@labels) - 1 ]; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 87 | ▶ | return 1 if $public_suffixes->{$wildcard}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 96 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub update_psl_file( $self, $dryrun = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_psl_file: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $psl_file = $self->find_psl_file(); | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | die "No Public Suffix List file found\n" if ( !$psl_file ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | die "Public suffix list file $psl_file not found\n" if ( !-f $psl_file ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | die "Cannot write to Public Suffix List file $psl_file\n" if ( !-w $psl_file ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $url = 'https://publicsuffix.org/list/effective_tld_names.dat'; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ($dryrun) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 171 | "Will attempt to update the Public Suffix List file at $psl_file (dryrun mode)\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $response = HTTP::Tiny->new->mirror( $url, $psl_file ); | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $content = $response->{'content'}; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( !$response->{'success'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $status = $response->{'status'}; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | die | |||||||||||||||||||||||||||||||||||||||||
| 180 | "HTTP Request for Public Suffix List file failed with error $status ($content)\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if ( $response->{'status'} eq '304' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | print "Public Suffix List file $psl_file not modified\n"; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | print "Public Suffix List file $psl_file updated\n"; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 13 | ▶ | sub find_psl_file($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_psl_file: called CC=9 SCAR=28.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | my $file | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 13 | ▶ | = $self->config->{dns}{public_suffix_list} || 'share/public_suffix_list'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->config->{'dns'}{'public_suffix_list'} || 'share/public_suffix_list'
MC/DC0%0/1
$self->config->{'dns'}{'public_suffix_list'} || 'share/public_suffix_list'
$self->config->{'dns'}{'public_suffix_list'}
Truth table50%1/2
A
A= $self->config->{'dns'}{'public_suffix_list'}
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 13 | ▶ | if ( $file =~ /^\// && -f $file && -r $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$file =~ m[^/] and -f $file and -r $file
$file =~ m[^/] and -f $file
MC/DC0%0/3
$file =~ m[^/] and -f $file and -r $file
$file =~ m[^/]
-f $file
-r $file
Truth table25%1/4
A and B and C
A= $file =~ m[^/]B= -f $fileC= -r $file
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | print "using $file for Public Suffix List\n" if $self->verbose; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return $file; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 13 | foreach my $path ( $self->get_prefix($file) ) { | |||||||||||||||||||||||||||||||||||||||||
| 202 | 52 | ▶ | if ( -f $path && -r $path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-f $path and -r $path
MC/DC50%1/2
-f $path and -r $path
-f $path
-r $path
Truth table66%2/3
A and B
A= -f $pathB= -r $path
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 13 | print "using $path for Public Suffix List\n"; # if $self->verbose; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 13 | return $path; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | # Fallback to included suffic list | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | return $self->get_sharefile('public_suffix_list'); | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 5 | ▶ | sub has_dns_rr( $self, $type, $domain ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_dns_rr: called CC=13 SCAR=46.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | my @matches; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | my $res = $self->get_resolver(); | |||||||||||||||||||||||||||||||||||||||||
| 215 | 5 | ▶ | my $query = $res->query( $domain, $type ) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | ▶ | return 0 if !wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | return @matches; | |||||||||||||||||||||||||||||||||||||||||
| 218 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | for my $rr ( $query->answer ) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | next if $rr->type ne $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | push @matches, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | $rr->type eq 'A' ? $rr->address | ||||||||||||||||||||||||||||||||||||||||||
| 223 | : $rr->type eq 'PTR' ? $rr->ptrdname | ||||||||||||||||||||||||||||||||||||||||||
| 224 | : $rr->type eq 'NS' ? $rr->nsdname | ||||||||||||||||||||||||||||||||||||||||||
| 225 | : $rr->type eq 'TXT' ? $rr->txtdata | ||||||||||||||||||||||||||||||||||||||||||
| 226 | : $rr->type eq 'SPF' ? $rr->txtdata | ||||||||||||||||||||||||||||||||||||||||||
| 227 | : $rr->type eq 'AAAA' ? $rr->address | ||||||||||||||||||||||||||||||||||||||||||
| 228 | : $rr->type eq 'MX' ? $rr->exchange | ||||||||||||||||||||||||||||||||||||||||||
| 229 | : $rr->answer; | ||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return scalar @matches if !wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | return @matches; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 65 | ▶ | sub epoch_to_iso( $self, $epoch ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
epoch_to_iso: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 65 | my @fields = localtime($epoch); | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 65 | my $ss = sprintf( "%02i", $fields[0] ); # seconds | |||||||||||||||||||||||||||||||||||||||||
| 239 | 65 | my $mn = sprintf( "%02i", $fields[1] ); # minutes | |||||||||||||||||||||||||||||||||||||||||
| 240 | 65 | my $hh = sprintf( "%02i", $fields[2] ); # hours (24 hour clock) | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 65 | my $dd = sprintf( "%02i", $fields[3] ); # day of month | |||||||||||||||||||||||||||||||||||||||||
| 243 | 65 | my $mm = sprintf( "%02i", $fields[4] + 1 ); # month | |||||||||||||||||||||||||||||||||||||||||
| 244 | 65 | my $yy = ( $fields[5] + 1900 ); # year | |||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 65 | return "$yy-$mm-$dd" . 'T' . "$hh:$mn:$ss"; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 359 | ▶ | sub get_resolver( $self, $timeout = undef, $retrans = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_resolver: called CC=8 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 359 | ▶ | $timeout ||= $self->config->{dns}{timeout} || 5; | ||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$timeout ||= $self->config->{"dns"}{"timeout"} || 5
$self->config->{'dns'}{'timeout'} || 5
MC/DC0%0/2
$timeout ||= $self->config->{"dns"}{"timeout"} || 5
$timeout
$self->config->{'dns'}{'timeout'}
Truth table33%1/3
A ||= B
A= $timeoutB= $self->config->{'dns'}{'timeout'}
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 359 | ▶ | $retrans ||= $self->config->{dns}{retrans} || 5; | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$retrans ||= $self->config->{"dns"}{"retrans"} || 5
$self->config->{'dns'}{'retrans'} || 5
MC/DC0%0/2
$retrans ||= $self->config->{"dns"}{"retrans"} || 5
$retrans
$self->config->{'dns'}{'retrans'}
Truth table33%1/3
A ||= B
A= $retransB= $self->config->{'dns'}{'retrans'}
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 359 | ▶ | return $self->{resolver} if defined $self->{resolver}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | $self->{resolver} = Net::DNS::Resolver->new( dnsrch => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | $self->{resolver}->tcp_timeout($timeout); | |||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | $self->{resolver}->udp_timeout($timeout); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | $self->{resolver}->retrans($retrans); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 3 | return $self->{resolver}; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 79 | ▶ | sub set_resolver( $self, $resolver ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_resolver: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 79 | $self->{resolver} = $resolver; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 79 | return; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 391 | ▶ | sub normalize_domain( $self, $domain ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_domain: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 391 | ( my $normal = lc $domain ) =~ s/\.$//; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 391 | return $normal; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 28 | ▶ | sub to_ascii_domain( $self, $domain ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_ascii_domain: called CC=4 SCAR=26.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 28 | ▶ | return $domain unless $domain =~ /[^\x00-\x7F]/; # fast path: ASCII only | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | # Convert each U-label to its A-label (punycode) equivalent per RFC 8616 ยง6 | ||||||||||||||||||||||||||||||||||||||||||
| 273 | my @ascii_labels = map { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (/[^\x00-\x7F]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $ascii = eval { URI::_idna::encode($_) }; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | $ascii // $_; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ascii // $_
MC/DC0%0/2
$ascii // $_
$ascii
$_
Truth table0%0/3
A // B
A= $asciiB= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $_; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | } split /\./, $domain; | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return join '.', @ascii_labels; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 60 | ▶ | sub is_valid_ip( $self, $ip ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_ip: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 60 | ▶ | return 0 if !defined $ip; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 59 | ▶ | my $family = $ip =~ /:/ ? AF_INET6 : AF_INET; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 59 | ▶ | return defined Socket::inet_pton( $family, $ip ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | # RFC 1101 | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 21 | my $dotted_quad = qr/(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})/; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 21 | my $not_an_ip = qr/(?!(?:$dotted_quad[.]$dotted_quad[.]$dotted_quad[.]$dotted_quad)(?:[.]|$))/; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 21 | my $host_label = qr/$not_an_ip[A-Za-z0-9](?:[-A-Za-z0-9]{0,61}[A-Za-z0-9])?/; | |||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 224 | ▶ | sub is_valid_domain( $self, $domain ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_domain: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 224 | ▶ | return 0 if $domain !~ /^$host_label(?:\.$host_label)*$/x; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 222 | my $tld = ( split /\./, $domain )[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 222 | ▶ | return 1 if $self->is_public_suffix($tld); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 6 | ▶ | return 0 if $domain eq 'localhost'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 6 | ▶ | return 0 if $tld eq 'localdomain'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 6 | ▶ | return 0 if -1 == index( $domain, '.' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 6 | $tld = join( '.', ( split /\./, $domain )[ -2, -1 ] ); | |||||||||||||||||||||||||||||||||||||||||
| 305 | 6 | ▶ | return 1 if $self->is_public_suffix($tld); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 5 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 113 | ▶ | sub is_valid_spf_scope( $self, $scope ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_spf_scope: called CC=3 SCAR=13.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 113 | ▶ | return if !defined $scope; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 113 | ▶ | return lc $scope if grep { lc $scope eq $_ } qw/ mfrom helo /; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | carp "$scope is not a valid SPF scope"; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 115 | ▶ | sub is_valid_spf_result( $self, $result ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_spf_result: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 115 | ▶ | return if !defined $result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | return 1 | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 114 | ▶ | if grep { lc $result eq $_ } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | qw/ fail neutral none pass permerror softfail temperror /; | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | carp "$result is not a valid SPF result"; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 30 | ▶ | sub slurp( $self, $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slurp: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 30 | ▶ | open my $FH, '<', $file or croak "unable to read $file: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 30 | my $contents = do { local $/; <$FH> }; ## no critic (Local) | |||||||||||||||||||||||||||||||||||||||||
| 328 | 30 | close $FH; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 30 | return $contents; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 649 | ▶ | sub verbose( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 649 | ▶ | return $self->{verbose} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 14 | return $self->{verbose} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 21 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | __END__ | ||||||||||||||||||||||||||||||||||||||||||