| 1 | package Zonemaster::Engine::Profile; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use v5.16.0; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use version; our $VERSION = version->declare( "v1.2.22" ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use File::ShareDir qw[dist_file]; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use JSON::PP qw( encode_json decode_json ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Scalar::Util qw(reftype looks_like_number); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Slurp; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Clone qw(clone); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Net::IP::XS; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Log::Any qw( $log ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use YAML::XS qw(); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | $YAML::XS::Boolean = "JSON::PP"; | |||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Zonemaster::Engine::Constants qw( $DURATION_5_MINUTES_IN_SECONDS $DURATION_1_HOUR_IN_SECONDS $DURATION_4_HOURS_IN_SECONDS $DURATION_12_HOURS_IN_SECONDS $DURATION_1_DAY_IN_SECONDS $DURATION_1_WEEK_IN_SECONDS $DURATION_180_DAYS_IN_SECONDS ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Zonemaster::Engine::Validation qw( validate_ipv4 validate_ipv6 ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||
| 23 | my %profile_properties_details = ( | ||||||||||||||||||||||||||||||||||||||||
| 24 | q{cache} => { | ||||||||||||||||||||||||||||||||||||||||
| 25 | type => q{HashRef}, | ||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | test => sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=44.4
| |||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my @allowed_keys = ( 'redis' ); | |||||||||||||||||||||||||||||||||||||||
| 28 | 1 | foreach my $cache_database ( keys %{$_[0]} ) { | |||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ( not grep( /^$cache_database$/, @allowed_keys ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | die "Property cache keys have " . scalar @allowed_keys . " possible values: " . join(", ", @allowed_keys) . "\n"; | |||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ( not scalar keys %{ $_[0]->{$cache_database} } ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | die "Property cache.$cache_database has no items\n"; | |||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||
| 36 | else { | ||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my @allowed_subkeys; | |||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ( $cache_database eq 'redis' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | @allowed_subkeys = ( 'server', 'expire' ); | |||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | foreach my $key ( keys %{ $_[0]->{$cache_database} } ) { | |||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ( not grep( /^$key$/, @allowed_subkeys ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | die "Property cache.$cache_database subkeys have " . scalar @allowed_subkeys . " possible values: " . join(", ", @allowed_subkeys) . "\n"; | |||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | die "Property cache.$cache_database.$key has a NULL or empty item\n" if not $_[0]->{$cache_database}->{$key}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | die "Property cache.$cache_database.$key has a negative value\n" if ( looks_like_number( $_[0]->{$cache_database}->{$key} ) and $_[0]->{$cache_database}->{$key} < 0 ) ; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&looks_like_number($_[0]{$cache_database}{$key}) and $_[0]{$cache_database}{$key} < 0
MC/DC0%0/2
&looks_like_number($_[0]{$cache_database}{$key}) and $_[0]{$cache_database}{$key} < 0
&looks_like_number($_[0]{$cache_database}{$key})
$_[0]{$cache_database}{$key} < 0
Truth table0%0/3
A and B
A= &looks_like_number($_[0]{$cache_database}{$key})B= $_[0]{$cache_database}{$key} < 0
| |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||||||||||||||
| 53 | default => {}, | ||||||||||||||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||||||||||||||
| 55 | q{resolver.defaults.debug} => { | ||||||||||||||||||||||||||||||||||||||||
| 56 | type => q{Bool} | ||||||||||||||||||||||||||||||||||||||||
| 57 | }, | ||||||||||||||||||||||||||||||||||||||||
| 58 | q{resolver.defaults.fallback} => { | ||||||||||||||||||||||||||||||||||||||||
| 59 | type => q{Bool} | ||||||||||||||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||||||||||||||
| 61 | q{resolver.defaults.retrans} => { | ||||||||||||||||||||||||||||||||||||||||
| 62 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 63 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 64 | max => 255 | ||||||||||||||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||||||||||||||
| 66 | q{resolver.defaults.retry} => { | ||||||||||||||||||||||||||||||||||||||||
| 67 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 68 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 69 | max => 255 | ||||||||||||||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||||||||||||||
| 71 | q{resolver.defaults.timeout} => { | ||||||||||||||||||||||||||||||||||||||||
| 72 | type => q{Num} | ||||||||||||||||||||||||||||||||||||||||
| 73 | }, | ||||||||||||||||||||||||||||||||||||||||
| 74 | q{resolver.source4} => { | ||||||||||||||||||||||||||||||||||||||||
| 75 | type => q{Str}, | ||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | test => sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=15.4
| |||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | unless ( $_[0] eq '' or validate_ipv4( $_[0] ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0] eq "" or validate_ipv4($_[0])
MC/DC0%0/2
$_[0] eq "" or validate_ipv4($_[0])
$_[0] eq ""
validate_ipv4($_[0])
Truth table33%1/3
A or B
A= $_[0] eq ""B= validate_ipv4($_[0])
| |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | die "Property resolver.source4 must be an IPv4 address or the empty string\n"; | |||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||
| 80 | }, | ||||||||||||||||||||||||||||||||||||||||
| 81 | default => q{} | ||||||||||||||||||||||||||||||||||||||||
| 82 | }, | ||||||||||||||||||||||||||||||||||||||||
| 83 | q{resolver.source6} => { | ||||||||||||||||||||||||||||||||||||||||
| 84 | type => q{Str}, | ||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | test => sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=15.4
| |||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | unless ( $_[0] eq '' or validate_ipv6( $_[0] ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0] eq "" or validate_ipv6($_[0])
MC/DC0%0/2
$_[0] eq "" or validate_ipv6($_[0])
$_[0] eq ""
validate_ipv6($_[0])
Truth table33%1/3
A or B
A= $_[0] eq ""B= validate_ipv6($_[0])
| |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | die "Property resolver.source6 must be a valid IPv6 address or the empty string\n"; | |||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||
| 89 | }, | ||||||||||||||||||||||||||||||||||||||||
| 90 | default => q{} | ||||||||||||||||||||||||||||||||||||||||
| 91 | }, | ||||||||||||||||||||||||||||||||||||||||
| 92 | q{net.ipv4} => { | ||||||||||||||||||||||||||||||||||||||||
| 93 | type => q{Bool} | ||||||||||||||||||||||||||||||||||||||||
| 94 | }, | ||||||||||||||||||||||||||||||||||||||||
| 95 | q{net.ipv6} => { | ||||||||||||||||||||||||||||||||||||||||
| 96 | type => q{Bool} | ||||||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||||||
| 98 | q{no_network} => { | ||||||||||||||||||||||||||||||||||||||||
| 99 | type => q{Bool} | ||||||||||||||||||||||||||||||||||||||||
| 100 | }, | ||||||||||||||||||||||||||||||||||||||||
| 101 | q{asn_db.style} => { | ||||||||||||||||||||||||||||||||||||||||
| 102 | type => q{Str}, | ||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | test => sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | if ( lc($_[0]) ne q{cymru} and lc($_[0]) ne q{ripe} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
lc $_[0] ne "cymru" and lc $_[0] ne "ripe"
MC/DC0%0/2
lc $_[0] ne "cymru" and lc $_[0] ne "ripe"
lc $_[0] ne "cymru"
lc $_[0] ne "ripe"
Truth table33%1/3
A and B
A= lc $_[0] ne "cymru"B= lc $_[0] ne "ripe"
| |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | die "Property asn_db.style has 2 possible values : Cymru or RIPE (case-insensitive)\n"; | |||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | $_[0] = lc($_[0]); | |||||||||||||||||||||||||||||||||||||||
| 108 | }, | ||||||||||||||||||||||||||||||||||||||||
| 109 | default => q{cymru} | ||||||||||||||||||||||||||||||||||||||||
| 110 | }, | ||||||||||||||||||||||||||||||||||||||||
| 111 | q{asn_db.sources} => { | ||||||||||||||||||||||||||||||||||||||||
| 112 | type => q{HashRef}, | ||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | test => sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=25.8
| |||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | foreach my $db_style ( keys %{$_[0]} ) { | |||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | if ( lc($db_style) ne q{cymru} and lc($db_style) ne q{ripe} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
lc $db_style ne "cymru" and lc $db_style ne "ripe"
MC/DC0%0/2
lc $db_style ne "cymru" and lc $db_style ne "ripe"
lc $db_style ne "cymru"
lc $db_style ne "ripe"
Truth table66%2/3
A and B
A= lc $db_style ne "cymru"B= lc $db_style ne "ripe"
| |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | die "Property asn_db.sources keys have 2 possible values : Cymru or RIPE (case-insensitive)\n"; | |||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | if ( not scalar @{ ${$_[0]}{$db_style} } ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | die "Property asn_db.sources.$db_style has no items\n"; | |||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||
| 121 | else { | ||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | foreach my $ndd ( @{ ${$_[0]}{$db_style} } ) { | |||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | die "Property asn_db.sources.$db_style has a NULL item\n" if not defined $ndd; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | die "Property asn_db.sources.$db_style has a non scalar item\n" if not defined ref($ndd); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | ▶ | die "Property asn_db.sources.$db_style has an item too long\n" if length($ndd) > 255; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | foreach my $label ( split /[.]/, $ndd ) { | |||||||||||||||||||||||||||||||||||||||
| 127 | 9 | ▶ | die "Property asn_db.sources.$db_style has a non domain name item\n" if $label !~ /^[a-z0-9](?:[-a-z0-9]{0,61}[a-z0-9])?$/; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | ${$_[0]}{lc($db_style)} = delete ${$_[0]}{$db_style}; | |||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||
| 133 | }, | ||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | default => { cymru => [ "asnlookup.zonemaster.net" ] }, | |||||||||||||||||||||||||||||||||||||||
| 135 | }, | ||||||||||||||||||||||||||||||||||||||||
| 136 | q{logfilter} => { | ||||||||||||||||||||||||||||||||||||||||
| 137 | type => q{HashRef}, | ||||||||||||||||||||||||||||||||||||||||
| 138 | default => {} | ||||||||||||||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||||||||||||||
| 140 | q{test_levels} => { | ||||||||||||||||||||||||||||||||||||||||
| 141 | type => q{HashRef} | ||||||||||||||||||||||||||||||||||||||||
| 142 | }, | ||||||||||||||||||||||||||||||||||||||||
| 143 | q{test_cases} => { | ||||||||||||||||||||||||||||||||||||||||
| 144 | type => q{ArrayRef} | ||||||||||||||||||||||||||||||||||||||||
| 145 | }, | ||||||||||||||||||||||||||||||||||||||||
| 146 | q{test_cases_vars.dnssec04.REMAINING_SHORT} => { | ||||||||||||||||||||||||||||||||||||||||
| 147 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 148 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 149 | default => $DURATION_12_HOURS_IN_SECONDS | ||||||||||||||||||||||||||||||||||||||||
| 150 | }, | ||||||||||||||||||||||||||||||||||||||||
| 151 | q{test_cases_vars.dnssec04.REMAINING_LONG} => { | ||||||||||||||||||||||||||||||||||||||||
| 152 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 153 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 154 | default => $DURATION_180_DAYS_IN_SECONDS | ||||||||||||||||||||||||||||||||||||||||
| 155 | }, | ||||||||||||||||||||||||||||||||||||||||
| 156 | q{test_cases_vars.dnssec04.DURATION_LONG} => { | ||||||||||||||||||||||||||||||||||||||||
| 157 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 158 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 159 | default => $DURATION_180_DAYS_IN_SECONDS | ||||||||||||||||||||||||||||||||||||||||
| 160 | }, | ||||||||||||||||||||||||||||||||||||||||
| 161 | q{test_cases_vars.zone02.SOA_REFRESH_MINIMUM_VALUE} => { | ||||||||||||||||||||||||||||||||||||||||
| 162 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 163 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 164 | default => $DURATION_4_HOURS_IN_SECONDS | ||||||||||||||||||||||||||||||||||||||||
| 165 | }, | ||||||||||||||||||||||||||||||||||||||||
| 166 | q{test_cases_vars.zone04.SOA_RETRY_MINIMUM_VALUE} => { | ||||||||||||||||||||||||||||||||||||||||
| 167 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 168 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 169 | default => $DURATION_1_HOUR_IN_SECONDS | ||||||||||||||||||||||||||||||||||||||||
| 170 | }, | ||||||||||||||||||||||||||||||||||||||||
| 171 | q{test_cases_vars.zone05.SOA_EXPIRE_MINIMUM_VALUE} => { | ||||||||||||||||||||||||||||||||||||||||
| 172 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 173 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 174 | default => $DURATION_1_WEEK_IN_SECONDS | ||||||||||||||||||||||||||||||||||||||||
| 175 | }, | ||||||||||||||||||||||||||||||||||||||||
| 176 | q{test_cases_vars.zone06.SOA_DEFAULT_TTL_MAXIMUM_VALUE} => { | ||||||||||||||||||||||||||||||||||||||||
| 177 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 178 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 179 | default => $DURATION_1_DAY_IN_SECONDS | ||||||||||||||||||||||||||||||||||||||||
| 180 | }, | ||||||||||||||||||||||||||||||||||||||||
| 181 | q{test_cases_vars.zone06.SOA_DEFAULT_TTL_MINIMUM_VALUE} => { | ||||||||||||||||||||||||||||||||||||||||
| 182 | type => q{Num}, | ||||||||||||||||||||||||||||||||||||||||
| 183 | min => 1, | ||||||||||||||||||||||||||||||||||||||||
| 184 | default => $DURATION_5_MINUTES_IN_SECONDS | ||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | _init_profile_properties_details_defaults(); | |||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | ▶ | sub _init_profile_properties_details_defaults { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_profile_properties_details_defaults: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | my $default_file = dist_file( 'Zonemaster-Engine', 'profile.json'); | |||||||||||||||||||||||||||||||||||||||
| 192 | 1 | my $json = read_file( $default_file ); | |||||||||||||||||||||||||||||||||||||||
| 193 | 1 | my $default_values = decode_json( $json ); | |||||||||||||||||||||||||||||||||||||||
| 194 | 1 | foreach my $property_name ( keys %profile_properties_details ) { | |||||||||||||||||||||||||||||||||||||||
| 195 | 24 | ▶ | if ( defined _get_value_from_nested_hash( $default_values, split /[.]/, $property_name ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 196 | 12 | $profile_properties_details{$property_name}{default} = clone _get_value_from_nested_hash( $default_values, split /[.]/, $property_name ); | |||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub _get_profile_paths { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_profile_paths: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my ( $paths_ref, $data, @path ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | foreach my $key (sort keys %$data) { | |||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $path = join '.', @path, $key; | |||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if (ref($data->{$key}) eq 'HASH' and not exists $profile_properties_details{$path} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $data->{$key} eq "HASH" and not exists $profile_properties_details{$path}
MC/DC0%0/2
ref $data->{$key} eq "HASH" and not exists $profile_properties_details{$path}
ref $data->{$key} eq "HASH"
not exists $profile_properties_details{$path}
Truth table0%0/3
A and not(B)
A= ref $data->{$key} eq "HASH"B= not exists $profile_properties_details{$path}
| |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | _get_profile_paths($paths_ref, $data->{$key}, @path, $key); | |||||||||||||||||||||||||||||||||||||||
| 209 | 0 | next; | |||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||
| 211 | else { | ||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $paths_ref->{$path} = 1; | |||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||
| 217 | 66 | ▶ | sub _get_value_from_nested_hash { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_value_from_nested_hash: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||
| 218 | 66 | my ( $hash_ref, @path ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||
| 220 | 66 | my $key = shift @path; | |||||||||||||||||||||||||||||||||||||||
| 221 | 66 | ▶ | if ( exists $hash_ref->{$key} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 222 | 54 | ▶ | if ( @path ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 223 | 30 | my $value_type = reftype($hash_ref->{$key}); | |||||||||||||||||||||||||||||||||||||||
| 224 | 30 | ▶ | if ( $value_type eq q{HASH} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 225 | 30 | return _get_value_from_nested_hash( $hash_ref->{$key}, @path ); | |||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||
| 227 | else { | ||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||
| 231 | else { | ||||||||||||||||||||||||||||||||||||||||
| 232 | 24 | return $hash_ref->{$key}; | |||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||
| 235 | else { | ||||||||||||||||||||||||||||||||||||||||
| 236 | 12 | return undef; | |||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||
| 240 | 56 | ▶ | sub _set_value_to_nested_hash { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_value_to_nested_hash: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||
| 241 | 56 | my ( $hash_ref, $value, @path ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||
| 243 | 56 | my $key = shift @path; | |||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||
| 245 | 56 | ▶ | if ( ! exists $hash_ref->{$key} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 246 | 34 | $hash_ref->{$key} = {}; | |||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||
| 248 | 56 | ▶ | if ( @path ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 249 | 32 | _set_value_to_nested_hash( $hash_ref->{$key}, $value, @path ); | |||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||
| 251 | else { | ||||||||||||||||||||||||||||||||||||||||
| 252 | 24 | $hash_ref->{$key} = clone $value; | |||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | our $effective = Zonemaster::Engine::Profile->default; | |||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 260 | 1 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||
| 261 | 1 | $self->{q{profile}} = {}; | |||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | ▶ | sub default { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 270 | 1 | my $new = $class->new; | |||||||||||||||||||||||||||||||||||||||
| 271 | 1 | foreach my $property_name ( keys %profile_properties_details ) { | |||||||||||||||||||||||||||||||||||||||
| 272 | 24 | ▶ | if ( exists $profile_properties_details{$property_name}{default} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 273 | 24 | $new->set( $property_name, $profile_properties_details{$property_name}{default} ); | |||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | return $new; | |||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub all_properties { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_properties: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return sort keys %profile_properties_details; | |||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my ( $self, $property_name ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | die "Unknown property '$property_name'\n" if not exists $profile_properties_details{$property_name}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ( $profile_properties_details{$property_name}->{type} eq q{ArrayRef} or $profile_properties_details{$property_name}->{type} eq q{HashRef} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$profile_properties_details{$property_name}{"type"} eq "ArrayRef" or $profile_properties_details{$property_name}{"type"} eq "HashRef"
MC/DC0%0/2
$profile_properties_details{$property_name}{"type"} eq "ArrayRef" or $profile_properties_details{$property_name}{"type"} eq "HashRef"
$profile_properties_details{$property_name}{"type"} eq "ArrayRef"
$profile_properties_details{$property_name}{"type"} eq "HashRef"
Truth table0%0/3
A or B
A= $profile_properties_details{$property_name}{"type"} eq "ArrayRef"B= $profile_properties_details{$property_name}{"type"} eq "HashRef"
| |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return clone _get_value_from_nested_hash( $self->{q{profile}}, split /[.]/, $property_name ); | |||||||||||||||||||||||||||||||||||||||
| 292 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | return _get_value_from_nested_hash( $self->{q{profile}}, split /[.]/, $property_name ); | |||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||
| 297 | 24 | ▶ | sub set { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 298 | 24 | my ( $self, $property_name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||
| 300 | 24 | $self->_set( q{DIRECT}, $property_name, $value ); | |||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||
| 303 | 24 | ▶ | sub _set { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set: called CC=34 SCAR=49.3
| |||||||||||||||||||||||||||||||||||||||||
| 304 | 24 | my ( $self, $from, $property_name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 305 | 24 | my $value_type = reftype($value); | |||||||||||||||||||||||||||||||||||||||
| 306 | 24 | my $data_details; | |||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||
| 308 | 24 | ▶ | die "Unknown property '$property_name'\n" if not exists $profile_properties_details{$property_name}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||
| 310 | $data_details = sprintf "[TYPE=%s][FROM=%s][VALUE_TYPE=%s][VALUE=%s]\n%s", | ||||||||||||||||||||||||||||||||||||||||
| 311 | 24 | ▶ | exists $profile_properties_details{$property_name}->{type} ? $profile_properties_details{$property_name}->{type} : q{UNDEF}, | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||
| 312 | defined $from ? $from : q{UNDEF}, | ||||||||||||||||||||||||||||||||||||||||
| 313 | defined $value_type ? $value_type : q{UNDEF}, | ||||||||||||||||||||||||||||||||||||||||
| 314 | defined $value ? $value : q{[UNDEF]}, | ||||||||||||||||||||||||||||||||||||||||
| 315 | Data::Dumper::Dumper($value); | ||||||||||||||||||||||||||||||||||||||||
| 316 | # $value is a Scalar | ||||||||||||||||||||||||||||||||||||||||
| 317 | 24 | ▶ | if ( ! $value_type or $value_type eq q{SCALAR} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $value_type or $value_type eq "SCALAR"
MC/DC100%2/2
not $value_type or $value_type eq "SCALAR"
not $value_type
$value_type eq "SCALAR"
Truth table100%3/3
not(A) or B
A= not $value_typeB= $value_type eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||
| 318 | 19 | ▶ | die "Property $property_name can not be undef\n" if not defined $value; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||
| 320 | # Boolean | ||||||||||||||||||||||||||||||||||||||||
| 321 | 19 | ▶ | if ( $profile_properties_details{$property_name}->{type} eq q{Bool} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 322 | 5 | ▶ | if ( $from eq q{DIRECT} and !$value ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
$from eq "DIRECT" and not $value
MC/DC50%1/2
$from eq "DIRECT" and not $value
$from eq "DIRECT"
not $value
Truth table66%2/3
A and not(B)
A= $from eq "DIRECT"B= not $value
| |||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | $value = JSON::PP::false; | |||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||
| 325 | ▶ | elsif ( $from eq q{DIRECT} and $value ) { | |||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$from eq "DIRECT" and $value
MC/DC0%0/2
$from eq "DIRECT" and $value
$from eq "DIRECT"
$value
Truth table33%1/3
A and B
A= $from eq "DIRECT"B= $value
| |||||||||||||||||||||||||||||||||||||||||
| 326 | 3 | $value = JSON::PP::true; | |||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||
| 328 | ▶ | elsif ( $from eq q{JSON} and $value_type and $value == JSON::PP::false ) { | |||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$from eq "JSON" and $value_type and $value == JSON::PP::false()
$from eq "JSON" and $value_type
MC/DC0%0/3
$from eq "JSON" and $value_type and $value == JSON::PP::false()
$from eq "JSON"
$value_type
$value == JSON::PP::false()
Truth table0%0/4
A and B and C
A= $from eq "JSON"B= $value_typeC= $value == JSON::PP::false()
| |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $value = JSON::PP::false; | |||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||
| 331 | ▶ | elsif ( $from eq q{JSON} and $value_type and $value == JSON::PP::true ) { | |||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$from eq "JSON" and $value_type and $value == JSON::PP::true()
$from eq "JSON" and $value_type
MC/DC0%0/3
$from eq "JSON" and $value_type and $value == JSON::PP::true()
$from eq "JSON"
$value_type
$value == JSON::PP::true()
Truth table0%0/4
A and B and C
A= $from eq "JSON"B= $value_typeC= $value == JSON::PP::true()
| |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $value = JSON::PP::true; | |||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||
| 334 | else { | ||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | die "Property $property_name is of type Boolean $data_details\n"; | |||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||
| 338 | # Number. In our case, only non-negative integers | ||||||||||||||||||||||||||||||||||||||||
| 339 | elsif ( $profile_properties_details{$property_name}->{type} eq q{Num} ) { | ||||||||||||||||||||||||||||||||||||||||
| 340 | 11 | ▶ | if ( $value !~ /^(\d+)$/ ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | die "Property $property_name is of type non-negative integer $data_details\n"; | |||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||
| 343 | 11 | ▶ | if ( exists $profile_properties_details{$property_name}->{min} and $value < $profile_properties_details{$property_name}->{min} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $profile_properties_details{$property_name}{"min"} and $value < $profile_properties_details{$property_name}{"min"}
MC/DC0%0/2
exists $profile_properties_details{$property_name}{"min"} and $value < $profile_properties_details{$property_name}{"min"}
exists $profile_properties_details{$property_name}{"min"}
$value < $profile_properties_details{$property_name}{"min"}
Truth table66%2/3
A and B
A= exists $profile_properties_details{$property_name}{"min"}B= $value < $profile_properties_details{$property_name}{"min"}
| |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | die "Property $property_name value is out of limit (smaller)\n"; | |||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||
| 346 | 11 | ▶ | if ( exists $profile_properties_details{$property_name}->{max} and $value > $profile_properties_details{$property_name}->{max} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $profile_properties_details{$property_name}{"max"} and $value > $profile_properties_details{$property_name}{"max"}
MC/DC0%0/2
exists $profile_properties_details{$property_name}{"max"} and $value > $profile_properties_details{$property_name}{"max"}
exists $profile_properties_details{$property_name}{"max"}
$value > $profile_properties_details{$property_name}{"max"}
Truth table66%2/3
A and B
A= exists $profile_properties_details{$property_name}{"max"}B= $value > $profile_properties_details{$property_name}{"max"}
| |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | die "Property $property_name value is out of limit (bigger)\n"; | |||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||
| 350 | 11 | $value = 0+ $value; # Make sure JSON::PP doesn't serialize it as a JSON string | |||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||
| 353 | else { | ||||||||||||||||||||||||||||||||||||||||
| 354 | # Array | ||||||||||||||||||||||||||||||||||||||||
| 355 | 5 | ▶ | if ( $profile_properties_details{$property_name}->{type} eq q{ArrayRef} and reftype($value) ne q{ARRAY} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$profile_properties_details{$property_name}{"type"} eq "ArrayRef" and builtin::reftype($value) ne "ARRAY"
MC/DC0%0/2
$profile_properties_details{$property_name}{"type"} eq "ArrayRef" and builtin::reftype($value) ne "ARRAY"
$profile_properties_details{$property_name}{"type"} eq "ArrayRef"
builtin::reftype($value) ne "ARRAY"
Truth table66%2/3
A and B
A= $profile_properties_details{$property_name}{"type"} eq "ArrayRef"B= builtin::reftype($value) ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | die "Property $property_name is not a ArrayRef $data_details\n"; | |||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||
| 358 | # Hash | ||||||||||||||||||||||||||||||||||||||||
| 359 | ▶ | elsif ( $profile_properties_details{$property_name}->{type} eq q{HashRef} and reftype($value) ne q{HASH} ) { | |||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$profile_properties_details{$property_name}{"type"} eq "HashRef" and builtin::reftype($value) ne "HASH"
MC/DC0%0/2
$profile_properties_details{$property_name}{"type"} eq "HashRef" and builtin::reftype($value) ne "HASH"
$profile_properties_details{$property_name}{"type"} eq "HashRef"
builtin::reftype($value) ne "HASH"
Truth table66%2/3
A and B
A= $profile_properties_details{$property_name}{"type"} eq "HashRef"B= builtin::reftype($value) ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | die "Property $property_name is not a HashRef $data_details\n"; | |||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||
| 362 | ▶ | elsif ( $profile_properties_details{$property_name}->{type} eq q{Bool} or $profile_properties_details{$property_name}->{type} eq q{Num} or $profile_properties_details{$property_name}->{type} eq q{Str} ) { | |||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$profile_properties_details{$property_name}{"type"} eq "Bool" or $profile_properties_details{$property_name}{"type"} eq "Num" or $profile_properties_details{$property_name}{"type"} eq "Str"
$profile_properties_details{$property_name}{"type"} eq "Bool" or $profile_properties_details{$property_name}{"type"} eq "Num"
MC/DC0%0/3
$profile_properties_details{$property_name}{"type"} eq "Bool" or $profile_properties_details{$property_name}{"type"} eq "Num" or $profile_properties_details{$property_name}{"type"} eq "Str"
$profile_properties_details{$property_name}{"type"} eq "Bool"
$profile_properties_details{$property_name}{"type"} eq "Num"
$profile_properties_details{$property_name}{"type"} eq "Str"
Truth table25%1/4
A or B or C
A= $profile_properties_details{$property_name}{"type"} eq "Bool"B= $profile_properties_details{$property_name}{"type"} eq "Num"C= $profile_properties_details{$property_name}{"type"} eq "Str"
| |||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | die "Property $property_name is a Scalar $data_details\n"; | |||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||
| 367 | 24 | ▶ | if ( $profile_properties_details{$property_name}->{test} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 368 | 5 | $profile_properties_details{$property_name}->{test}->( $value ); | |||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||
| 371 | 24 | return _set_value_to_nested_hash( $self->{q{profile}}, $value, split /[.]/, $property_name ); | |||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | sub merge { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my ( $self, $other_profile ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | die "Merge with ", __PACKAGE__, " only\n" if ref($other_profile) ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | foreach my $property_name ( keys %profile_properties_details ) { | |||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if ( defined _get_value_from_nested_hash( $other_profile->{q{profile}}, split /[.]/, $property_name ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $self->_set( q{JSON}, $property_name, _get_value_from_nested_hash( $other_profile->{q{profile}}, split /[.]/, $property_name ) ); | |||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return $other_profile->{q{profile}}; | |||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub from_json { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_json: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my ( $class, $json ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $new = $class->new; | |||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $internal = decode_json( $json ); | |||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my %paths; | |||||||||||||||||||||||||||||||||||||||
| 393 | 0 | _get_profile_paths(\%paths, $internal); | |||||||||||||||||||||||||||||||||||||||
| 394 | 0 | foreach my $property_name ( keys %paths ) { | |||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ( defined _get_value_from_nested_hash( $internal, split /[.]/, $property_name ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $new->_set( q{JSON}, $property_name, _get_value_from_nested_hash( $internal, split /[.]/, $property_name ) ); | |||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | return $new; | |||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | sub to_json { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_json: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return encode_json( $self->{q{profile}} ); | |||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | sub from_yaml { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_yaml: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my ( $class, $yaml ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $data = YAML::XS::Load( $yaml ); | |||||||||||||||||||||||||||||||||||||||
| 412 | 0 | return $class->from_json( encode_json( $data ) ); | |||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | sub to_yaml { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_yaml: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return YAML::XS::Dump( $self->{q{profile}} ); | |||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | sub effective { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
effective: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | return $effective; | |||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||
| 427 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||
| 429 | Zonemaster::Engine::Profile - A simple system for configuring Zonemaster Engine | ||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||
| 431 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||
| 433 | This module has two parts: | ||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||
| 435 | =over | ||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||
| 437 | =item * a I<profile> representation class | ||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||
| 439 | =item * a global profile object (the I<effective profile>) that configures Zonemaster Engine | ||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||
| 441 | =back | ||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||
| 443 | A I<profile> consists of a collection of named properties. | ||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||
| 445 | The properties determine the configurable behaviors of Zonemaster | ||||||||||||||||||||||||||||||||||||||||
| 446 | Engine with regard to what tests are to be performed, how they are to | ||||||||||||||||||||||||||||||||||||||||
| 447 | be performed, and how the results are to be analyzed. | ||||||||||||||||||||||||||||||||||||||||
| 448 | For details on available properties see the L</PROFILE PROPERTIES> | ||||||||||||||||||||||||||||||||||||||||
| 449 | section. | ||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||
| 451 | Here is an example for updating the effective profile with values from | ||||||||||||||||||||||||||||||||||||||||
| 452 | a given file and setting all properties not mentioned in the file to | ||||||||||||||||||||||||||||||||||||||||
| 453 | default values. | ||||||||||||||||||||||||||||||||||||||||
| 454 | For details on the file format see the L</REPRESENTATIONS> section. | ||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||
| 456 | use Zonemaster::Engine::Profile; | ||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||
| 458 | my $json = read_file( "/path/to/foo.profile" ); | ||||||||||||||||||||||||||||||||||||||||
| 459 | my $foo = Zonemaster::Engine::Profile->from_json( $json ); | ||||||||||||||||||||||||||||||||||||||||
| 460 | my $profile = Zonemaster::Engine::Profile->default; | ||||||||||||||||||||||||||||||||||||||||
| 461 | $profile->merge( $foo ); | ||||||||||||||||||||||||||||||||||||||||
| 462 | Zonemaster::Engine::Profile->effective->merge( $profile ); | ||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||
| 464 | Here is an example for serializing the default profile to JSON. | ||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||
| 466 | my $string = Zonemaster::Engine::Profile->default->to_json; | ||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||
| 468 | For any given profile: | ||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||
| 470 | =over | ||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||
| 472 | =item * At any moment, each property is either set or unset. | ||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||
| 474 | =item * At any moment, every set property has a valid value. | ||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||
| 476 | =item * It is possible to set the value of each unset property. | ||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||
| 478 | =item * It is possible to update the value of each set property. | ||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||
| 480 | =item * It is NOT possible to unset the value of any set property. | ||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||
| 482 | =back | ||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||
| 484 | =head1 CLASS ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||
| 486 | =head2 effective | ||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||
| 488 | A L<Zonemaster::Engine::Profile>. | ||||||||||||||||||||||||||||||||||||||||
| 489 | This is the effective profile. | ||||||||||||||||||||||||||||||||||||||||
| 490 | It serves as the global runtime configuration for Zonemaster Engine. | ||||||||||||||||||||||||||||||||||||||||
| 491 | Update it to change the configuration. | ||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||
| 493 | The effective profile is initialized with the default values declared | ||||||||||||||||||||||||||||||||||||||||
| 494 | in the L</PROFILE PROPERTIES> section. | ||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||
| 496 | All properties in the effective profile are always set (to valid values). | ||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||
| 498 | =head1 CLASS METHODS | ||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||
| 500 | =head2 new | ||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||
| 502 | A constructor that returns a new profile with all properties unset. | ||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||
| 504 | my $profile = Zonemaster::Engine::Profile->new; | ||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||
| 506 | =head2 default | ||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||
| 508 | A constructor that returns a new profile with the default property | ||||||||||||||||||||||||||||||||||||||||
| 509 | values declared in the L</PROFILE PROPERTIES> section. | ||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||
| 511 | my $default = Zonemaster::Engine::Profile->default; | ||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||
| 513 | =head2 from_json | ||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||
| 515 | A constructor that returns a new profile with values parsed from a JSON string. | ||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||
| 517 | my $profile = Zonemaster::Engine::Profile->from_json( '{ "no_network": true }' ); | ||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||
| 519 | The returned profile has set values for all properties specified in the | ||||||||||||||||||||||||||||||||||||||||
| 520 | given string. | ||||||||||||||||||||||||||||||||||||||||
| 521 | The remaining properties are unset. | ||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||
| 523 | Dies if the given string is illegal according to the L</JSON REPRESENTATION> | ||||||||||||||||||||||||||||||||||||||||
| 524 | section or if the property values are illegal according to the L</PROFILE | ||||||||||||||||||||||||||||||||||||||||
| 525 | PROPERTIES> section. | ||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||
| 527 | =head2 from_yaml | ||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||
| 529 | A constructor that returns a new profile with values parsed from a YAML string. | ||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||
| 531 | my $profile = Zonemaster::Engine::Profile->from_yaml( <<EOF | ||||||||||||||||||||||||||||||||||||||||
| 532 | no_network: true | ||||||||||||||||||||||||||||||||||||||||
| 533 | EOF | ||||||||||||||||||||||||||||||||||||||||
| 534 | ); | ||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||
| 536 | The returned profile has set values for all properties specified in the | ||||||||||||||||||||||||||||||||||||||||
| 537 | given string. | ||||||||||||||||||||||||||||||||||||||||
| 538 | The remaining properties are unset. | ||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||
| 540 | Dies if the given string is illegal according to the L</YAML REPRESENTATION> | ||||||||||||||||||||||||||||||||||||||||
| 541 | section or if the property values are illegal according to the L</PROFILE | ||||||||||||||||||||||||||||||||||||||||
| 542 | PROPERTIES> section. | ||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||
| 544 | =head1 INSTANCE METHODS | ||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||
| 546 | =head2 get | ||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||
| 548 | Get the value of a property. | ||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||
| 550 | my $value = $profile1->get( 'net.ipv6' ); | ||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||
| 552 | Returns value of the given property, or C<undef> if the property is unset. | ||||||||||||||||||||||||||||||||||||||||
| 553 | For boolean properties the returned value is either C<1> for true or C<0> for | ||||||||||||||||||||||||||||||||||||||||
| 554 | false. | ||||||||||||||||||||||||||||||||||||||||
| 555 | For properties with complex types, the returned value is a | ||||||||||||||||||||||||||||||||||||||||
| 556 | L<deep copy|https://en.wiktionary.org/wiki/deep_copy#Noun>. | ||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||
| 558 | Dies if the given property name is invalid. | ||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||
| 560 | =head2 set | ||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||
| 562 | Set the value of a property. | ||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||
| 564 | $profile1->set( 'net.ipv6', 0 ); | ||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||
| 566 | Takes a property name and value and updates the property accordingly. | ||||||||||||||||||||||||||||||||||||||||
| 567 | For boolean properties any truthy value is interpreted as true and any falsy | ||||||||||||||||||||||||||||||||||||||||
| 568 | value except C<undef> is interpreted as false. | ||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||
| 570 | Dies if the given property name is invalid. | ||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||
| 572 | Dies if the value is C<undef> or otherwise invalid for the given property. | ||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||
| 574 | =head2 merge | ||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||
| 576 | Merge the profile data of another profile into this one. | ||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||
| 578 | $profile1->merge( $other ); | ||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||
| 580 | Properties from the other profile take precedence when the same property | ||||||||||||||||||||||||||||||||||||||||
| 581 | name exists in both profiles. | ||||||||||||||||||||||||||||||||||||||||
| 582 | The other profile object remains unmodified. | ||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||
| 584 | =head2 to_json | ||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||
| 586 | Serialize the profile to the L</JSON REPRESENTATION> format. | ||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||
| 588 | my $string = $profile->to_json(); | ||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||
| 590 | Returns a string. | ||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||
| 592 | =head2 to_yaml | ||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||
| 594 | Serialize the profile to the L</JSON REPRESENTATION> format. | ||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||
| 596 | my $string = $profile->to_yaml(); | ||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||
| 598 | Returns a string. | ||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||
| 600 | =head2 all_properties | ||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||
| 602 | Get the names of all properties. | ||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||
| 604 | Returns a sorted list of strings. | ||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||
| 606 | =head1 SUBROUTINES | ||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||
| 608 | =head2 _get_profile_paths | ||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||
| 610 | Internal method used to get all the paths of a nested hashes-of-hashes. | ||||||||||||||||||||||||||||||||||||||||
| 611 | It creates a hash where keys are dotted keys of the nested hashes-of-hashes | ||||||||||||||||||||||||||||||||||||||||
| 612 | that exist in %profile_properties_details. | ||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||
| 614 | _get_profile_paths(\%paths, $internal); | ||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||
| 616 | =head2 _get_value_from_nested_hash | ||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||
| 618 | Internal method used to get a value in a nested hashes-of-hashes. | ||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||
| 620 | _get_value_from_nested_hash( $hash_ref, @path ); | ||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||
| 622 | Where $hash_ref is the hash to explore and @path are the labels of the property to get. | ||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||
| 624 | @path = split /\./, q{resolver.defaults.timeout}; | ||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||
| 626 | =head2 _set_value_to_nested_hash | ||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||
| 628 | Internal method used to set a value in a nested hashes-of-hashes. | ||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||
| 630 | _set_value_from_nested_hash( $hash_ref, $value, @path ); | ||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||
| 632 | Where $hash_ref is the hash to explore and @path are the labels of the property to set. | ||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||
| 634 | @path = split /\./, q{resolver.defaults.timeout}; | ||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||
| 636 | =head1 PROFILE PROPERTIES | ||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||
| 638 | Each property has a name and is either set or unset. | ||||||||||||||||||||||||||||||||||||||||
| 639 | If it is set it has a value that is valid for that specific property. | ||||||||||||||||||||||||||||||||||||||||
| 640 | Here is a listing of all the properties and their respective sets of | ||||||||||||||||||||||||||||||||||||||||
| 641 | valid values. | ||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||
| 643 | =head2 resolver.defaults.retrans | ||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||
| 645 | An integer between 1 and 255 inclusive. The number of seconds between retries. | ||||||||||||||||||||||||||||||||||||||||
| 646 | Default 3. | ||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||
| 648 | =head2 resolver.defaults.retry | ||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||
| 650 | An integer between 1 and 255 inclusive. | ||||||||||||||||||||||||||||||||||||||||
| 651 | The number of times a query is sent before we give up. Default 2. | ||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||
| 653 | =head2 resolver.defaults.fallback | ||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||
| 655 | A boolean. If true, UDP queries that get responses with the C<TC> | ||||||||||||||||||||||||||||||||||||||||
| 656 | flag set will be automatically resent over TCP or using EDNS. Default | ||||||||||||||||||||||||||||||||||||||||
| 657 | true. | ||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||
| 659 | In ldns-1.7.0 (NLnet Labs), in case of truncated answer when UDP is used, | ||||||||||||||||||||||||||||||||||||||||
| 660 | the same query is resent with EDNS0 and TCP (if needed). If you | ||||||||||||||||||||||||||||||||||||||||
| 661 | want the original answer (with TC bit set) and avoid this kind of | ||||||||||||||||||||||||||||||||||||||||
| 662 | replay, set this flag to false. | ||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||
| 664 | =head2 resolver.source4 | ||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||
| 666 | A string representation of an IPv4 address or the empty string. | ||||||||||||||||||||||||||||||||||||||||
| 667 | The source address all resolver objects should use when sending queries over IPv4. | ||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||
| 669 | If set to "" (empty string), the OS default IPv4 address is used. | ||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||
| 671 | Default: "" (empty string). | ||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||
| 673 | =head2 resolver.source6 | ||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||
| 675 | A string representation of an IPv6 address or the empty string. | ||||||||||||||||||||||||||||||||||||||||
| 676 | The source address all resolver objects should use when sending queries over IPv6. | ||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||
| 678 | If set to "" (empty string), the OS default IPv6 address is used. | ||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||
| 680 | Default: "" (empty string). | ||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||
| 682 | =head2 net.ipv4 | ||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||
| 684 | A boolean. If true, resolver objects are allowed to send queries over | ||||||||||||||||||||||||||||||||||||||||
| 685 | IPv4. Default true. | ||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||
| 687 | =head2 net.ipv6 | ||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||
| 689 | A boolean. If true, resolver objects are allowed to send queries over | ||||||||||||||||||||||||||||||||||||||||
| 690 | IPv6. Default true. | ||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||
| 692 | =head2 no_network | ||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||
| 694 | A boolean. If true, network traffic is forbidden. Default false. | ||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||
| 696 | Use when you want to be sure that any data is only taken from a preloaded | ||||||||||||||||||||||||||||||||||||||||
| 697 | cache. | ||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||
| 699 | =head2 asn_db.style | ||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||
| 701 | A string that is either C<"Cymru"> or C<"RIPE"> (case-insensitive). | ||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||
| 703 | Defines which service will be used for AS lookup zones. | ||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||
| 705 | Default C<"Cymru">. | ||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||
| 707 | =head2 asn_db.sources | ||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||
| 709 | A hash of arrayrefs of strings. The currently supported keys are C<"Cymru"> or C<"RIPE"> (case-insensitive). | ||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||
| 711 | For C<"Cymru">, the strings are domain names. For C<"RIPE">, they are WHOIS servers. Normally only the first | ||||||||||||||||||||||||||||||||||||||||
| 712 | item in the list will be used, the rest are backups in case the previous ones didn't work. | ||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||
| 714 | Default C<{Cymru: [ "asnlookup.zonemaster.net", "asn.cymru.com" ], RIPE: [ "riswhois.ripe.net" ]}>. | ||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||
| 716 | =head2 cache | ||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||
| 718 | A hash of hashes. The currently supported key is C<"redis">. | ||||||||||||||||||||||||||||||||||||||||
| 719 | Default C<{}>. | ||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||
| 721 | =head3 redis | ||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||
| 723 | A hashref. The currently supported keys are C<"server"> and C<"expire">. | ||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||
| 725 | Specifies the address of the Redis server used to perform global caching | ||||||||||||||||||||||||||||||||||||||||
| 726 | (C<cache.redis.server>) and an optional expire time (C<cache.redis.expire>). | ||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||
| 728 | C<cache.redis.server> must be a string in the form C<host:port>. | ||||||||||||||||||||||||||||||||||||||||
| 729 | C<cache.redis.expire> must be a non-negative integer and defines a time in seconds. | ||||||||||||||||||||||||||||||||||||||||
| 730 | Default is 300 seconds. | ||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||
| 732 | =head2 logfilter | ||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||
| 734 | A complex data structure. Default C<{}>. | ||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||
| 736 | Specifies the severity level of each tag emitted by a specific module. | ||||||||||||||||||||||||||||||||||||||||
| 737 | The intended use is to remove known erroneous results. | ||||||||||||||||||||||||||||||||||||||||
| 738 | E.g. if you know that a certain name server is recursive and for some | ||||||||||||||||||||||||||||||||||||||||
| 739 | reason should be, you can use this functionality to lower the severity | ||||||||||||||||||||||||||||||||||||||||
| 740 | of the complaint about it to a lower level than normal. | ||||||||||||||||||||||||||||||||||||||||
| 741 | The C<test_levels> item also specifies tag severity level, but with | ||||||||||||||||||||||||||||||||||||||||
| 742 | coarser granularity and lower precedence. | ||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||
| 744 | The data under the C<logfilter> key should be structured like this: | ||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||
| 746 | Module | ||||||||||||||||||||||||||||||||||||||||
| 747 | Tag | ||||||||||||||||||||||||||||||||||||||||
| 748 | Array of exceptions | ||||||||||||||||||||||||||||||||||||||||
| 749 | "when" | ||||||||||||||||||||||||||||||||||||||||
| 750 | Hash with conditions | ||||||||||||||||||||||||||||||||||||||||
| 751 | "set" | ||||||||||||||||||||||||||||||||||||||||
| 752 | Severity level to set if all conditions match | ||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||
| 754 | The hash with conditions should have keys matching the attributes of | ||||||||||||||||||||||||||||||||||||||||
| 755 | the log entry that's being filtered (check the translation files to see | ||||||||||||||||||||||||||||||||||||||||
| 756 | what they are). The values for the keys should be either a single value | ||||||||||||||||||||||||||||||||||||||||
| 757 | that the attribute should be, or an array of values any one of which the | ||||||||||||||||||||||||||||||||||||||||
| 758 | attribute should be. | ||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||
| 760 | A complete logfilter structure might look like this: | ||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||
| 762 | { | ||||||||||||||||||||||||||||||||||||||||
| 763 | "A_MODULE": { | ||||||||||||||||||||||||||||||||||||||||
| 764 | "SOME_TAG": [ | ||||||||||||||||||||||||||||||||||||||||
| 765 | { | ||||||||||||||||||||||||||||||||||||||||
| 766 | "when": { | ||||||||||||||||||||||||||||||||||||||||
| 767 | "count": 1, | ||||||||||||||||||||||||||||||||||||||||
| 768 | "type": [ | ||||||||||||||||||||||||||||||||||||||||
| 769 | "this", | ||||||||||||||||||||||||||||||||||||||||
| 770 | "or" | ||||||||||||||||||||||||||||||||||||||||
| 771 | ] | ||||||||||||||||||||||||||||||||||||||||
| 772 | }, | ||||||||||||||||||||||||||||||||||||||||
| 773 | "set": "INFO" | ||||||||||||||||||||||||||||||||||||||||
| 774 | }, | ||||||||||||||||||||||||||||||||||||||||
| 775 | { | ||||||||||||||||||||||||||||||||||||||||
| 776 | "when": { | ||||||||||||||||||||||||||||||||||||||||
| 777 | "count": 128, | ||||||||||||||||||||||||||||||||||||||||
| 778 | "type": [ | ||||||||||||||||||||||||||||||||||||||||
| 779 | "that" | ||||||||||||||||||||||||||||||||||||||||
| 780 | ] | ||||||||||||||||||||||||||||||||||||||||
| 781 | }, | ||||||||||||||||||||||||||||||||||||||||
| 782 | "set": "INFO" | ||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||
| 784 | ] | ||||||||||||||||||||||||||||||||||||||||
| 785 | }, | ||||||||||||||||||||||||||||||||||||||||
| 786 | "ANOTHER_MODULE": { | ||||||||||||||||||||||||||||||||||||||||
| 787 | "OTHER_TAG": [ | ||||||||||||||||||||||||||||||||||||||||
| 788 | { | ||||||||||||||||||||||||||||||||||||||||
| 789 | "when": { | ||||||||||||||||||||||||||||||||||||||||
| 790 | "bananas": 0 | ||||||||||||||||||||||||||||||||||||||||
| 791 | }, | ||||||||||||||||||||||||||||||||||||||||
| 792 | "set": "WARNING" | ||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||
| 794 | ] | ||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||
| 798 | This would set the severity level to C<INFO> for any C<A_MODULE:SOME_TAG> | ||||||||||||||||||||||||||||||||||||||||
| 799 | messages that had a C<count> attribute set to 1 and a C<type> attribute | ||||||||||||||||||||||||||||||||||||||||
| 800 | set to either C<this> or C<or>. | ||||||||||||||||||||||||||||||||||||||||
| 801 | This also would set the level to C<INFO> for any C<A_MODULE:SOME_TAG> | ||||||||||||||||||||||||||||||||||||||||
| 802 | messages that had a C<count> attribute set to 128 and a C<type> attribute | ||||||||||||||||||||||||||||||||||||||||
| 803 | set to C<that>. | ||||||||||||||||||||||||||||||||||||||||
| 804 | And this would set the level to C<WARNING> for any C<ANOTHER_MODULE:OTHER_TAG> | ||||||||||||||||||||||||||||||||||||||||
| 805 | messages that had a C<bananas> attribute set to 0. | ||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||
| 807 | =head2 test_levels | ||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||
| 809 | A complex data structure. | ||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||
| 811 | Specifies the severity level of each tag emitted by a specific module. | ||||||||||||||||||||||||||||||||||||||||
| 812 | The C<logfilter> item also specifies tag severity level, but with finer | ||||||||||||||||||||||||||||||||||||||||
| 813 | granularity and higher precedence. | ||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||
| 815 | At the top level of this data structure are two levels of nested hashrefs. | ||||||||||||||||||||||||||||||||||||||||
| 816 | The keys of the top level hash are names of test implementation modules | ||||||||||||||||||||||||||||||||||||||||
| 817 | (without the C<Zonemaster::Engine::Test::> prefix). | ||||||||||||||||||||||||||||||||||||||||
| 818 | The keys of the second level hashes are tags that the respective | ||||||||||||||||||||||||||||||||||||||||
| 819 | modules emit. | ||||||||||||||||||||||||||||||||||||||||
| 820 | The values of the second level hashes are mapped to severity levels. | ||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||
| 822 | The various L<test case specifications| | ||||||||||||||||||||||||||||||||||||||||
| 823 | https://github.com/zonemaster/zonemaster/tree/master/docs/specifications/tests/README.md> | ||||||||||||||||||||||||||||||||||||||||
| 824 | define the default severity level for some of the messages. | ||||||||||||||||||||||||||||||||||||||||
| 825 | These specifications are the only authoritative documents on the default | ||||||||||||||||||||||||||||||||||||||||
| 826 | severity level for the various messages. | ||||||||||||||||||||||||||||||||||||||||
| 827 | For messages not defined in any of these specifications you can use the | ||||||||||||||||||||||||||||||||||||||||
| 828 | following command to query the default severity level directly from the actual | ||||||||||||||||||||||||||||||||||||||||
| 829 | default profile. | ||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||
| 831 | ```sh | ||||||||||||||||||||||||||||||||||||||||
| 832 | perl -MZonemaster::Engine::Test -E 'say Zonemaster::Engine::Profile->default->to_json' | jq -S .test_levels | ||||||||||||||||||||||||||||||||||||||||
| 833 | ``` | ||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||
| 835 | For messages neither defined in test specifications, nor listed in the default | ||||||||||||||||||||||||||||||||||||||||
| 836 | profile, the default severity level is C<DEBUG>. | ||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||
| 838 | I<Note:> Sometimes multiple test cases within the same test module define | ||||||||||||||||||||||||||||||||||||||||
| 839 | messages for the same tag. | ||||||||||||||||||||||||||||||||||||||||
| 840 | When they do, it is imperative that all test cases define the same severity | ||||||||||||||||||||||||||||||||||||||||
| 841 | level for the tag. | ||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||
| 843 | =head2 test_cases | ||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||
| 845 | An arrayref of names of implemented test cases (in all lower-case) as listed in the | ||||||||||||||||||||||||||||||||||||||||
| 846 | L<test case specifications|https://github.com/zonemaster/zonemaster/tree/master/docs/specifications/tests/ImplementedTestCases.md>. | ||||||||||||||||||||||||||||||||||||||||
| 847 | Default is an arrayref listing all the test cases. | ||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||
| 849 | Specifies which test cases can be run by the testing suite. | ||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||
| 851 | =head2 test_cases_vars.dnssec04.REMAINING_SHORT | ||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||
| 853 | A positive integer value. | ||||||||||||||||||||||||||||||||||||||||
| 854 | Recommended lower bound for signatures' remaining validity time (in seconds) in | ||||||||||||||||||||||||||||||||||||||||
| 855 | test case L<DNSSEC04| | ||||||||||||||||||||||||||||||||||||||||
| 856 | https://github.com/zonemaster/zonemaster/blob/master/docs/specifications/tests/DNSSEC-TP/dnssec04.md>. | ||||||||||||||||||||||||||||||||||||||||
| 857 | Related to the REMAINING_SHORT message tag from this test case. | ||||||||||||||||||||||||||||||||||||||||
| 858 | Default C<43200> (12 hours in seconds). | ||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||
| 860 | =head2 test_cases_vars.dnssec04.REMAINING_LONG | ||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||
| 862 | A positive integer value. | ||||||||||||||||||||||||||||||||||||||||
| 863 | Recommended upper bound for signatures' remaining validity time (in seconds) in | ||||||||||||||||||||||||||||||||||||||||
| 864 | test case L<DNSSEC04| | ||||||||||||||||||||||||||||||||||||||||
| 865 | https://github.com/zonemaster/zonemaster/blob/master/docs/specifications/tests/DNSSEC-TP/dnssec04.md>. | ||||||||||||||||||||||||||||||||||||||||
| 866 | Related to the REMAINING_LONG message tag from this test case. | ||||||||||||||||||||||||||||||||||||||||
| 867 | Default C<15552000> (180 days in seconds). | ||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||
| 869 | =head2 test_cases_vars.dnssec04.DURATION_LONG | ||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||
| 871 | A positive integer value. | ||||||||||||||||||||||||||||||||||||||||
| 872 | Recommended upper bound for signatures' lifetime (in seconds) in the test case | ||||||||||||||||||||||||||||||||||||||||
| 873 | L<DNSSEC04| | ||||||||||||||||||||||||||||||||||||||||
| 874 | https://github.com/zonemaster/zonemaster/blob/master/docs/specifications/tests/DNSSEC-TP/dnssec04.md>. | ||||||||||||||||||||||||||||||||||||||||
| 875 | Related to the DURATION_LONG message tag from this test case. | ||||||||||||||||||||||||||||||||||||||||
| 876 | Default C<15552000> (180 days in seconds). | ||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||
| 878 | =head2 test_cases_vars.zone02.SOA_REFRESH_MINIMUM_VALUE | ||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||
| 880 | A positive integer value. | ||||||||||||||||||||||||||||||||||||||||
| 881 | Recommended lower bound for SOA refresh values (in seconds) in test case | ||||||||||||||||||||||||||||||||||||||||
| 882 | L<ZONE02| | ||||||||||||||||||||||||||||||||||||||||
| 883 | https://github.com/zonemaster/zonemaster/blob/master/docs/specifications/tests/Zone-TP/zone02.md>. | ||||||||||||||||||||||||||||||||||||||||
| 884 | Related to the REFRESH_MINIMUM_VALUE_LOWER message tag from this test case. | ||||||||||||||||||||||||||||||||||||||||
| 885 | Default C<14400> (4 hours in seconds). | ||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||
| 887 | =head2 test_cases_vars.zone04.SOA_RETRY_MINIMUM_VALUE | ||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||
| 889 | A positive integer value. | ||||||||||||||||||||||||||||||||||||||||
| 890 | Recommended lower bound for SOA retry values (in seconds) in test case | ||||||||||||||||||||||||||||||||||||||||
| 891 | L<ZONE04| | ||||||||||||||||||||||||||||||||||||||||
| 892 | https://github.com/zonemaster/zonemaster/blob/master/docs/specifications/tests/Zone-TP/zone04.md>. | ||||||||||||||||||||||||||||||||||||||||
| 893 | Related to the RETRY_MINIMUM_VALUE_LOWER message tag from this test case. | ||||||||||||||||||||||||||||||||||||||||
| 894 | Default C<3600> (1 hour in seconds). | ||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||
| 896 | =head2 test_cases_vars.zone05.SOA_EXPIRE_MINIMUM_VALUE | ||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||
| 898 | A positive integer value. | ||||||||||||||||||||||||||||||||||||||||
| 899 | Recommended lower bound for SOA expire values (in seconds) in test case | ||||||||||||||||||||||||||||||||||||||||
| 900 | L<ZONE05| | ||||||||||||||||||||||||||||||||||||||||
| 901 | https://github.com/zonemaster/zonemaster/blob/master/docs/specifications/tests/Zone-TP/zone05.md>. | ||||||||||||||||||||||||||||||||||||||||
| 902 | Related to the EXPIRE_MINIMUM_VALUE_LOWER message tag from this test case. | ||||||||||||||||||||||||||||||||||||||||
| 903 | Default C<604800> (1 week in seconds). | ||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||
| 905 | =head2 test_cases_vars.zone06.SOA_DEFAULT_TTL_MINIMUM_VALUE | ||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||
| 907 | A positive integer value. | ||||||||||||||||||||||||||||||||||||||||
| 908 | Recommended lower bound for SOA minimum values (in seconds) in test case | ||||||||||||||||||||||||||||||||||||||||
| 909 | L<ZONE06| | ||||||||||||||||||||||||||||||||||||||||
| 910 | https://github.com/zonemaster/zonemaster/blob/master/docs/specifications/tests/Zone-TP/zone06.md>. | ||||||||||||||||||||||||||||||||||||||||
| 911 | Related to the SOA_DEFAULT_TTL_MAXIMUM_VALUE_LOWER message tag from this test case. | ||||||||||||||||||||||||||||||||||||||||
| 912 | Default C<300> (5 minutes in seconds). | ||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||
| 914 | =head2 test_cases_vars.zone06.SOA_DEFAULT_TTL_MAXIMUM_VALUE | ||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||
| 916 | A positive integer value. | ||||||||||||||||||||||||||||||||||||||||
| 917 | Recommended upper bound for SOA minimum values (in seconds) in test case | ||||||||||||||||||||||||||||||||||||||||
| 918 | L<ZONE06| | ||||||||||||||||||||||||||||||||||||||||
| 919 | https://github.com/zonemaster/zonemaster/blob/master/docs/specifications/tests/Zone-TP/zone06.md>. | ||||||||||||||||||||||||||||||||||||||||
| 920 | Related to the SOA_DEFAULT_TTL_MAXIMUM_VALUE_HIGHER message tag from this test case. | ||||||||||||||||||||||||||||||||||||||||
| 921 | Default C<86400> (1 day in seconds). | ||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||
| 923 | =head1 REPRESENTATIONS | ||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||
| 925 | =head2 JSON REPRESENTATION | ||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||
| 927 | Property names in L</PROFILE PROPERTIES> section correspond to paths in | ||||||||||||||||||||||||||||||||||||||||
| 928 | a datastructure of nested JSON objects. | ||||||||||||||||||||||||||||||||||||||||
| 929 | Property values are stored at their respective paths. | ||||||||||||||||||||||||||||||||||||||||
| 930 | Paths are formed from property names by splitting them at dot characters | ||||||||||||||||||||||||||||||||||||||||
| 931 | (U+002E). | ||||||||||||||||||||||||||||||||||||||||
| 932 | The left-most path component corresponds to a key in the top-most | ||||||||||||||||||||||||||||||||||||||||
| 933 | JSON object. | ||||||||||||||||||||||||||||||||||||||||
| 934 | Properties with unset values are omitted in the JSON representation. | ||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||
| 936 | For a complete example, refer to the file located by L<dist_file( | ||||||||||||||||||||||||||||||||||||||||
| 937 | "Zonemaster-Engine", "default.profile" )|File::ShareDir/dist_file>. | ||||||||||||||||||||||||||||||||||||||||
| 938 | A profile with the only two properties set, C<net.ipv4> = true and | ||||||||||||||||||||||||||||||||||||||||
| 939 | C<net.ipv6> = true has this JSON representation: | ||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||
| 941 | { | ||||||||||||||||||||||||||||||||||||||||
| 942 | "net": { | ||||||||||||||||||||||||||||||||||||||||
| 943 | "ipv4": true, | ||||||||||||||||||||||||||||||||||||||||
| 944 | "ipv6": true | ||||||||||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||
| 948 | =head2 YAML REPRESENTATION | ||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||
| 950 | Similar to the L</JSON REPRESENTATION> but uses a YAML format. | ||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||
| 952 | =cut | ||||||||||||||||||||||||||||||||||||||||