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