| 1 | package Zonemaster::Engine::Test::DNSSEC; | ||
| 2 | |||
| 3 | use v5.16.0; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use version; our $VERSION = version->declare( "v1.1.58" ); | ||
| 7 | |||
| 8 | use Carp; | ||
| 9 | use List::Compare; | ||
| 10 | use List::MoreUtils qw[any uniq]; | ||
| 11 | use List::Util qw[min]; | ||
| 12 | use Locale::TextDomain qw[Zonemaster-Engine]; | ||
| 13 | use Readonly; | ||
| 14 | |||
| 15 | use Zonemaster::LDNS::RR; | ||
| 16 | use Zonemaster::Engine::Profile; | ||
| 17 | use Zonemaster::Engine::Constants qw[:algo :soa :ip]; | ||
| 18 | use Zonemaster::Engine::Util qw[name should_run_test]; | ||
| 19 | use Zonemaster::Engine::TestMethods; | ||
| 20 | use Zonemaster::Engine::TestMethodsV2; | ||
| 21 | |||
| 22 | =head1 NAME | ||
| 23 | |||
| 24 | Zonemaster::Engine::Test::DNSSEC - Module implementing tests focused on DNSSEC | ||
| 25 | |||
| 26 | =head1 SYNOPSIS | ||
| 27 | |||
| 28 | my @results = Zonemaster::Engine::Test::DNSSEC->all( $zone ); | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | ### Table fetched from IANA on 2025-07-15 | ||
| 33 | Readonly::Hash our %algo_properties => ( | ||
| 34 | 0 => { | ||
| 35 | status => $ALGO_STATUS_NOT_ZONE_SIGN, | ||
| 36 | description => q{Delete DS}, | ||
| 37 | mnemonic => q{DELETE}, | ||
| 38 | sig => 0, | ||
| 39 | }, | ||
| 40 | 1 => { | ||
| 41 | status => $ALGO_STATUS_DEPRECATED, | ||
| 42 | description => q{RSA/MD5}, | ||
| 43 | mnemonic => q{RSAMD5}, | ||
| 44 | sig => 0, | ||
| 45 | }, | ||
| 46 | 2 => { | ||
| 47 | status => $ALGO_STATUS_NOT_ZONE_SIGN, | ||
| 48 | description => q{Diffie-Hellman}, | ||
| 49 | mnemonic => q{DH}, | ||
| 50 | sig => 0, | ||
| 51 | }, | ||
| 52 | 3 => { | ||
| 53 | status => $ALGO_STATUS_DEPRECATED, | ||
| 54 | description => q{DSA/SHA1}, | ||
| 55 | mnemonic => q{DSA}, | ||
| 56 | sig => 1, | ||
| 57 | }, | ||
| 58 | 4 => { | ||
| 59 | status => $ALGO_STATUS_RESERVED, | ||
| 60 | description => q{Reserved}, | ||
| 61 | mnemonic => q{RESERVED}, | ||
| 62 | }, | ||
| 63 | 5 => { | ||
| 64 | status => $ALGO_STATUS_DEPRECATED, | ||
| 65 | description => q{RSA/SHA1}, | ||
| 66 | mnemonic => q{RSASHA1}, | ||
| 67 | sig => 1, | ||
| 68 | }, | ||
| 69 | 6 => { | ||
| 70 | status => $ALGO_STATUS_DEPRECATED, | ||
| 71 | description => q{DSA-NSEC3-SHA1}, | ||
| 72 | mnemonic => q{DSA-NSEC3-SHA1}, | ||
| 73 | sig => 1, | ||
| 74 | }, | ||
| 75 | 7 => { | ||
| 76 | status => $ALGO_STATUS_DEPRECATED, | ||
| 77 | description => q{RSASHA1-NSEC3-SHA1}, | ||
| 78 | mnemonic => q{RSASHA1-NSEC3-SHA1}, | ||
| 79 | sig => 1, | ||
| 80 | }, | ||
| 81 | 8 => { | ||
| 82 | status => $ALGO_STATUS_OTHER, | ||
| 83 | description => q{RSA/SHA-256}, | ||
| 84 | mnemonic => q{RSASHA256}, | ||
| 85 | sig => 1, | ||
| 86 | }, | ||
| 87 | 9 => { | ||
| 88 | status => $ALGO_STATUS_RESERVED, | ||
| 89 | description => q{Reserved}, | ||
| 90 | mnemonic => q{RESERVED}, | ||
| 91 | }, | ||
| 92 | 10 => { | ||
| 93 | status => $ALGO_STATUS_NOT_RECOMMENDED, | ||
| 94 | description => q{RSA/SHA-512}, | ||
| 95 | mnemonic => q{RSASHA512}, | ||
| 96 | sig => 1, | ||
| 97 | }, | ||
| 98 | 11 => { | ||
| 99 | status => $ALGO_STATUS_RESERVED, | ||
| 100 | description => q{Reserved}, | ||
| 101 | mnemonic => q{RESERVED}, | ||
| 102 | }, | ||
| 103 | 12 => { | ||
| 104 | status => $ALGO_STATUS_DEPRECATED, | ||
| 105 | description => q{GOST R 34.10-2001}, | ||
| 106 | mnemonic => q{ECC-GOST}, | ||
| 107 | sig => 1, | ||
| 108 | }, | ||
| 109 | 13 => { | ||
| 110 | status => $ALGO_STATUS_OTHER, | ||
| 111 | description => q{ECDSA Curve P-256 with SHA-256}, | ||
| 112 | mnemonic => q{ECDSAP256SHA256}, | ||
| 113 | sig => 1, | ||
| 114 | }, | ||
| 115 | 14 => { | ||
| 116 | status => $ALGO_STATUS_OTHER, | ||
| 117 | description => q{ECDSA Curve P-384 with SHA-384}, | ||
| 118 | mnemonic => q{ECDSAP384SHA384}, | ||
| 119 | sig => 1, | ||
| 120 | }, | ||
| 121 | 15 => { | ||
| 122 | status => $ALGO_STATUS_OTHER, | ||
| 123 | description => q{Ed25519}, | ||
| 124 | mnemonic => q{ED25519}, | ||
| 125 | sig => 1, | ||
| 126 | }, | ||
| 127 | 16 => { | ||
| 128 | status => $ALGO_STATUS_OTHER, | ||
| 129 | description => q{Ed448}, | ||
| 130 | mnemonic => q{ED448}, | ||
| 131 | sig => 1, | ||
| 132 | }, | ||
| 133 | 17 => { | ||
| 134 | status => $ALGO_STATUS_OTHER, | ||
| 135 | description => q{SM2 signing algo w SM3 hash algo}, | ||
| 136 | mnemonic => q{SM2SM3}, | ||
| 137 | sig => 1, | ||
| 138 | }, | ||
| 139 | ( | ||
| 140 | map { $_ => { status => $ALGO_STATUS_UNASSIGNED, description => q{Unassigned}, mnemonic => q{UNASSIGNED} } } ( 18 .. 22 ) | ||
| 141 | ), | ||
| 142 | 23 => { | ||
| 143 | status => $ALGO_STATUS_OTHER, | ||
| 144 | description => q{GOST R 34.10-2012}, | ||
| 145 | mnemonic => q{ECC-GOST12}, | ||
| 146 | sig => 1, | ||
| 147 | }, | ||
| 148 | ( | ||
| 149 | map { $_ => { status => $ALGO_STATUS_UNASSIGNED, description => q{Unassigned}, mnemonic => q{UNASSIGNED} } } ( 24 .. 122 ) | ||
| 150 | ), | ||
| 151 | ( | ||
| 152 | map { $_ => { status => $ALGO_STATUS_RESERVED, description => q{Reserved}, mnemonic => q{RESERVED} } } ( 123 .. 251 ) | ||
| 153 | ), | ||
| 154 | 252 => { | ||
| 155 | status => $ALGO_STATUS_NOT_ZONE_SIGN, | ||
| 156 | description => q{Reserved for Indirect Keys}, | ||
| 157 | mnemonic => q{INDIRECT}, | ||
| 158 | sig => 0, | ||
| 159 | }, | ||
| 160 | 253 => { | ||
| 161 | status => $ALGO_STATUS_PRIVATE, | ||
| 162 | description => q{private algorithm}, | ||
| 163 | mnemonic => q{PRIVATEDNS}, | ||
| 164 | sig => 1, | ||
| 165 | }, | ||
| 166 | 254 => { | ||
| 167 | status => $ALGO_STATUS_PRIVATE, | ||
| 168 | description => q{private algorithm OID}, | ||
| 169 | mnemonic => q{PRIVATEOID}, | ||
| 170 | sig => 1, | ||
| 171 | }, | ||
| 172 | 255 => { | ||
| 173 | status => $ALGO_STATUS_RESERVED, | ||
| 174 | description => q{Reserved}, | ||
| 175 | mnemonic => q{RESERVED}, | ||
| 176 | }, | ||
| 177 | ); | ||
| 178 | |||
| 179 | Readonly::Hash our %rsa_key_size_details => ( | ||
| 180 | 5 => { | ||
| 181 | min_size => 512, | ||
| 182 | max_size => 4096, | ||
| 183 | rec_size => 2048, | ||
| 184 | reference => q{RFC 3110}, | ||
| 185 | }, | ||
| 186 | 7 => { | ||
| 187 | min_size => 512, | ||
| 188 | max_size => 4096, | ||
| 189 | rec_size => 2048, | ||
| 190 | reference => q{RFC 5155}, | ||
| 191 | }, | ||
| 192 | 8 => { | ||
| 193 | min_size => 512, | ||
| 194 | max_size => 4096, | ||
| 195 | rec_size => 2048, | ||
| 196 | reference => q{RFC 5702}, | ||
| 197 | }, | ||
| 198 | 10 => { | ||
| 199 | min_size => 1024, | ||
| 200 | max_size => 4096, | ||
| 201 | rec_size => 2048, | ||
| 202 | reference => q{RFC 5702}, | ||
| 203 | }, | ||
| 204 | ); | ||
| 205 | |||
| 206 | Readonly::Hash our %digest_algorithms => ( | ||
| 207 | 0 => q{Reserved}, | ||
| 208 | 1 => q{SHA-1}, | ||
| 209 | 2 => q{SHA-256}, | ||
| 210 | 3 => q{GOST R 34.11-94}, | ||
| 211 | 4 => q{SHA-384}, | ||
| 212 | 5 => q{GOST R 34.11-2012}, | ||
| 213 | 6 => q{SM3}, | ||
| 214 | ( | ||
| 215 | map { $_ => q{Unassigned} } ( 7 .. 127 ) | ||
| 216 | ), | ||
| 217 | ( | ||
| 218 | map { $_ => q{Reserved} } ( 128 .. 252 ) | ||
| 219 | ), | ||
| 220 | ( | ||
| 221 | map { $_ => q{Reserved for Private Use} } ( 253 .. 254 ) | ||
| 222 | ), | ||
| 223 | 255 => q{Unassigned}, | ||
| 224 | ); | ||
| 225 | |||
| 226 | Readonly::Hash our %LDNS_digest_algorithms_supported => ( | ||
| 227 | 1 => q{sha1}, | ||
| 228 | 2 => q{sha256}, | ||
| 229 | 3 => q{gost}, | ||
| 230 | 4 => q{sha384}, | ||
| 231 | ); | ||
| 232 | |||
| 233 | Readonly::Hash our %dnssec01_tags_mapping => ( | ||
| 234 | 0 => q{DS01_DS_ALGO_NOT_DS}, | ||
| 235 | 1 => q{DS01_DS_ALGO_DEPRECATED}, | ||
| 236 | 2 => q{DS01_DS_ALGO_OK}, | ||
| 237 | 3 => q{DS01_DS_ALGO_DEPRECATED}, | ||
| 238 | 4 => q{DS01_DS_ALGO_OK}, | ||
| 239 | 5 => q{DS01_DS_ALGO_OK}, | ||
| 240 | 6 => q{DS01_DS_ALGO_OK}, | ||
| 241 | ( | ||
| 242 | map { $_ => q{DS01_DS_ALGO_UNASSIGNED} } ( 7 .. 127 ) | ||
| 243 | ), | ||
| 244 | ( | ||
| 245 | map { $_ => q{DS01_DS_ALGO_RESERVED} } ( 128 .. 252 ) | ||
| 246 | ), | ||
| 247 | ( | ||
| 248 | map { $_ => q{DS01_DS_ALGO_PRIVATE} } ( 253 .. 254 ) | ||
| 249 | ), | ||
| 250 | 255 => q{DS01_DS_ALGO_UNASSIGNED}, | ||
| 251 | ); | ||
| 252 | |||
| 253 | Readonly::Hash our %dnssec05_tags_mapping => ( | ||
| 254 | 0 => q{DS05_ALGO_NOT_ZONE_SIGN}, | ||
| 255 | 1 => q{DS05_ALGO_DEPRECATED}, | ||
| 256 | 2 => q{DS05_ALGO_NOT_ZONE_SIGN}, | ||
| 257 | 3 => q{DS05_ALGO_DEPRECATED}, | ||
| 258 | 4 => q{DS05_ALGO_RESERVED}, | ||
| 259 | 5 => q{DS05_ALGO_DEPRECATED}, | ||
| 260 | 6 => q{DS05_ALGO_DEPRECATED}, | ||
| 261 | 7 => q{DS05_ALGO_DEPRECATED}, | ||
| 262 | 8 => q{DS05_ALGO_OK}, | ||
| 263 | 9 => q{DS05_ALGO_RESERVED}, | ||
| 264 | 10 => q{DS05_ALGO_NOT_RECOMMENDED}, | ||
| 265 | 11 => q{DS05_ALGO_RESERVED}, | ||
| 266 | 12 => q{DS05_ALGO_DEPRECATED}, | ||
| 267 | 13 => q{DS05_ALGO_OK}, | ||
| 268 | 14 => q{DS05_ALGO_OK}, | ||
| 269 | 15 => q{DS05_ALGO_OK}, | ||
| 270 | 16 => q{DS05_ALGO_OK}, | ||
| 271 | 17 => q{DS05_ALGO_OK}, | ||
| 272 | ( | ||
| 273 | map { $_ => q{DS05_ALGO_UNASSIGNED} } ( 18 .. 22 ) | ||
| 274 | ), | ||
| 275 | 23 => q{DS05_ALGO_OK}, | ||
| 276 | ( | ||
| 277 | map { $_ => q{DS05_ALGO_UNASSIGNED} } ( 24 .. 122 ) | ||
| 278 | ), | ||
| 279 | ( | ||
| 280 | map { $_ => q{DS05_ALGO_RESERVED} } ( 123 .. 251 ) | ||
| 281 | ), | ||
| 282 | 252 => q{DS05_ALGO_NOT_ZONE_SIGN}, | ||
| 283 | 253 => q{DS05_ALGO_PRIVATE}, | ||
| 284 | 254 => q{DS05_ALGO_PRIVATE}, | ||
| 285 | 255 => q{DS05_ALGO_RESERVED}, | ||
| 286 | ); | ||
| 287 | |||
| 288 | =head1 METHODS | ||
| 289 | |||
| 290 | =over | ||
| 291 | |||
| 292 | =item all() | ||
| 293 | |||
| 294 | my @logentry_array = all( $zone ); | ||
| 295 | |||
| 296 | Runs the default set of tests for that module, i.e. between L<one and seventeen tests|/TESTS> depending on the tested zone. | ||
| 297 | If L<DNSSEC07|/dnssec07()> finds no DNSKEY nor DS RRs, no other test is run. If L<DNSSEC07|/dnssec07()> finds a DNSKEY RR, L<DNSSEC06|/dnssec06()> is run. | ||
| 298 | |||
| 299 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 300 | |||
| 301 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 302 | |||
| 303 | =back | ||
| 304 | |||
| 305 | =cut | ||
| 306 | |||
| 307 | sub all { | ||
| 308 | my ( $class, $zone ) = @_; | ||
| 309 | my @results; | ||
| 310 | |||
| 311 | if ( should_run_test( q{dnssec07} ) ) { | ||
| 312 | push @results, $class->dnssec07( $zone ); | ||
| 313 | } | ||
| 314 | |||
| 315 | if ( should_run_test( q{dnssec11} ) ) { | ||
| 316 | push @results, $class->dnssec11( $zone ); | ||
| 317 | } | ||
| 318 | |||
| 319 | if ( any { $_->tag eq 'DS07_NOT_SIGNED' } @results ) { | ||
| 320 | return @results; | ||
| 321 | } | ||
| 322 | |||
| 323 | if ( should_run_test( q{dnssec01} ) ) { | ||
| 324 | push @results, $class->dnssec01( $zone ); | ||
| 325 | } | ||
| 326 | |||
| 327 | if ( should_run_test( q{dnssec02} ) ) { | ||
| 328 | push @results, $class->dnssec02( $zone ); | ||
| 329 | } | ||
| 330 | |||
| 331 | if ( should_run_test( q{dnssec03} ) ) { | ||
| 332 | push @results, $class->dnssec03( $zone ); | ||
| 333 | } | ||
| 334 | |||
| 335 | if ( should_run_test( q{dnssec04} ) ) { | ||
| 336 | push @results, $class->dnssec04( $zone ); | ||
| 337 | } | ||
| 338 | |||
| 339 | if ( should_run_test( q{dnssec05} ) ) { | ||
| 340 | push @results, $class->dnssec05( $zone ); | ||
| 341 | } | ||
| 342 | |||
| 343 | if ( should_run_test( q{dnssec06} ) ) { | ||
| 344 | push @results, $class->dnssec06( $zone ); | ||
| 345 | } | ||
| 346 | |||
| 347 | if ( should_run_test( q{dnssec08} ) ) { | ||
| 348 | push @results, $class->dnssec08( $zone ); | ||
| 349 | } | ||
| 350 | |||
| 351 | if ( should_run_test( q{dnssec09} ) ) { | ||
| 352 | push @results, $class->dnssec09( $zone ); | ||
| 353 | } | ||
| 354 | |||
| 355 | if ( should_run_test( q{dnssec10} ) ) { | ||
| 356 | push @results, $class->dnssec10( $zone ); | ||
| 357 | } | ||
| 358 | |||
| 359 | if ( should_run_test( q{dnssec13} ) ) { | ||
| 360 | push @results, $class->dnssec13( $zone ); | ||
| 361 | } | ||
| 362 | |||
| 363 | if ( should_run_test( q{dnssec14} ) ) { | ||
| 364 | push @results, $class->dnssec14( $zone ); | ||
| 365 | } | ||
| 366 | |||
| 367 | if ( should_run_test( q{dnssec15} ) ) { | ||
| 368 | push @results, $class->dnssec15( $zone ); | ||
| 369 | } | ||
| 370 | |||
| 371 | if ( should_run_test( q{dnssec16} ) ) { | ||
| 372 | push @results, $class->dnssec16( $zone ); | ||
| 373 | } | ||
| 374 | |||
| 375 | if ( should_run_test( q{dnssec17} ) ) { | ||
| 376 | push @results, $class->dnssec17( $zone ); | ||
| 377 | } | ||
| 378 | |||
| 379 | if ( should_run_test( q{dnssec18} ) ) { | ||
| 380 | push @results, $class->dnssec18( $zone ); | ||
| 381 | } | ||
| 382 | |||
| 383 | return @results; | ||
| 384 | } ## end sub all | ||
| 385 | |||
| 386 | =over | ||
| 387 | |||
| 388 | =item metadata() | ||
| 389 | |||
| 390 | my $hash_ref = metadata(); | ||
| 391 | |||
| 392 | Returns a reference to a hash, the keys of which are the names of all Test Cases in the module, and the corresponding values are references to | ||
| 393 | an array containing all the message tags that the Test Case can use in L<log entries|Zonemaster::Engine::Logger::Entry>. | ||
| 394 | |||
| 395 | =back | ||
| 396 | |||
| 397 | =cut | ||
| 398 | |||
| 399 | sub metadata { | ||
| 400 | my ( $class ) = @_; | ||
| 401 | |||
| 402 | return { | ||
| 403 | dnssec01 => [ | ||
| 404 | qw( | ||
| 405 | DS01_DS_ALGO_2_MISSING | ||
| 406 | DS01_DS_ALGO_DEPRECATED | ||
| 407 | DS01_DS_ALGO_NOT_DS | ||
| 408 | DS01_DS_ALGO_OK | ||
| 409 | DS01_DS_ALGO_PRIVATE | ||
| 410 | DS01_DS_ALGO_RESERVED | ||
| 411 | DS01_DS_ALGO_UNASSIGNED | ||
| 412 | DS01_NO_RESPONSE | ||
| 413 | DS01_PARENT_SERVER_NO_DS | ||
| 414 | DS01_PARENT_ZONE_NO_DS | ||
| 415 | DS01_ROOT_N_NO_UNDEL_DS | ||
| 416 | DS01_UNDEL_N_NO_UNDEL_DS | ||
| 417 | ) | ||
| 418 | ], | ||
| 419 | dnssec02 => [ | ||
| 420 | qw( | ||
| 421 | DS02_ALGO_NOT_SUPPORTED_BY_ZM | ||
| 422 | DS02_DNSKEY_NOT_FOR_ZONE_SIGNING | ||
| 423 | DS02_DNSKEY_NOT_SEP | ||
| 424 | DS02_DNSKEY_NOT_SIGNED_BY_ANY_DS | ||
| 425 | DS02_NO_DNSKEY_FOR_DS | ||
| 426 | DS02_NO_MATCHING_DNSKEY_RRSIG | ||
| 427 | DS02_NO_MATCH_DS_DNSKEY | ||
| 428 | DS02_NO_VALID_DNSKEY_FOR_ANY_DS | ||
| 429 | DS02_RRSIG_NOT_VALID_BY_DNSKEY | ||
| 430 | ) | ||
| 431 | ], | ||
| 432 | dnssec03 => [ | ||
| 433 | qw( | ||
| 434 | DS03_ERR_MULT_NSEC3 | ||
| 435 | DS03_ILLEGAL_HASH_ALGO | ||
| 436 | DS03_ILLEGAL_ITERATION_VALUE | ||
| 437 | DS03_ILLEGAL_SALT_LENGTH | ||
| 438 | DS03_INCONSISTENT_HASH_ALGO | ||
| 439 | DS03_INCONSISTENT_ITERATION | ||
| 440 | DS03_INCONSISTENT_NSEC3_FLAGS | ||
| 441 | DS03_INCONSISTENT_SALT_LENGTH | ||
| 442 | DS03_LEGAL_EMPTY_SALT | ||
| 443 | DS03_LEGAL_HASH_ALGO | ||
| 444 | DS03_LEGAL_ITERATION_VALUE | ||
| 445 | DS03_NO_DNSSEC_SUPPORT | ||
| 446 | DS03_NO_NSEC3 | ||
| 447 | DS03_NSEC3_OPT_OUT_DISABLED | ||
| 448 | DS03_NSEC3_OPT_OUT_ENABLED_NON_TLD | ||
| 449 | DS03_NSEC3_OPT_OUT_ENABLED_TLD | ||
| 450 | DS03_SERVER_NO_DNSSEC_SUPPORT | ||
| 451 | DS03_SERVER_NO_NSEC3 | ||
| 452 | DS03_UNASSIGNED_FLAG_USED | ||
| 453 | ) | ||
| 454 | ], | ||
| 455 | dnssec04 => [ | ||
| 456 | qw( | ||
| 457 | RRSIG_EXPIRATION | ||
| 458 | RRSIG_EXPIRED | ||
| 459 | REMAINING_SHORT | ||
| 460 | REMAINING_LONG | ||
| 461 | DURATION_LONG | ||
| 462 | DURATION_OK | ||
| 463 | TEST_CASE_END | ||
| 464 | TEST_CASE_START | ||
| 465 | ) | ||
| 466 | ], | ||
| 467 | dnssec05 => [ | ||
| 468 | qw( | ||
| 469 | DS05_ALGO_DEPRECATED | ||
| 470 | DS05_ALGO_NOT_RECOMMENDED | ||
| 471 | DS05_ALGO_NOT_ZONE_SIGN | ||
| 472 | DS05_ALGO_OK | ||
| 473 | DS05_ALGO_PRIVATE | ||
| 474 | DS05_ALGO_RESERVED | ||
| 475 | DS05_ALGO_UNASSIGNED | ||
| 476 | DS05_NO_RESPONSE | ||
| 477 | DS05_SERVER_NO_DNSSEC | ||
| 478 | DS05_ZONE_NO_DNSSEC | ||
| 479 | ) | ||
| 480 | ], | ||
| 481 | dnssec06 => [ | ||
| 482 | qw( | ||
| 483 | EXTRA_PROCESSING_OK | ||
| 484 | EXTRA_PROCESSING_BROKEN | ||
| 485 | TEST_CASE_END | ||
| 486 | TEST_CASE_START | ||
| 487 | ) | ||
| 488 | ], | ||
| 489 | dnssec07 => [ | ||
| 490 | qw( | ||
| 491 | DS07_DS_FOR_SIGNED_ZONE | ||
| 492 | DS07_DS_ON_PARENT_SERVER | ||
| 493 | DS07_INCONSISTENT_DS | ||
| 494 | DS07_INCONSISTENT_SIGNED | ||
| 495 | DS07_NON_AUTH_RESPONSE_DNSKEY | ||
| 496 | DS07_NOT_SIGNED | ||
| 497 | DS07_NOT_SIGNED_ON_SERVER | ||
| 498 | DS07_NO_DS_ON_PARENT_SERVER | ||
| 499 | DS07_NO_DS_FOR_SIGNED_ZONE | ||
| 500 | DS07_NO_RESPONSE_DNSKEY | ||
| 501 | DS07_SIGNED | ||
| 502 | DS07_SIGNED_ON_SERVER | ||
| 503 | DS07_UNEXP_RCODE_RESP_DNSKEY | ||
| 504 | ) | ||
| 505 | ], | ||
| 506 | dnssec08 => [ | ||
| 507 | qw( | ||
| 508 | DS08_ALGO_NOT_SUPPORTED_BY_ZM | ||
| 509 | DS08_DNSKEY_RRSIG_EXPIRED | ||
| 510 | DS08_DNSKEY_RRSIG_NOT_YET_VALID | ||
| 511 | DS08_MISSING_RRSIG_IN_RESPONSE | ||
| 512 | DS08_NO_MATCHING_DNSKEY | ||
| 513 | DS08_RRSIG_NOT_VALID_BY_DNSKEY | ||
| 514 | ) | ||
| 515 | ], | ||
| 516 | dnssec09 => [ | ||
| 517 | qw( | ||
| 518 | DS09_ALGO_NOT_SUPPORTED_BY_ZM | ||
| 519 | DS09_MISSING_RRSIG_IN_RESPONSE | ||
| 520 | DS09_NO_MATCHING_DNSKEY | ||
| 521 | DS09_RRSIG_NOT_VALID_BY_DNSKEY | ||
| 522 | DS09_SOA_RRSIG_EXPIRED | ||
| 523 | DS09_SOA_RRSIG_NOT_YET_VALID | ||
| 524 | ) | ||
| 525 | ], | ||
| 526 | dnssec10 => [ | ||
| 527 | qw( | ||
| 528 | DS10_ALGO_NOT_SUPPORTED_BY_ZM | ||
| 529 | DS10_ERR_MULT_NSEC | ||
| 530 | DS10_ERR_MULT_NSEC3 | ||
| 531 | DS10_EXPECTED_NSEC_NSEC3_MISSING | ||
| 532 | DS10_HAS_NSEC | ||
| 533 | DS10_HAS_NSEC3 | ||
| 534 | DS10_INCONSISTENT_NSEC | ||
| 535 | DS10_INCONSISTENT_NSEC3 | ||
| 536 | DS10_INCONSISTENT_NSEC_NSEC3 | ||
| 537 | DS10_MIXED_NSEC_NSEC3 | ||
| 538 | DS10_NSEC3PARAM_GIVES_ERR_ANSWER | ||
| 539 | DS10_NSEC3PARAM_MISMATCHES_APEX | ||
| 540 | DS10_NSEC3PARAM_QUERY_RESPONSE_ERR | ||
| 541 | DS10_NSEC3_ERR_TYPE_LIST | ||
| 542 | DS10_NSEC3_MISMATCHES_APEX | ||
| 543 | DS10_NSEC3_MISSING_SIGNATURE | ||
| 544 | DS10_NSEC3_NODATA_MISSING_SOA | ||
| 545 | DS10_NSEC3_NODATA_WRONG_SOA | ||
| 546 | DS10_NSEC3_NO_VERIFIED_SIGNATURE | ||
| 547 | DS10_NSEC3_RRSIG_EXPIRED | ||
| 548 | DS10_NSEC3_RRSIG_NOT_YET_VALID | ||
| 549 | DS10_NSEC3_RRSIG_NO_DNSKEY | ||
| 550 | DS10_NSEC3_RRSIG_VERIFY_ERROR | ||
| 551 | DS10_NSEC_ERR_TYPE_LIST | ||
| 552 | DS10_NSEC_GIVES_ERR_ANSWER | ||
| 553 | DS10_NSEC_MISMATCHES_APEX | ||
| 554 | DS10_NSEC_MISSING_SIGNATURE | ||
| 555 | DS10_NSEC_NODATA_MISSING_SOA | ||
| 556 | DS10_NSEC_NODATA_WRONG_SOA | ||
| 557 | DS10_NSEC_NO_VERIFIED_SIGNATURE | ||
| 558 | DS10_NSEC_QUERY_RESPONSE_ERR | ||
| 559 | DS10_NSEC_RRSIG_EXPIRED | ||
| 560 | DS10_NSEC_RRSIG_NOT_YET_VALID | ||
| 561 | DS10_NSEC_RRSIG_NO_DNSKEY | ||
| 562 | DS10_NSEC_RRSIG_VERIFY_ERROR | ||
| 563 | DS10_NONSTANDARD_NSEC_RESPONSE | ||
| 564 | DS10_SERVER_NO_DNSSEC | ||
| 565 | DS10_ZONE_NO_DNSSEC | ||
| 566 | ) | ||
| 567 | ], | ||
| 568 | dnssec11 => [ | ||
| 569 | qw( | ||
| 570 | DS11_INCONSISTENT_DS | ||
| 571 | DS11_INCONSISTENT_SIGNED_ZONE | ||
| 572 | DS11_UNDETERMINED_DS | ||
| 573 | DS11_UNDETERMINED_SIGNED_ZONE | ||
| 574 | DS11_PARENT_WITHOUT_DS | ||
| 575 | DS11_PARENT_WITH_DS | ||
| 576 | DS11_NS_WITH_SIGNED_ZONE | ||
| 577 | DS11_NS_WITH_UNSIGNED_ZONE | ||
| 578 | DS11_DS_BUT_UNSIGNED_ZONE | ||
| 579 | ), | ||
| 580 | ], | ||
| 581 | dnssec13 => [ | ||
| 582 | qw( | ||
| 583 | DS13_ALGO_NOT_SIGNED_DNSKEY | ||
| 584 | DS13_ALGO_NOT_SIGNED_NS | ||
| 585 | DS13_ALGO_NOT_SIGNED_SOA | ||
| 586 | ), | ||
| 587 | ], | ||
| 588 | dnssec14 => [ | ||
| 589 | qw( | ||
| 590 | NO_RESPONSE | ||
| 591 | NO_RESPONSE_DNSKEY | ||
| 592 | DNSKEY_SMALLER_THAN_REC | ||
| 593 | DNSKEY_TOO_SMALL_FOR_ALGO | ||
| 594 | DNSKEY_TOO_LARGE_FOR_ALGO | ||
| 595 | IPV4_DISABLED | ||
| 596 | IPV6_DISABLED | ||
| 597 | KEY_SIZE_OK | ||
| 598 | TEST_CASE_END | ||
| 599 | TEST_CASE_START | ||
| 600 | ), | ||
| 601 | ], | ||
| 602 | dnssec15 => [ | ||
| 603 | qw( | ||
| 604 | DS15_HAS_CDNSKEY_NO_CDS | ||
| 605 | DS15_HAS_CDS_AND_CDNSKEY | ||
| 606 | DS15_HAS_CDS_NO_CDNSKEY | ||
| 607 | DS15_INCONSISTENT_CDNSKEY | ||
| 608 | DS15_INCONSISTENT_CDS | ||
| 609 | DS15_MISMATCH_CDS_CDNSKEY | ||
| 610 | DS15_NO_CDS_CDNSKEY | ||
| 611 | ), | ||
| 612 | ], | ||
| 613 | dnssec16 => [ | ||
| 614 | qw( | ||
| 615 | DS16_CDS_INVALID_RRSIG | ||
| 616 | DS16_CDS_MATCHES_NON_SEP_DNSKEY | ||
| 617 | DS16_CDS_MATCHES_NON_ZONE_DNSKEY | ||
| 618 | DS16_CDS_MATCHES_NO_DNSKEY | ||
| 619 | DS16_CDS_NOT_SIGNED_BY_CDS | ||
| 620 | DS16_CDS_SIGNED_BY_UNKNOWN_DNSKEY | ||
| 621 | DS16_CDS_UNSIGNED | ||
| 622 | DS16_CDS_WITHOUT_DNSKEY | ||
| 623 | DS16_DELETE_CDS | ||
| 624 | DS16_DNSKEY_NOT_SIGNED_BY_CDS | ||
| 625 | DS16_MIXED_DELETE_CDS | ||
| 626 | ), | ||
| 627 | ], | ||
| 628 | dnssec17 => [ | ||
| 629 | qw( | ||
| 630 | DS17_CDNSKEY_INVALID_RRSIG | ||
| 631 | DS17_CDNSKEY_IS_NON_SEP | ||
| 632 | DS17_CDNSKEY_IS_NON_ZONE | ||
| 633 | DS17_CDNSKEY_MATCHES_NO_DNSKEY | ||
| 634 | DS17_CDNSKEY_NOT_SIGNED_BY_CDNSKEY | ||
| 635 | DS17_CDNSKEY_SIGNED_BY_UNKNOWN_DNSKEY | ||
| 636 | DS17_CDNSKEY_UNSIGNED | ||
| 637 | DS17_CDNSKEY_WITHOUT_DNSKEY | ||
| 638 | DS17_DELETE_CDNSKEY | ||
| 639 | DS17_DNSKEY_NOT_SIGNED_BY_CDNSKEY | ||
| 640 | DS17_MIXED_DELETE_CDNSKEY | ||
| 641 | ), | ||
| 642 | ], | ||
| 643 | dnssec18 => [ | ||
| 644 | qw( | ||
| 645 | DS18_NO_MATCH_CDS_RRSIG_DS | ||
| 646 | DS18_NO_MATCH_CDNSKEY_RRSIG_DS | ||
| 647 | ), | ||
| 648 | ], | ||
| 649 | }; | ||
| 650 | } ## end sub metadata | ||
| 651 | |||
| 652 | Readonly my %TAG_DESCRIPTIONS => ( | ||
| 653 | DNSSEC01 => sub { | ||
| 654 | __x # DNSSEC:DNSSEC01 | ||
| 655 | "Legal values for the DS hash digest algorithm"; | ||
| 656 | }, | ||
| 657 | DNSSEC02 => sub { | ||
| 658 | __x # DNSSEC:DNSSEC02 | ||
| 659 | "DS must match a valid DNSKEY in the child zone"; | ||
| 660 | }, | ||
| 661 | DNSSEC03 => sub { | ||
| 662 | __x # DNSSEC:DNSSEC03 | ||
| 663 | "Verify NSEC3 parameters"; | ||
| 664 | }, | ||
| 665 | DNSSEC04 => sub { | ||
| 666 | __x # DNSSEC:DNSSEC04 | ||
| 667 | "Check for too short or too long RRSIG lifetimes"; | ||
| 668 | }, | ||
| 669 | DNSSEC05 => sub { | ||
| 670 | __x # DNSSEC:DNSSEC05 | ||
| 671 | "Check for invalid DNSKEY algorithms"; | ||
| 672 | }, | ||
| 673 | DNSSEC06 => sub { | ||
| 674 | __x # DNSSEC:DNSSEC06 | ||
| 675 | "Verify DNSSEC additional processing"; | ||
| 676 | }, | ||
| 677 | DNSSEC07 => sub { | ||
| 678 | __x # DNSSEC:DNSSEC07 | ||
| 679 | "DNSSEC signed zone and DS in parent for signed zone"; | ||
| 680 | }, | ||
| 681 | DNSSEC08 => sub { | ||
| 682 | __x # DNSSEC:DNSSEC08 | ||
| 683 | "Valid RRSIG for DNSKEY"; | ||
| 684 | }, | ||
| 685 | DNSSEC09 => sub { | ||
| 686 | __x # DNSSEC:DNSSEC09 | ||
| 687 | "RRSIG(SOA) must be valid and created by a valid DNSKEY"; | ||
| 688 | }, | ||
| 689 | DNSSEC10 => sub { | ||
| 690 | __x # DNSSEC:DNSSEC10 | ||
| 691 | "Zone contains NSEC or NSEC3 records"; | ||
| 692 | }, | ||
| 693 | DNSSEC11 => sub { | ||
| 694 | __x # DNSSEC:DNSSEC11 | ||
| 695 | "DS in delegation requires signed zone"; | ||
| 696 | }, | ||
| 697 | DNSSEC12 => sub { | ||
| 698 | __x # DNSSEC:DNSSEC12 | ||
| 699 | "Test for DNSSEC Algorithm Completeness"; | ||
| 700 | }, | ||
| 701 | DNSSEC13 => sub { | ||
| 702 | __x # DNSSEC:DNSSEC13 | ||
| 703 | "All DNSKEY algorithms used to sign the zone"; | ||
| 704 | }, | ||
| 705 | DNSSEC14 => sub { | ||
| 706 | __x # DNSSEC:DNSSEC14 | ||
| 707 | "Check for valid RSA DNSKEY key size"; | ||
| 708 | }, | ||
| 709 | DNSSEC15 => sub { | ||
| 710 | __x # DNSSEC:DNSSEC15 | ||
| 711 | "Existence of CDS and CDNSKEY"; | ||
| 712 | }, | ||
| 713 | DNSSEC16 => sub { | ||
| 714 | __x # DNSSEC:DNSSEC16 | ||
| 715 | "Validate CDS"; | ||
| 716 | }, | ||
| 717 | DNSSEC17 => sub { | ||
| 718 | __x # DNSSEC:DNSSEC17 | ||
| 719 | "Validate CDNSKEY"; | ||
| 720 | }, | ||
| 721 | DNSSEC18 => sub { | ||
| 722 | __x # DNSSEC:DNSSEC18 | ||
| 723 | "Validate trust from DS to CDS and CDNSKEY"; | ||
| 724 | }, | ||
| 725 | DNSKEY_SMALLER_THAN_REC => sub { | ||
| 726 | __x # DNSSEC:DNSKEY_SMALLER_THAN_REC | ||
| 727 | 'DNSKEY with tag {keytag} and using algorithm {algo_num} ' | ||
| 728 | . '({algo_descr}) has a size ({keysize}) smaller than the ' | ||
| 729 | . 'recommended one ({keysizerec}).', | ||
| 730 | @_; | ||
| 731 | }, | ||
| 732 | DNSKEY_TOO_SMALL_FOR_ALGO => sub { | ||
| 733 | __x # DNSSEC:DNSKEY_TOO_SMALL_FOR_ALGO | ||
| 734 | 'DNSKEY with tag {keytag} and using algorithm {algo_num} ' | ||
| 735 | . '({algo_descr}) has a size ({keysize}) smaller than the minimum ' | ||
| 736 | . 'one ({keysizemin}).', | ||
| 737 | @_; | ||
| 738 | }, | ||
| 739 | DNSKEY_TOO_LARGE_FOR_ALGO => sub { | ||
| 740 | __x # DNSSEC:DNSKEY_TOO_LARGE_FOR_ALGO | ||
| 741 | 'DNSKEY with tag {keytag} and using algorithm {algo_num} ' | ||
| 742 | . '({algo_descr}) has a size ({keysize}) larger than the maximum one ' | ||
| 743 | . '({keysizemax}).', | ||
| 744 | @_; | ||
| 745 | }, | ||
| 746 | DS01_DS_ALGO_2_MISSING => sub { | ||
| 747 | __x # DNSSEC:DS01_DS_ALGO_2_MISSING | ||
| 748 | 'There is a DS record with keytag {keytag}. A DS record using digest algorithm 2 (SHA-256) ' | ||
| 749 | . 'is missing. Fetched from parent name servers "{ns_list}".', | ||
| 750 | @_; | ||
| 751 | }, | ||
| 752 | DS01_DS_ALGO_DEPRECATED => sub { | ||
| 753 | __x # DNSSEC:DS01_DS_ALGO_DEPRECATED | ||
| 754 | 'The DS record with keytag {keytag} uses a deprecated digest algorithm {ds_algo_num} ' | ||
| 755 | . '({ds_algo_descr}). Fetched from parent name servers "{ns_list}".', | ||
| 756 | @_; | ||
| 757 | }, | ||
| 758 | DS01_DS_ALGO_NOT_DS => sub { | ||
| 759 | __x # DNSSEC:DS01_DS_ALGO_NOT_DS | ||
| 760 | 'The DS record with keytag {keytag} uses a digest algorithm {ds_algo_num} ({ds_algo_descr}) ' | ||
| 761 | . 'not meant for DS records. Fetched from parent name servers "{ns_list}".', | ||
| 762 | @_; | ||
| 763 | }, | ||
| 764 | DS01_DS_ALGO_PRIVATE => sub { | ||
| 765 | __x # DNSSEC:DS01_DS_ALGO_PRIVATE | ||
| 766 | 'The DS record with keytag {keytag} uses a digest algorithm {ds_algo_num} for private use. ' | ||
| 767 | . 'Fetched from parent name servers "{ns_list}".', | ||
| 768 | @_; | ||
| 769 | }, | ||
| 770 | DS01_DS_ALGO_RESERVED => sub { | ||
| 771 | __x # DNSSEC:DS01_DS_ALGO_RESERVED | ||
| 772 | 'The DS record with keytag {keytag} uses a reserved digest algorithm {ds_algo_num} on name ' | ||
| 773 | . 'servers "{ns_list}".', | ||
| 774 | @_; | ||
| 775 | }, | ||
| 776 | DS01_DS_ALGO_UNASSIGNED => sub { | ||
| 777 | __x # DNSSEC:DS01_DS_ALGO_UNASSIGNED | ||
| 778 | 'The DS record with keytag {keytag} uses an unassigned digest algorithm {ds_algo_num} on parent ' | ||
| 779 | . 'name servers "{ns_list}".', | ||
| 780 | @_; | ||
| 781 | }, | ||
| 782 | DS01_NO_RESPONSE => sub { | ||
| 783 | __x # DNSSEC:DS01_NO_RESPONSE | ||
| 784 | 'No response or error in response from all parent name servers on the DS query. Name servers ' | ||
| 785 | . 'are "{ns_list}".', | ||
| 786 | @_; | ||
| 787 | }, | ||
| 788 | DS01_PARENT_SERVER_NO_DS => sub { | ||
| 789 | __x # DNSSEC:DS01_PARENT_SERVER_NO_DS | ||
| 790 | 'The following name servers do not provide DS record or have not been properly configured. ' | ||
| 791 | . 'Fetched from parent name servers "{ns_list}".', | ||
| 792 | @_; | ||
| 793 | }, | ||
| 794 | DS01_PARENT_ZONE_NO_DS => sub { | ||
| 795 | __x # DNSSEC:DS01_PARENT_ZONE_NO_DS | ||
| 796 | 'The parent zone provides no DS records for the child zone. Fetched from parent name ' | ||
| 797 | . 'servers "{ns_list}".', | ||
| 798 | @_; | ||
| 799 | }, | ||
| 800 | DS01_ROOT_N_NO_UNDEL_DS => sub { | ||
| 801 | __x # DNSSEC:DS01_ROOT_N_NO_UNDEL_DS | ||
| 802 | 'Tested zone is the root zone, but no undelegated DS has been provided. DS is not tested.', | ||
| 803 | @_; | ||
| 804 | }, | ||
| 805 | DS01_UNDEL_N_NO_UNDEL_DS => sub { | ||
| 806 | __x # DNSSEC:DS01_UNDEL_N_NO_UNDEL_DS | ||
| 807 | 'Tested zone is undelegated, but no undelegated DS has been provided. DS is not tested.', | ||
| 808 | @_; | ||
| 809 | }, | ||
| 810 | DS02_ALGO_NOT_SUPPORTED_BY_ZM => sub { | ||
| 811 | __x # DNSSEC:DS02_ALGO_NOT_SUPPORTED_BY_ZM | ||
| 812 | 'DNSKEY with tag {keytag} uses unsupported algorithm {algo_num} ' | ||
| 813 | . '({algo_mnemo}) by this installation of Zonemaster. Fetched from ' | ||
| 814 | . 'the nameservers with IP addresses "{ns_ip_list}".', | ||
| 815 | @_; | ||
| 816 | }, | ||
| 817 | DS02_DNSKEY_NOT_FOR_ZONE_SIGNING => sub { | ||
| 818 | __x # DNSSEC:DS02_DNSKEY_NOT_FOR_ZONE_SIGNING | ||
| 819 | 'Flags field of DNSKEY record with tag {keytag} has not ZONE bit set ' | ||
| 820 | . 'although DS with same tag is present in parent. Fetched from ' | ||
| 821 | . 'the nameservers with IP addresses "{ns_ip_list}".', | ||
| 822 | @_; | ||
| 823 | }, | ||
| 824 | DS02_DNSKEY_NOT_SEP => sub { | ||
| 825 | __x # DNSSEC:DS02_DNSKEY_NOT_SEP | ||
| 826 | 'Flags field of DNSKEY record with tag {keytag} has not SEP bit set ' | ||
| 827 | . 'although DS with same tag is present in parent. Fetched from ' | ||
| 828 | . 'the nameservers with IP addresses "{ns_ip_list}".', | ||
| 829 | @_; | ||
| 830 | }, | ||
| 831 | DS02_DNSKEY_NOT_SIGNED_BY_ANY_DS => sub { | ||
| 832 | __x # DNSSEC:DS02_DNSKEY_NOT_SIGNED_BY_ANY_DS | ||
| 833 | 'The DNSKEY RRset has not been signed by any DNSKEY matched by a DS record. ' | ||
| 834 | . 'Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 835 | @_; | ||
| 836 | }, | ||
| 837 | DS02_NO_DNSKEY_FOR_DS => sub { | ||
| 838 | __x # DNSSEC:DS02_NO_DNSKEY_FOR_DS | ||
| 839 | 'The DNSKEY record with tag {keytag} that the DS refers to does not ' | ||
| 840 | . 'exist in the DNSKEY RRset. Fetched from the nameservers with IP ' | ||
| 841 | . '"{ns_ip_list}".', | ||
| 842 | @_; | ||
| 843 | }, | ||
| 844 | DS02_NO_MATCHING_DNSKEY_RRSIG => sub { | ||
| 845 | __x # DNSSEC:DS02_NO_MATCHING_DNSKEY_RRSIG | ||
| 846 | 'The DNSKEY RRset is not signed by the DNSKEY with tag {keytag} that ' | ||
| 847 | . 'the DS record refers to. Fetched from the nameservers with IP ' | ||
| 848 | . '"{ns_ip_list}".', | ||
| 849 | @_; | ||
| 850 | }, | ||
| 851 | DS02_NO_MATCH_DS_DNSKEY => sub { | ||
| 852 | __x # DNSSEC:DS02_NO_MATCH_DS_DNSKEY | ||
| 853 | 'The DS record does not match the DNSKEY with tag {keytag} by algorithm ' | ||
| 854 | . 'or digest. Fetched from the nameservers with IP "{ns_ip_list}".', | ||
| 855 | @_; | ||
| 856 | }, | ||
| 857 | DS02_NO_VALID_DNSKEY_FOR_ANY_DS => sub { | ||
| 858 | __x # DNSSEC:DS02_NO_VALID_DNSKEY_FOR_ANY_DS | ||
| 859 | 'There is no valid DNSKEY matched by any of the DS records. ' | ||
| 860 | . 'Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 861 | @_; | ||
| 862 | }, | ||
| 863 | DS02_RRSIG_NOT_VALID_BY_DNSKEY => sub { | ||
| 864 | __x # DNSSEC:DS02_RRSIG_NOT_VALID_BY_DNSKEY | ||
| 865 | 'The DNSKEY RRset is signed with an RRSIG with tag {keytag} which cannot ' | ||
| 866 | . 'be validated by the matching DNSKEY. Fetched from the nameservers with IP ' | ||
| 867 | . 'addresses "{ns_ip_list}".', | ||
| 868 | @_; | ||
| 869 | }, | ||
| 870 | DS03_ERROR_RESPONSE_NSEC_QUERY => sub { | ||
| 871 | __x # DNSSEC:DS03_ERROR_RESPONSE_NSEC_QUERY | ||
| 872 | 'The following servers give erroneous response to NSEC query. Fetched from name servers "{ns_list}".', @_; | ||
| 873 | }, | ||
| 874 | DS03_ERR_MULT_NSEC3 => sub { | ||
| 875 | __x # DNSSEC:DS03_ERR_MULT_NSEC3 | ||
| 876 | 'Multiple NSEC3 records when one is expected. Fetched from name servers "{ns_list}".', @_; | ||
| 877 | }, | ||
| 878 | DS03_ILLEGAL_HASH_ALGO => sub { | ||
| 879 | __x # DNSSEC:DS03_ILLEGAL_HASH_ALGO | ||
| 880 | 'The following servers respond with an illegal hash algorithm for NSEC3 ({algo_num}). ' | ||
| 881 | . 'Fetched from name servers "{ns_list}".', | ||
| 882 | @_; | ||
| 883 | }, | ||
| 884 | DS03_ILLEGAL_ITERATION_VALUE => sub { | ||
| 885 | __x # DNSSEC:DS03_ILLEGAL_ITERATION_VALUE | ||
| 886 | 'The following servers respond with the NSEC3 iteration value {int}. ' | ||
| 887 | . 'The recommended practice is to set this value to 0. ' | ||
| 888 | . 'Fetched from name servers "{ns_list}".', | ||
| 889 | @_; | ||
| 890 | }, | ||
| 891 | DS03_ILLEGAL_SALT_LENGTH => sub { | ||
| 892 | __x # DNSSEC:DS03_ILLEGAL_SALT_LENGTH | ||
| 893 | 'The following servers respond with a non-empty salt in NSEC3 ({int} octets). ' | ||
| 894 | . 'The recommended practice is to use an empty salt. ' | ||
| 895 | . 'Fetched from name servers "{ns_list}".', | ||
| 896 | @_; | ||
| 897 | }, | ||
| 898 | DS03_INCONSISTENT_HASH_ALGO => sub { | ||
| 899 | __x # DNSSEC:DS03_INCONSISTENT_HASH_ALGO | ||
| 900 | 'Inconsistent hash algorithm in NSEC3 in responses for the child zone from different name servers.', @_; | ||
| 901 | }, | ||
| 902 | DS03_INCONSISTENT_ITERATION => sub { | ||
| 903 | __x # DNSSEC:DS03_INCONSISTENT_ITERATION | ||
| 904 | 'Inconsistent NSEC3 iteration value in responses for the child zone from different name servers.', @_; | ||
| 905 | }, | ||
| 906 | DS03_INCONSISTENT_NSEC3_FLAGS => sub { | ||
| 907 | __x # DNSSEC:DS03_INCONSISTENT_NSEC3_FLAGS | ||
| 908 | 'Inconsistent NSEC3 flag list in responses for the child zone from different name servers.', @_; | ||
| 909 | }, | ||
| 910 | DS03_INCONSISTENT_SALT_LENGTH => sub { | ||
| 911 | __x # DNSSEC:DS03_INCONSISTENT_SALT_LENGTH | ||
| 912 | 'Inconsistent salt length in NSEC3 in responses for the child zone from different name servers.', @_; | ||
| 913 | }, | ||
| 914 | DS03_LEGAL_EMPTY_SALT => sub { | ||
| 915 | __x # DNSSEC:DS03_LEGAL_EMPTY_SALT | ||
| 916 | 'The following servers respond with a legal empty salt in NSEC3. ' | ||
| 917 | . 'Fetched from name servers "{ns_list}".', | ||
| 918 | @_; | ||
| 919 | }, | ||
| 920 | DS03_LEGAL_HASH_ALGO => sub { | ||
| 921 | __x # DNSSEC:DS03_LEGAL_HASH_ALGO | ||
| 922 | 'The following servers respond with a legal hash algorithm in NSEC3. ' | ||
| 923 | . 'Fetched from name servers "{ns_list}".', | ||
| 924 | @_; | ||
| 925 | }, | ||
| 926 | DS03_LEGAL_ITERATION_VALUE => sub { | ||
| 927 | __x # DNSSEC:DS03_LEGAL_ITERATION_VALUE | ||
| 928 | 'The following servers respond with NSEC3 iteration value set to zero (as recommended). ' | ||
| 929 | . 'Fetched from name servers "{ns_list}".', | ||
| 930 | @_; | ||
| 931 | }, | ||
| 932 | DS03_NO_DNSSEC_SUPPORT => sub { | ||
| 933 | __x # DNSSEC:DS03_NO_DNSSEC_SUPPORT | ||
| 934 | 'The zone is not DNSSEC signed or not properly DNSSEC signed. Testing for NSEC3 has been skipped. ' | ||
| 935 | . 'Fetched from name servers "{ns_list}".', | ||
| 936 | @_; | ||
| 937 | }, | ||
| 938 | DS03_NO_NSEC3 => sub { | ||
| 939 | __x # DNSSEC:DS03_NO_NSEC3 | ||
| 940 | 'The zone does not use NSEC3. Testing for NSEC3 has been skipped. ' | ||
| 941 | . 'Fetched from name servers "{ns_list}".', | ||
| 942 | @_; | ||
| 943 | }, | ||
| 944 | DS03_NO_RESPONSE_NSEC_QUERY => sub { | ||
| 945 | __x # DNSSEC:DS03_NO_RESPONSE_NSEC_QUERY | ||
| 946 | 'The following servers do not respond to NSEC query. Fetched from name servers "{ns_list}".', @_; | ||
| 947 | }, | ||
| 948 | DS03_NSEC3_OPT_OUT_DISABLED => sub { | ||
| 949 | __x # DNSSEC:DS03_NSEC3_OPT_OUT_DISABLED | ||
| 950 | 'The following servers respond with NSEC3 opt-out disabled (as recommended). ' | ||
| 951 | . 'Fetched from name servers "{ns_list}".', | ||
| 952 | @_; | ||
| 953 | }, | ||
| 954 | DS03_NSEC3_OPT_OUT_ENABLED_NON_TLD => sub { | ||
| 955 | __x # DNSSEC:DS03_NSEC3_OPT_OUT_ENABLED_NON_TLD | ||
| 956 | 'The following servers respond with NSEC3 opt-out enabled. ' | ||
| 957 | . 'The recommended practice is to disable opt-out. ' | ||
| 958 | . 'Fetched from name servers "{ns_list}".', | ||
| 959 | @_; | ||
| 960 | }, | ||
| 961 | DS03_NSEC3_OPT_OUT_ENABLED_TLD => sub { | ||
| 962 | __x # DNSSEC:DS03_NSEC3_OPT_OUT_ENABLED_TLD | ||
| 963 | 'The following servers respond with NSEC3 opt-out enabled. ' | ||
| 964 | . 'Fetched from name servers "{ns_list}".', | ||
| 965 | @_; | ||
| 966 | }, | ||
| 967 | DS03_SERVER_NO_DNSSEC_SUPPORT => sub { | ||
| 968 | __x # DNSSEC:DS03_SERVER_NO_DNSSEC_SUPPORT | ||
| 969 | 'The following name servers do not support DNSSEC or have not been properly configured. ' | ||
| 970 | . 'Testing for NSEC3 has been skipped on those servers. ' | ||
| 971 | . 'Fetched from name servers "{ns_list}".', | ||
| 972 | @_; | ||
| 973 | }, | ||
| 974 | DS03_SERVER_NO_NSEC3 => sub { | ||
| 975 | __x # DNSSEC:DS03_SERVER_NO_NSEC3 | ||
| 976 | 'The following name servers do not use NSEC3, but others do. ' | ||
| 977 | . 'Testing for NSEC3 has been skipped on the following servers. ' | ||
| 978 | . 'Fetched from name servers "{ns_list}".', | ||
| 979 | @_; | ||
| 980 | }, | ||
| 981 | DS03_UNASSIGNED_FLAG_USED => sub { | ||
| 982 | __x # DNSSEC:DS03_UNASSIGNED_FLAG_USED | ||
| 983 | 'The following servers respond with an NSEC3 record where an unassigned flag is used (bit {int}). ' | ||
| 984 | . 'Fetched from name servers "{ns_list}".', | ||
| 985 | @_; | ||
| 986 | }, | ||
| 987 | DS05_ALGO_DEPRECATED => sub { | ||
| 988 | __x # DNSSEC:DS05_ALGO_DEPRECATED | ||
| 989 | 'The DNSKEY with tag {keytag} uses deprecated algorithm number {algo_num} ("{algo_descr}", {algo_mnemo}). ' | ||
| 990 | . 'Fetched from name servers "{ns_list}".', | ||
| 991 | @_; | ||
| 992 | }, | ||
| 993 | DS05_ALGO_NOT_RECOMMENDED => sub { | ||
| 994 | __x # DNSSEC:DS05_ALGO_NOT_RECOMMENDED | ||
| 995 | 'The DNSKEY with tag {keytag} uses unrecommended algorithm number {algo_num} ("{algo_descr}", {algo_mnemo}). ' | ||
| 996 | . 'Fetched from name servers "{ns_list}".', | ||
| 997 | @_; | ||
| 998 | }, | ||
| 999 | DS05_ALGO_NOT_ZONE_SIGN => sub { | ||
| 1000 | __x # DNSSEC:DS05_ALGO_NOT_ZONE_SIGN | ||
| 1001 | 'The DNSKEY with tag {keytag} uses algorithm number {algo_num} ("{algo_descr}", {algo_mnemo}) which is ' | ||
| 1002 | . 'not meant for zone signing. Fetched from name servers "{ns_list}".', | ||
| 1003 | @_; | ||
| 1004 | }, | ||
| 1005 | DS05_ALGO_OK => sub { | ||
| 1006 | __x # DNSSEC:DS05_ALGO_OK | ||
| 1007 | 'The DNSKEY with tag {keytag} uses algorithm number {algo_num} ("{algo_descr}", {algo_mnemo}). ' | ||
| 1008 | . 'Fetched from name servers "{ns_list}".', | ||
| 1009 | @_; | ||
| 1010 | }, | ||
| 1011 | DS05_ALGO_PRIVATE => sub { | ||
| 1012 | __x # DNSSEC:DS05_ALGO_PRIVATE | ||
| 1013 | 'The DNSKEY with tag {keytag} uses algorithm number {algo_num} which is ' | ||
| 1014 | . 'reserved for private use. Fetched from name servers "{ns_list}".', | ||
| 1015 | @_; | ||
| 1016 | }, | ||
| 1017 | DS05_ALGO_RESERVED => sub { | ||
| 1018 | __x # DNSSEC:DS05_ALGO_RESERVED | ||
| 1019 | 'The DNSKEY with tag {keytag} uses reserved algorithm number {algo_num}. ' | ||
| 1020 | . 'Fetched from name servers "{ns_list}".', | ||
| 1021 | @_; | ||
| 1022 | }, | ||
| 1023 | DS05_ALGO_UNASSIGNED => sub { | ||
| 1024 | __x # DNSSEC:DS05_ALGO_UNASSIGNED | ||
| 1025 | 'The DNSKEY with tag {keytag} uses unassigned algorithm number {algo_num}. ' | ||
| 1026 | . 'Fetched from name servers "{ns_list}".', | ||
| 1027 | @_; | ||
| 1028 | }, | ||
| 1029 | DS05_NO_RESPONSE => sub { | ||
| 1030 | __x # DNSSEC:DS05_NO_RESPONSE | ||
| 1031 | 'No response or error in response from all name servers on the DNSKEY query. Failing name servers: "{ns_list}".', | ||
| 1032 | @_; | ||
| 1033 | }, | ||
| 1034 | DS05_SERVER_NO_DNSSEC => sub { | ||
| 1035 | __x # DNSSEC:DS05_SERVER_NO_DNSSEC | ||
| 1036 | 'Some name servers do not support DNSSEC or have not been properly configured. DNSKEY cannot be tested on ' | ||
| 1037 | . 'those servers. Fetched from name servers "{ns_list}".', | ||
| 1038 | @_; | ||
| 1039 | }, | ||
| 1040 | DS05_ZONE_NO_DNSSEC => sub { | ||
| 1041 | __x # DNSSEC:DS05_ZONE_NO_DNSSEC | ||
| 1042 | 'The zone is not DNSSEC signed or not properly DNSSEC signed. DNSKEY cannot be tested. Fetched from name ' | ||
| 1043 | . 'servers "{ns_list}".', | ||
| 1044 | @_; | ||
| 1045 | }, | ||
| 1046 | DS07_DS_FOR_SIGNED_ZONE => sub { | ||
| 1047 | __x # DNSSEC:DS07_DS_FOR_SIGNED_ZONE | ||
| 1048 | 'The parent zone has DS record or records for the signed child zone.'; | ||
| 1049 | }, | ||
| 1050 | DS07_DS_ON_PARENT_SERVER => sub { | ||
| 1051 | __x # DNSSEC:DS07_DS_ON_PARENT_SERVER | ||
| 1052 | 'The following parent name servers respond with DS record or records for the child ' | ||
| 1053 | . 'zone. Name servers: "{ns_list}".', | ||
| 1054 | @_; | ||
| 1055 | }, | ||
| 1056 | DS07_INCONSISTENT_DS => sub { | ||
| 1057 | __x # DNSSEC:DS07_INCONSISTENT_DS | ||
| 1058 | 'Inconsistent responses from parent name servers. Some include DS, others do not.'; | ||
| 1059 | }, | ||
| 1060 | DS07_INCONSISTENT_SIGNED => sub { | ||
| 1061 | __x # DNSSEC:DS07_INCONSISTENT_SIGNED | ||
| 1062 | 'Inconsistent responses from name servers. Some include signed responses, others do not.'; | ||
| 1063 | }, | ||
| 1064 | DS07_NON_AUTH_RESPONSE_DNSKEY => sub { | ||
| 1065 | __x # DNSSEC:DS07_NON_AUTH_RESPONSE_DNSKEY | ||
| 1066 | 'The following name servers give a non authoritative response on DNSKEY query with DO bit set. ' | ||
| 1067 | . 'Name servers: "{ns_list}".', | ||
| 1068 | @_; | ||
| 1069 | }, | ||
| 1070 | DS07_NOT_SIGNED => sub { | ||
| 1071 | __x # DNSSEC:DS07_NOT_SIGNED | ||
| 1072 | 'The zone is not signed.'; | ||
| 1073 | }, | ||
| 1074 | DS07_NOT_SIGNED_ON_SERVER => sub { | ||
| 1075 | __x # DNSSEC:DS07_NOT_SIGNED_ON_SERVER | ||
| 1076 | 'The following name servers respond with no DNSKEY (unsigned child zone). ' | ||
| 1077 | . 'Name servers: "{ns_list}".', | ||
| 1078 | @_; | ||
| 1079 | }, | ||
| 1080 | DS07_NO_DS_ON_PARENT_SERVER => sub { | ||
| 1081 | __x # DNSSEC:DS07_NO_DS_ON_PARENT_SERVER | ||
| 1082 | 'The following parent name servers respond without DS record for the child zone. ' | ||
| 1083 | . 'Name servers: "{ns_list}".', | ||
| 1084 | @_; | ||
| 1085 | }, | ||
| 1086 | DS07_NO_DS_FOR_SIGNED_ZONE => sub { | ||
| 1087 | __x # DNSSEC:DS07_NO_DS_FOR_SIGNED_ZONE | ||
| 1088 | 'The parent zone has no DS record for the signed child zone.'; | ||
| 1089 | }, | ||
| 1090 | DS07_NO_RESPONSE_DNSKEY => sub { | ||
| 1091 | __x # DNSSEC:DS07_NO_RESPONSE_DNSKEY | ||
| 1092 | 'The following name servers do not respond on DNSKEY query with DO bit set. ' | ||
| 1093 | . 'Name servers: "{ns_list}".', | ||
| 1094 | @_; | ||
| 1095 | }, | ||
| 1096 | DS07_SIGNED => sub { | ||
| 1097 | __x # DNSSEC:DS07_SIGNED | ||
| 1098 | 'The zone is signed.'; | ||
| 1099 | }, | ||
| 1100 | DS07_SIGNED_ON_SERVER => sub { | ||
| 1101 | __x # DNSSEC:DS07_SIGNED_ON_SERVER | ||
| 1102 | 'The following name servers respond with DNSKEY (signed child zone). ' | ||
| 1103 | . 'Name servers: "{ns_list}".', | ||
| 1104 | @_; | ||
| 1105 | }, | ||
| 1106 | DS07_UNEXP_RCODE_RESP_DNSKEY => sub { | ||
| 1107 | __x # DNSSEC:DS07_UNEXP_RCODE_RESP_DNSKEY | ||
| 1108 | 'The following name servers respond with RCODE "{rcode}" instead of expected "NOERROR" ' | ||
| 1109 | . 'on DNSKEY query with DO bit set. Name servers: "{ns_list}".', | ||
| 1110 | @_; | ||
| 1111 | }, | ||
| 1112 | DS08_ALGO_NOT_SUPPORTED_BY_ZM => sub { | ||
| 1113 | __x # DNSSEC:DS08_ALGO_NOT_SUPPORTED_BY_ZM | ||
| 1114 | 'DNSKEY with tag {keytag} uses unsupported algorithm {algo_num} ' | ||
| 1115 | . '({algo_mnemo}) by this installation of Zonemaster. Fetched from ' | ||
| 1116 | . 'the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1117 | @_; | ||
| 1118 | }, | ||
| 1119 | DS08_DNSKEY_RRSIG_EXPIRED => sub { | ||
| 1120 | __x # DNSSEC:DS08_DNSKEY_RRSIG_EXPIRED | ||
| 1121 | 'RRSIG with keytag {keytag} and covering type DNSKEY has already expired. ' | ||
| 1122 | . 'Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1123 | @_; | ||
| 1124 | }, | ||
| 1125 | DS08_DNSKEY_RRSIG_NOT_YET_VALID => sub { | ||
| 1126 | __x # DNSSEC:DS08_DNSKEY_RRSIG_NOT_YET_VALID | ||
| 1127 | 'RRSIG with keytag {keytag} and covering type DNSKEY has inception date in ' | ||
| 1128 | . 'the future. Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1129 | @_; | ||
| 1130 | }, | ||
| 1131 | DS08_MISSING_RRSIG_IN_RESPONSE => sub { | ||
| 1132 | __x # DNSSEC:DS08_MISSING_RRSIG_IN_RESPONSE | ||
| 1133 | 'The DNSKEY RRset is not signed, which is against expectation. Fetched ' | ||
| 1134 | . 'from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1135 | @_; | ||
| 1136 | }, | ||
| 1137 | DS08_NO_MATCHING_DNSKEY => sub { | ||
| 1138 | __x # DNSSEC:DS08_NO_MATCHING_DNSKEY | ||
| 1139 | 'The DNSKEY RRset is signed with an RRSIG with tag {keytag} which does ' | ||
| 1140 | . 'not match any DNSKEY record. Fetched from the nameservers with IP ' | ||
| 1141 | . 'addresses "{ns_ip_list}".', | ||
| 1142 | @_; | ||
| 1143 | }, | ||
| 1144 | DS08_RRSIG_NOT_VALID_BY_DNSKEY => sub { | ||
| 1145 | __x # DNSSEC:DS08_RRSIG_NOT_VALID_BY_DNSKEY | ||
| 1146 | 'The DNSKEY RRset is signed with an RRSIG with tag {keytag} which cannot ' | ||
| 1147 | . 'be validated by the matching DNSKEY. Fetched from the nameservers with IP ' | ||
| 1148 | . 'addresses "{ns_ip_list}".', | ||
| 1149 | @_; | ||
| 1150 | }, | ||
| 1151 | DS09_ALGO_NOT_SUPPORTED_BY_ZM => sub { | ||
| 1152 | __x # DNSSEC:DS09_ALGO_NOT_SUPPORTED_BY_ZM | ||
| 1153 | 'DNSKEY with tag {keytag} uses unsupported algorithm {algo_num} ' | ||
| 1154 | . '({algo_mnemo}) by this installation of Zonemaster. Fetched from ' | ||
| 1155 | . 'the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1156 | @_; | ||
| 1157 | }, | ||
| 1158 | DS09_MISSING_RRSIG_IN_RESPONSE => sub { | ||
| 1159 | __x # DNSSEC:DS09_MISSING_RRSIG_IN_RESPONSE | ||
| 1160 | 'The SOA RRset is not signed, which is against expectation. Fetched ' | ||
| 1161 | . 'from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1162 | @_; | ||
| 1163 | }, | ||
| 1164 | DS09_NO_MATCHING_DNSKEY => sub { | ||
| 1165 | __x # DNSSEC:DS09_NO_MATCHING_DNSKEY | ||
| 1166 | 'The SOA RRset is signed with an RRSIG with tag {keytag} which does ' | ||
| 1167 | . 'not match any DNSKEY record. Fetched from the nameservers with IP ' | ||
| 1168 | . 'addresses "{ns_ip_list}".', | ||
| 1169 | @_; | ||
| 1170 | }, | ||
| 1171 | DS09_RRSIG_NOT_VALID_BY_DNSKEY => sub { | ||
| 1172 | __x # DNSSEC:DS09_RRSIG_NOT_VALID_BY_DNSKEY | ||
| 1173 | 'The SOA RRset is signed with an RRSIG with tag {keytag} which cannot ' | ||
| 1174 | . 'be validated by the matching DNSKEY. Fetched from the nameservers with IP ' | ||
| 1175 | . 'addresses "{ns_ip_list}".', | ||
| 1176 | @_; | ||
| 1177 | }, | ||
| 1178 | DS09_SOA_RRSIG_EXPIRED => sub { | ||
| 1179 | __x # DNSSEC:DS09_SOA_RRSIG_EXPIRED | ||
| 1180 | 'RRSIG with keytag {keytag} and covering type SOA has already expired. ' | ||
| 1181 | . 'Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1182 | @_; | ||
| 1183 | }, | ||
| 1184 | DS09_SOA_RRSIG_NOT_YET_VALID => sub { | ||
| 1185 | __x # DNSSEC:DS09_SOA_RRSIG_NOT_YET_VALID | ||
| 1186 | 'RRSIG with keytag {keytag} and covering type SOA has inception date in ' | ||
| 1187 | . 'the future. Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1188 | @_; | ||
| 1189 | }, | ||
| 1190 | DS10_ALGO_NOT_SUPPORTED_BY_ZM => sub { | ||
| 1191 | __x # DNSSEC:DS10_ALGO_NOT_SUPPORTED_BY_ZM | ||
| 1192 | 'DNSKEY with tag {keytag} uses unsupported algorithm {algo_num} ' | ||
| 1193 | . '({algo_mnemo}) by this installation of Zonemaster. Fetched from ' | ||
| 1194 | . 'name servers "{ns_ip_list}".', | ||
| 1195 | @_; | ||
| 1196 | }, | ||
| 1197 | DS10_ERR_MULT_NSEC => sub { | ||
| 1198 | __x # DNSSEC:DS10_ERR_MULT_NSEC | ||
| 1199 | 'Multiple NSEC records when one is expected. Fetched from name servers "{ns_list}".', | ||
| 1200 | @_; | ||
| 1201 | }, | ||
| 1202 | DS10_ERR_MULT_NSEC3 => sub { | ||
| 1203 | __x # DNSSEC:DS10_ERR_MULT_NSEC3 | ||
| 1204 | 'Multiple NSEC3 records when one is expected. Fetched from name servers "{ns_list}".', | ||
| 1205 | @_; | ||
| 1206 | }, | ||
| 1207 | DS10_EXPECTED_NSEC_NSEC3_MISSING => sub { | ||
| 1208 | __x # DNSSEC:DS10_EXPECTED_NSEC_NSEC3_MISSING | ||
| 1209 | 'The server responded with DNSKEY but not with expected NSEC or NSEC3. ' | ||
| 1210 | . 'Fetched from name servers "{ns_list}".', | ||
| 1211 | @_; | ||
| 1212 | }, | ||
| 1213 | DS10_HAS_NSEC => sub { | ||
| 1214 | __x # DNSSEC:DS10_HAS_NSEC | ||
| 1215 | 'The zone has NSEC records. Fetched from name servers "{ns_list}".', | ||
| 1216 | @_; | ||
| 1217 | }, | ||
| 1218 | DS10_HAS_NSEC3 => sub { | ||
| 1219 | __x # DNSSEC:DS10_HAS_NSEC3 | ||
| 1220 | 'The zone has NSEC3 records. Fetched from name servers "{ns_list}".', | ||
| 1221 | @_; | ||
| 1222 | }, | ||
| 1223 | DS10_INCONSISTENT_NSEC => sub { | ||
| 1224 | __x # DNSSEC:DS10_INCONSISTENT_NSEC | ||
| 1225 | 'Inconsistent responses from zone with NSEC. Fetched from name servers "{ns_list}".', | ||
| 1226 | @_; | ||
| 1227 | }, | ||
| 1228 | DS10_INCONSISTENT_NSEC3 => sub { | ||
| 1229 | __x # DNSSEC:DS10_INCONSISTENT_NSEC3 | ||
| 1230 | 'Inconsistent responses from zone with NSEC3. Fetched from name servers "{ns_list}".', | ||
| 1231 | @_; | ||
| 1232 | }, | ||
| 1233 | DS10_INCONSISTENT_NSEC_NSEC3 => sub { | ||
| 1234 | __x # DNSSEC:DS10_INCONSISTENT_NSEC_NSEC3 | ||
| 1235 | 'The zone is inconsistent on NSEC and NSEC3. NSEC is fetched from name servers ' | ||
| 1236 | . '"{ns_list_nsec}". NSEC3 is fetched from name servers "{ns_list_nsec3}".', | ||
| 1237 | @_; | ||
| 1238 | }, | ||
| 1239 | DS10_MIXED_NSEC_NSEC3 => sub { | ||
| 1240 | __x # DNSSEC:DS10_MIXED_NSEC_NSEC3 | ||
| 1241 | 'The zone responds with both NSEC and NSEC3, where only one of them is expected. ' | ||
| 1242 | . 'Fetched from name servers "{ns_list}".', | ||
| 1243 | @_; | ||
| 1244 | }, | ||
| 1245 | DS10_NSEC3PARAM_GIVES_ERR_ANSWER => sub { | ||
| 1246 | __x # DNSSEC:DS10_NSEC3PARAM_GIVES_ERR_ANSWER | ||
| 1247 | 'Unexpected DNS record in the answer section on an NSEC3PARAM query. Fetched ' | ||
| 1248 | . 'from name servers "{ns_list}".', | ||
| 1249 | @_; | ||
| 1250 | }, | ||
| 1251 | DS10_NSEC3PARAM_MISMATCHES_APEX => sub { | ||
| 1252 | __x # DNSSEC:DS10_NSEC3PARAM_MISMATCHES_APEX | ||
| 1253 | 'The returned NSEC3PARAM record has an unexpected non-apex owner name. ' | ||
| 1254 | . 'Fetched from name servers "{ns_list}".', | ||
| 1255 | @_; | ||
| 1256 | }, | ||
| 1257 | DS10_NSEC3PARAM_QUERY_RESPONSE_ERR => sub { | ||
| 1258 | __x # DNSSEC:DS10_NSEC3PARAM_QUERY_RESPONSE_ERR | ||
| 1259 | 'No response or error in response on query for NSEC3PARAM. Fetched from ' | ||
| 1260 | . 'name servers "{ns_list}".', | ||
| 1261 | @_; | ||
| 1262 | }, | ||
| 1263 | DS10_NSEC3_ERR_TYPE_LIST => sub { | ||
| 1264 | __x # DNSSEC:DS10_NSEC3_ERR_TYPE_LIST | ||
| 1265 | 'NSEC3 record for the zone apex with incorrect type list. Fetched from ' | ||
| 1266 | . 'name servers "{ns_list}".', | ||
| 1267 | @_; | ||
| 1268 | }, | ||
| 1269 | DS10_NSEC3_MISMATCHES_APEX => sub { | ||
| 1270 | __x # DNSSEC:DS10_NSEC3_MISMATCHES_APEX | ||
| 1271 | 'The returned NSEC3 record unexpectedly does not match the zone name. ' | ||
| 1272 | . 'Fetched from name servers "{ns_list}".', | ||
| 1273 | @_; | ||
| 1274 | }, | ||
| 1275 | DS10_NSEC3_MISSING_SIGNATURE => sub { | ||
| 1276 | __x # DNSSEC:DS10_NSEC3_MISSING_SIGNATURE | ||
| 1277 | 'Missing RRSIG (signature) for the NSEC3 record or records. Fetched ' | ||
| 1278 | . 'from name servers "{ns_list}".', | ||
| 1279 | @_; | ||
| 1280 | }, | ||
| 1281 | DS10_NSEC3_NODATA_MISSING_SOA => sub { | ||
| 1282 | __x # DNSSEC:DS10_NSEC3_NODATA_MISSING_SOA | ||
| 1283 | 'Missing SOA record in NODATA response with NSEC3. Fetched from ' | ||
| 1284 | . 'name servers "{ns_list}".', | ||
| 1285 | @_; | ||
| 1286 | }, | ||
| 1287 | DS10_NSEC3_NODATA_WRONG_SOA => sub { | ||
| 1288 | __x # DNSSEC:DS10_NSEC3_NODATA_WRONG_SOA | ||
| 1289 | 'Wrong owner name ("{domain}") on SOA record in NODATA response with NSEC3. ' | ||
| 1290 | . 'Fetched from name servers "{ns_list}".', | ||
| 1291 | @_; | ||
| 1292 | }, | ||
| 1293 | DS10_NSEC3_NO_VERIFIED_SIGNATURE => sub { | ||
| 1294 | __x # DNSSEC:DS10_NSEC3_NO_VERIFIED_SIGNATURE | ||
| 1295 | 'The RRSIG (signature) for the NSEC3 record cannot be verified. ' | ||
| 1296 | . 'Fetched from name servers "{ns_list}".', | ||
| 1297 | @_; | ||
| 1298 | }, | ||
| 1299 | DS10_NSEC3_RRSIG_EXPIRED => sub { | ||
| 1300 | __x # DNSSEC:DS10_NSEC3_RRSIG_EXPIRED | ||
| 1301 | 'The RRSIG (signature) with tag {keytag} for the NSEC3 record has expired. ' | ||
| 1302 | . 'Fetched from name servers "{ns_list}".', | ||
| 1303 | @_; | ||
| 1304 | }, | ||
| 1305 | DS10_NSEC3_RRSIG_NOT_YET_VALID => sub { | ||
| 1306 | __x # DNSSEC:DS10_NSEC3_RRSIG_NOT_YET_VALID | ||
| 1307 | 'The RRSIG (signature) with tag {keytag} for the NSEC3 record it not yet valid. ' | ||
| 1308 | . 'Fetched from name servers "{ns_list}".', | ||
| 1309 | @_; | ||
| 1310 | }, | ||
| 1311 | DS10_NSEC3_RRSIG_NO_DNSKEY => sub { | ||
| 1312 | __x # DNSSEC:DS10_NSEC3_RRSIG_NO_DNSKEY | ||
| 1313 | 'There is no DNSKEY record matching the RRSIG (signature) with tag {keytag} for ' | ||
| 1314 | . 'the NSEC3 record. Fetched from name servers "{ns_list}".', | ||
| 1315 | @_; | ||
| 1316 | }, | ||
| 1317 | DS10_NSEC3_RRSIG_VERIFY_ERROR => sub { | ||
| 1318 | __x # DNSSEC:DS10_NSEC3_RRSIG_VERIFY_ERROR | ||
| 1319 | 'The RRSIG (signature) with tag {keytag} for the NSEC3 record cannot be verified. ' | ||
| 1320 | . 'Fetched from name servers "{ns_list}".', | ||
| 1321 | @_; | ||
| 1322 | }, | ||
| 1323 | DS10_NSEC_ERR_TYPE_LIST => sub { | ||
| 1324 | __x # DNSSEC:DS10_NSEC_ERR_TYPE_LIST | ||
| 1325 | 'NSEC record for the zone apex with incorrect type list. Fetched from name ' | ||
| 1326 | . 'servers "{ns_list}".', | ||
| 1327 | @_; | ||
| 1328 | }, | ||
| 1329 | DS10_NSEC_GIVES_ERR_ANSWER => sub { | ||
| 1330 | __x # DNSSEC:DS10_NSEC_GIVES_ERR_ANSWER | ||
| 1331 | 'Unexpected DNS record in the answer section on an NSEC query. Fetched from ' | ||
| 1332 | . 'name servers "{ns_list}".', | ||
| 1333 | @_; | ||
| 1334 | }, | ||
| 1335 | DS10_NSEC_MISMATCHES_APEX => sub { | ||
| 1336 | __x # DNSSEC:DS10_NSEC_MISMATCHES_APEX | ||
| 1337 | 'The returned NSEC record has an unexpected non-apex owner name. Fetched from ' | ||
| 1338 | . 'name servers "{ns_list}".', | ||
| 1339 | @_; | ||
| 1340 | }, | ||
| 1341 | DS10_NSEC_MISSING_SIGNATURE => sub { | ||
| 1342 | __x # DNSSEC:DS10_NSEC_MISSING_SIGNATURE | ||
| 1343 | 'Missing RRSIG (signature) for the NSEC record or records. Fetched from ' | ||
| 1344 | . 'name servers "{ns_list}".', | ||
| 1345 | @_; | ||
| 1346 | }, | ||
| 1347 | DS10_NSEC_NODATA_MISSING_SOA => sub { | ||
| 1348 | __x # DNSSEC:DS10_NSEC_NODATA_MISSING_SOA | ||
| 1349 | 'Missing SOA record in NODATA response with NSEC. Fetched from name ' | ||
| 1350 | . 'servers "{ns_list}".', | ||
| 1351 | @_; | ||
| 1352 | }, | ||
| 1353 | DS10_NSEC_NODATA_WRONG_SOA => sub { | ||
| 1354 | __x # DNSSEC:DS10_NSEC_NODATA_WRONG_SOA | ||
| 1355 | 'Wrong owner name ("{domain}") on SOA record in NODATA response with NSEC. ' | ||
| 1356 | . 'Fetched from name servers "{ns_list}".', | ||
| 1357 | @_; | ||
| 1358 | }, | ||
| 1359 | DS10_NSEC_NO_VERIFIED_SIGNATURE => sub { | ||
| 1360 | __x # DNSSEC:DS10_NSEC_NO_VERIFIED_SIGNATURE | ||
| 1361 | 'There is no RRSIG (signature) for the NSEC record that can be verified. ' | ||
| 1362 | . 'Fetched from name servers "{ns_list}".', | ||
| 1363 | @_; | ||
| 1364 | }, | ||
| 1365 | DS10_NSEC_QUERY_RESPONSE_ERR => sub { | ||
| 1366 | __x # DNSSEC:DS10_NSEC_QUERY_RESPONSE_ERR | ||
| 1367 | 'No response or error in response on query for NSEC. Fetched from name ' | ||
| 1368 | . 'servers "{ns_list}".', | ||
| 1369 | @_; | ||
| 1370 | }, | ||
| 1371 | DS10_NSEC_RRSIG_EXPIRED => sub { | ||
| 1372 | __x # DNSSEC:DS10_NSEC_RRSIG_EXPIRED | ||
| 1373 | 'The RRSIG (signature) with tag {keytag} for the NSEC record has expired. ' | ||
| 1374 | . 'Fetched from name servers "{ns_list}".', | ||
| 1375 | @_; | ||
| 1376 | }, | ||
| 1377 | DS10_NSEC_RRSIG_NOT_YET_VALID => sub { | ||
| 1378 | __x # DNSSEC:DS10_NSEC_RRSIG_NOT_YET_VALID | ||
| 1379 | 'The RRSIG (signature) with tag {keytag} for the NSEC record it not yet valid. ' | ||
| 1380 | . 'Fetched from name servers "{ns_list}".', | ||
| 1381 | @_; | ||
| 1382 | }, | ||
| 1383 | DS10_NSEC_RRSIG_NO_DNSKEY => sub { | ||
| 1384 | __x # DNSSEC:DS10_NSEC_RRSIG_NO_DNSKEY | ||
| 1385 | 'There is no DNSKEY record matching the RRSIG (signature) with tag {keytag} for ' | ||
| 1386 | . 'the NSEC record. Fetched from name servers "{ns_list}".', | ||
| 1387 | @_; | ||
| 1388 | }, | ||
| 1389 | DS10_NSEC_RRSIG_VERIFY_ERROR => sub { | ||
| 1390 | __x # DNSSEC:DS10_NSEC_RRSIG_VERIFY_ERROR | ||
| 1391 | 'The RRSIG (signature) with tag {keytag} for the NSEC record cannot be verified. ' | ||
| 1392 | . 'Fetched from name servers "{ns_list}".', | ||
| 1393 | @_; | ||
| 1394 | }, | ||
| 1395 | DS10_NONSTANDARD_NSEC_RESPONSE => sub { | ||
| 1396 | __x # DNSSEC:DS10_NONSTANDARD_NSEC_RESPONSE | ||
| 1397 | 'The following name servers give a non-standard response to the NSEC query ' | ||
| 1398 | . '(NSEC RR in authority section instead of answer section). ' | ||
| 1399 | . 'Fetched from name servers "{ns_list}".', | ||
| 1400 | @_; | ||
| 1401 | }, | ||
| 1402 | DS10_SERVER_NO_DNSSEC => sub { | ||
| 1403 | __x # DNSSEC:DS10_SERVER_NO_DNSSEC | ||
| 1404 | 'The following name servers do not support DNSSEC or have not been properly ' | ||
| 1405 | . 'configured. Testing for NSEC and NSEC3 has been skipped on these servers. ' | ||
| 1406 | . 'Fetched from name servers "{ns_list}".', | ||
| 1407 | @_; | ||
| 1408 | }, | ||
| 1409 | DS10_ZONE_NO_DNSSEC => sub { | ||
| 1410 | __x # DNSSEC:DS10_ZONE_NO_DNSSEC | ||
| 1411 | 'The zone is not DNSSEC signed or not properly DNSSEC signed. ' | ||
| 1412 | . 'Testing for NSEC and NSEC3 has been skipped. Fetched from ' | ||
| 1413 | . 'name servers "{ns_list}".', | ||
| 1414 | @_; | ||
| 1415 | }, | ||
| 1416 | DS11_INCONSISTENT_DS => sub { | ||
| 1417 | __x # DNSSEC:DS11_INCONSISTENT_DS | ||
| 1418 | 'Parent name servers are inconsistent on the existence of DS.', | ||
| 1419 | @_; | ||
| 1420 | }, | ||
| 1421 | DS11_INCONSISTENT_SIGNED_ZONE => sub { | ||
| 1422 | __x # DNSSEC:DS11_INCONSISTENT_SIGNED_ZONE | ||
| 1423 | 'Name servers for the child zone are inconsistent on whether the ' | ||
| 1424 | . 'zone is signed or not.', | ||
| 1425 | @_; | ||
| 1426 | }, | ||
| 1427 | DS11_UNDETERMINED_DS => sub { | ||
| 1428 | __x # DNSSEC:DS11_UNDETERMINED_DS | ||
| 1429 | 'It cannot be determined if the parent zone has DS for the child ' | ||
| 1430 | . 'zone or not.', | ||
| 1431 | @_; | ||
| 1432 | }, | ||
| 1433 | DS11_UNDETERMINED_SIGNED_ZONE => sub { | ||
| 1434 | __x # DNSSEC:DS11_UNDETERMINED_SIGNED_ZONE | ||
| 1435 | 'It cannot be determined if the child zone is signed or not.', | ||
| 1436 | @_; | ||
| 1437 | }, | ||
| 1438 | DS11_PARENT_WITHOUT_DS => sub { | ||
| 1439 | __x # DNSSEC:DS11_PARENT_WITHOUT_DS | ||
| 1440 | 'No DS record for the child zone found on parent nameservers with IP ' | ||
| 1441 | . 'addresses "{ns_ip_list}".', | ||
| 1442 | @_; | ||
| 1443 | }, | ||
| 1444 | DS11_PARENT_WITH_DS => sub { | ||
| 1445 | __x # DNSSEC:DS11_PARENT_WITH_DS | ||
| 1446 | 'DS record for the child zone found on parent nameservers with IP addresses ' | ||
| 1447 | . '"{ns_ip_list}".', | ||
| 1448 | @_; | ||
| 1449 | }, | ||
| 1450 | DS11_NS_WITH_SIGNED_ZONE => sub { | ||
| 1451 | __x # DNSSEC:DS11_NS_WITH_SIGNED_ZONE | ||
| 1452 | 'Signed child zone found on nameservers with IP addresses ' | ||
| 1453 | . '"{ns_ip_list}".', | ||
| 1454 | @_; | ||
| 1455 | }, | ||
| 1456 | DS11_NS_WITH_UNSIGNED_ZONE => sub { | ||
| 1457 | __x # DNSSEC:DS11_NS_WITH_UNSIGNED_ZONE | ||
| 1458 | 'Unsigned child zone found on nameservers with IP addresses ' | ||
| 1459 | . '"{ns_ip_list}".', | ||
| 1460 | @_; | ||
| 1461 | }, | ||
| 1462 | DS11_DS_BUT_UNSIGNED_ZONE => sub { | ||
| 1463 | __x # DNSSEC:DS11_DS_BUT_UNSIGNED_ZONE | ||
| 1464 | 'The child zone is unsigned, but the parent zone has DS record.', | ||
| 1465 | @_; | ||
| 1466 | }, | ||
| 1467 | DS13_ALGO_NOT_SIGNED_DNSKEY => sub { | ||
| 1468 | __x # DNSSEC:DS13_ALGO_NOT_SIGNED_DNSKEY | ||
| 1469 | 'The DNSKEY RRset is not signed by algorithm {algo_num} ({algo_mnemo}) ' | ||
| 1470 | . 'present in the DNSKEY RRset. Fetched from the nameservers with IP ' | ||
| 1471 | . 'addresses "{ns_ip_list}".', | ||
| 1472 | @_; | ||
| 1473 | }, | ||
| 1474 | DS13_ALGO_NOT_SIGNED_NS => sub { | ||
| 1475 | __x # DNSSEC:DS13_ALGO_NOT_SIGNED_NS | ||
| 1476 | 'The NS RRset is not signed by algorithm {algo_num} ({algo_mnemo}) ' | ||
| 1477 | . 'present in the DNSKEY RRset. Fetched from the nameservers with IP ' | ||
| 1478 | . 'addresses "{ns_ip_list}".', | ||
| 1479 | @_; | ||
| 1480 | }, | ||
| 1481 | DS13_ALGO_NOT_SIGNED_SOA => sub { | ||
| 1482 | __x # DNSSEC:DS13_ALGO_NOT_SIGNED_SOA | ||
| 1483 | 'The SOA RRset is not signed by algorithm {algo_num} ({algo_mnemo}) ' | ||
| 1484 | . 'present in the DNSKEY RRset. Fetched from the nameservers with IP ' | ||
| 1485 | . 'addresses "{ns_ip_list}".', | ||
| 1486 | @_; | ||
| 1487 | }, | ||
| 1488 | DS15_HAS_CDNSKEY_NO_CDS => sub { | ||
| 1489 | __x # DNSSEC:DS15_HAS_CDNSKEY_NO_CDS | ||
| 1490 | 'CDNSKEY RRset is found on nameservers that resolve to IP addresses ' | ||
| 1491 | . '({ns_ip_list}), but no CDS RRset.', | ||
| 1492 | @_; | ||
| 1493 | }, | ||
| 1494 | DS15_HAS_CDS_AND_CDNSKEY => sub { | ||
| 1495 | __x # DNSSEC:DS15_HAS_CDS_AND_CDNSKEY | ||
| 1496 | 'CDNSKEY and CDS RRsets are found on nameservers that resolve to IP addresses ' | ||
| 1497 | . '({ns_ip_list}).', | ||
| 1498 | @_; | ||
| 1499 | }, | ||
| 1500 | DS15_HAS_CDS_NO_CDNSKEY => sub { | ||
| 1501 | __x # DNSSEC:DS15_HAS_CDS_NO_CDNSKEY | ||
| 1502 | 'CDS RRset is found on nameservers that resolve to IP addresses ' | ||
| 1503 | . '({ns_ip_list}), but no CDNSKEY RRset.', | ||
| 1504 | @_; | ||
| 1505 | }, | ||
| 1506 | DS15_INCONSISTENT_CDNSKEY => sub { | ||
| 1507 | __x # DNSSEC:DS15_INCONSISTENT_CDNSKEY | ||
| 1508 | 'All servers do not have the same CDNSKEY RRset.', @_; | ||
| 1509 | }, | ||
| 1510 | DS15_INCONSISTENT_CDS => sub { | ||
| 1511 | __x # DNSSEC:DS15_INCONSISTENT_CDS | ||
| 1512 | 'All servers do not have the same CDS RRset.', @_; | ||
| 1513 | }, | ||
| 1514 | DS15_MISMATCH_CDS_CDNSKEY => sub { | ||
| 1515 | __x # DNSSEC:DS15_MISMATCH_CDS_CDNSKEY | ||
| 1516 | 'Both CDS and CDNSKEY RRsets are found on nameservers that resolve to IP ' | ||
| 1517 | . 'addresses ({ns_ip_list}) but they do not match.', | ||
| 1518 | @_; | ||
| 1519 | }, | ||
| 1520 | DS15_NO_CDS_CDNSKEY => sub { | ||
| 1521 | __x # DNSSEC:DS15_NO_CDS_CDNSKEY | ||
| 1522 | 'No CDS or CDNSKEY RRsets are found on any name server.', @_; | ||
| 1523 | }, | ||
| 1524 | DS16_CDS_INVALID_RRSIG => sub { | ||
| 1525 | __x # DNSSEC:DS16_CDS_INVALID_RRSIG | ||
| 1526 | 'The CDS RRset is signed with an RRSIG with tag {keytag}, but the RRSIG does ' | ||
| 1527 | . 'not match the DNSKEY with the same key tag. Fetched from the nameservers ' | ||
| 1528 | . 'with IP addresses "{ns_ip_list}".', | ||
| 1529 | @_; | ||
| 1530 | }, | ||
| 1531 | DS16_CDS_MATCHES_NON_SEP_DNSKEY => sub { | ||
| 1532 | __x # DNSSEC:DS16_CDS_MATCHES_NON_SEP_DNSKEY | ||
| 1533 | 'The CDS record with tag {keytag} matches a DNSKEY record with SEP bit (bit 15) ' | ||
| 1534 | . 'unset. Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1535 | @_; | ||
| 1536 | }, | ||
| 1537 | DS16_CDS_MATCHES_NON_ZONE_DNSKEY => sub { | ||
| 1538 | __x # DNSSEC:DS16_CDS_MATCHES_NON_ZONE_DNSKEY | ||
| 1539 | 'The CDS record with tag {keytag} matches a DNSKEY record with zone bit (bit 7) ' | ||
| 1540 | . 'unset. Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1541 | @_; | ||
| 1542 | }, | ||
| 1543 | DS16_CDS_MATCHES_NO_DNSKEY => sub { | ||
| 1544 | __x # DNSSEC:DS16_CDS_MATCHES_NO_DNSKEY | ||
| 1545 | 'The CDS record with tag {keytag} does not match any DNSKEY record. Fetched ' | ||
| 1546 | . 'from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1547 | @_; | ||
| 1548 | }, | ||
| 1549 | DS16_CDS_NOT_SIGNED_BY_CDS => sub { | ||
| 1550 | __x # DNSSEC:DS16_CDS_NOT_SIGNED_BY_CDS | ||
| 1551 | 'The CDS RRset is not signed by the DNSKEY that the CDS record with tag ' | ||
| 1552 | . '{keytag} points to. Fetched from the nameservers with IP addresses ' | ||
| 1553 | . '"{ns_ip_list}".', | ||
| 1554 | @_; | ||
| 1555 | }, | ||
| 1556 | DS16_CDS_SIGNED_BY_UNKNOWN_DNSKEY => sub { | ||
| 1557 | __x # DNSSEC:DS16_CDS_SIGNED_BY_UNKNOWN_DNSKEY | ||
| 1558 | 'The CDS RRset is signed by RRSIG with tag {keytag} but that is not in the ' | ||
| 1559 | . 'DNSKEY RRset. Fetched from the nameservers with P addresses "{ns_ip_list}".', | ||
| 1560 | @_; | ||
| 1561 | }, | ||
| 1562 | DS16_CDS_UNSIGNED => sub { | ||
| 1563 | __x # DNSSEC:DS16_CDS_UNSIGNED | ||
| 1564 | 'The CDS RRset is not signed. Fetched from the nameservers with IP addresses ' | ||
| 1565 | . '"{ns_ip_list}".', | ||
| 1566 | @_; | ||
| 1567 | }, | ||
| 1568 | DS16_CDS_WITHOUT_DNSKEY => sub { | ||
| 1569 | __x # DNSSEC:DS16_CDS_WITHOUT_DNSKEY | ||
| 1570 | 'A CDS RRset exists, but no DNSKEY record exists. Fetched from the ' | ||
| 1571 | . 'nameservers with IP addresses "{ns_ip_list}".', | ||
| 1572 | @_; | ||
| 1573 | }, | ||
| 1574 | DS16_DELETE_CDS => sub { | ||
| 1575 | __x # DNSSEC:DS16_DELETE_CDS | ||
| 1576 | 'A single "delete" CDS record is found on the nameservers with IP addresses ' | ||
| 1577 | . '"{ns_ip_list}".', | ||
| 1578 | @_; | ||
| 1579 | }, | ||
| 1580 | DS16_DNSKEY_NOT_SIGNED_BY_CDS => sub { | ||
| 1581 | __x # DNSSEC:DS16_DNSKEY_NOT_SIGNED_BY_CDS | ||
| 1582 | 'The DNSKEY RRset is not signed by the DNSKEY that the CDS record with tag ' | ||
| 1583 | . '{keytag} points to. Fetched from the nameservers with IP addresses ' | ||
| 1584 | . '"{ns_ip_list}".', | ||
| 1585 | @_; | ||
| 1586 | }, | ||
| 1587 | DS16_MIXED_DELETE_CDS => sub { | ||
| 1588 | __x # DNSSEC:DS16_MIXED_DELETE_CDS | ||
| 1589 | 'The CDS RRset is a mixture between "delete" record and other records. ' | ||
| 1590 | . 'Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1591 | @_; | ||
| 1592 | }, | ||
| 1593 | DS17_CDNSKEY_INVALID_RRSIG => sub { | ||
| 1594 | __x # DNSSEC:DS17_CDNSKEY_INVALID_RRSIG | ||
| 1595 | 'The CDNSKEY RRset is signed with an RRSIG with tag {keytag}, but the RRSIG does ' | ||
| 1596 | . 'not match the DNSKEY with the same key tag. Fetched from the nameservers ' | ||
| 1597 | . 'with IP addresses "{ns_ip_list}".', | ||
| 1598 | @_; | ||
| 1599 | }, | ||
| 1600 | DS17_CDNSKEY_IS_NON_SEP => sub { | ||
| 1601 | __x # DNSSEC:DS17_CDNSKEY_IS_NON_SEP | ||
| 1602 | 'The CDNSKEY record with tag {keytag} has the SEP bit (bit 15) unset. Fetched ' | ||
| 1603 | . 'from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1604 | @_; | ||
| 1605 | }, | ||
| 1606 | DS17_CDNSKEY_IS_NON_ZONE => sub { | ||
| 1607 | __x # DNSSEC:DS17_CDNSKEY_IS_NON_ZONE | ||
| 1608 | 'The CDNSKEY record with tag {keytag} has the zone bit (bit 7) unset. Fetched ' | ||
| 1609 | . 'from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1610 | @_; | ||
| 1611 | }, | ||
| 1612 | DS17_CDNSKEY_MATCHES_NO_DNSKEY => sub { | ||
| 1613 | __x # DNSSEC:DS17_CDNSKEY_MATCHES_NO_DNSKEY | ||
| 1614 | 'The CDNSKEY record with tag {keytag} does not match any DNSKEY record. Fetched ' | ||
| 1615 | . 'from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1616 | @_; | ||
| 1617 | }, | ||
| 1618 | DS17_CDNSKEY_NOT_SIGNED_BY_CDNSKEY => sub { | ||
| 1619 | __x # DNSSEC:DS17_CDNSKEY_NOT_SIGNED_BY_CDNSKEY | ||
| 1620 | 'The CDNSKEY RRset is not signed by the DNSKEY that the CDNSKEY record with tag ' | ||
| 1621 | . '{keytag} points to. Fetched from the nameservers with IP addresses ' | ||
| 1622 | . '"{ns_ip_list}".', | ||
| 1623 | @_; | ||
| 1624 | }, | ||
| 1625 | DS17_CDNSKEY_SIGNED_BY_UNKNOWN_DNSKEY => sub { | ||
| 1626 | __x # DNSSEC:DS17_CDNSKEY_SIGNED_BY_UNKNOWN_DNSKEY | ||
| 1627 | 'The CDNSKEY RRset is signed by RRSIG with tag {keytag} but that is not in the ' | ||
| 1628 | . 'DNSKEY RRset. Fetched from the nameservers with P addresses "{ns_ip_list}".', | ||
| 1629 | @_; | ||
| 1630 | }, | ||
| 1631 | DS17_CDNSKEY_UNSIGNED => sub { | ||
| 1632 | __x # DNSSEC:DS17_CDNSKEY_UNSIGNED | ||
| 1633 | 'The CDNSKEY RRset is not signed. Fetched from the nameservers with IP addresses ' | ||
| 1634 | . '"{ns_ip_list}".', | ||
| 1635 | @_; | ||
| 1636 | }, | ||
| 1637 | DS17_CDNSKEY_WITHOUT_DNSKEY => sub { | ||
| 1638 | __x # DNSSEC:DS17_CDNSKEY_WITHOUT_DNSKEY | ||
| 1639 | 'A CDNSKEY RRset exists, but no DNSKEY record exists. Fetched from the ' | ||
| 1640 | . 'nameservers with IP addresses "{ns_ip_list}".', | ||
| 1641 | @_; | ||
| 1642 | }, | ||
| 1643 | DS17_DELETE_CDNSKEY => sub { | ||
| 1644 | __x # DNSSEC:DS17_DELETE_CDNSKEY | ||
| 1645 | 'A single "delete" CDNSKEY record is found on the nameservers with IP addresses ' | ||
| 1646 | . '"{ns_ip_list}".', | ||
| 1647 | @_; | ||
| 1648 | }, | ||
| 1649 | DS17_DNSKEY_NOT_SIGNED_BY_CDNSKEY => sub { | ||
| 1650 | __x # DNSSEC:DS17_DNSKEY_NOT_SIGNED_BY_CDNSKEY | ||
| 1651 | 'The DNSKEY RRset is not signed by the DNSKEY that the CDNSKEY record with tag ' | ||
| 1652 | . '{keytag} points to. Fetched from the nameservers with IP addresses ' | ||
| 1653 | . '"{ns_ip_list}".', | ||
| 1654 | @_; | ||
| 1655 | }, | ||
| 1656 | DS17_MIXED_DELETE_CDNSKEY => sub { | ||
| 1657 | __x # DNSSEC:DS17_MIXED_DELETE_CDNSKEY | ||
| 1658 | 'The CDNSKEY RRset is a mixture between "delete" record and other records. ' | ||
| 1659 | . 'Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1660 | @_; | ||
| 1661 | }, | ||
| 1662 | DS18_NO_MATCH_CDS_RRSIG_DS => sub { | ||
| 1663 | __x # DNSSEC:DS18_NO_MATCH_CDS_RRSIG_DS | ||
| 1664 | 'The CDS RRset is not signed with a DNSKEY record that a DS record points to. ' | ||
| 1665 | . 'Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1666 | @_; | ||
| 1667 | }, | ||
| 1668 | DS18_NO_MATCH_CDNSKEY_RRSIG_DS => sub { | ||
| 1669 | __x # DNSSEC:DS18_NO_MATCH_CDNSKEY_RRSIG_DS | ||
| 1670 | 'The CDNSKEY RRset is not signed with a DNSKEY record that a DS record points to. ' | ||
| 1671 | . 'Fetched from the nameservers with IP addresses "{ns_ip_list}".', | ||
| 1672 | @_; | ||
| 1673 | }, | ||
| 1674 | DURATION_LONG => sub { | ||
| 1675 | __x # DNSSEC:DURATION_LONG | ||
| 1676 | 'RRSIG with keytag {keytag} and covering type(s) {types} ' | ||
| 1677 | . 'has a duration of {duration} seconds, which is too long.', | ||
| 1678 | @_; | ||
| 1679 | }, | ||
| 1680 | DURATION_OK => sub { | ||
| 1681 | __x # DNSSEC:DURATION_OK | ||
| 1682 | 'RRSIG with keytag {keytag} and covering type(s) {types} ' | ||
| 1683 | . 'has a duration of {duration} seconds, which is just fine.', | ||
| 1684 | @_; | ||
| 1685 | }, | ||
| 1686 | EXTRA_PROCESSING_BROKEN => sub { | ||
| 1687 | __x # DNSSEC:EXTRA_PROCESSING_BROKEN | ||
| 1688 | 'Server at {server} sent {keys} DNSKEY records, and {sigs} RRSIG records.', @_; | ||
| 1689 | }, | ||
| 1690 | EXTRA_PROCESSING_OK => sub { | ||
| 1691 | __x # DNSSEC:EXTRA_PROCESSING_OK | ||
| 1692 | 'Server at {server} sent {keys} DNSKEY records and {sigs} RRSIG records.', @_; | ||
| 1693 | }, | ||
| 1694 | IPV4_DISABLED => sub { | ||
| 1695 | __x # DNSSEC:IPV4_DISABLED | ||
| 1696 | 'IPv4 is disabled, not sending "{rrtype}" query to {ns}.', @_; | ||
| 1697 | }, | ||
| 1698 | IPV6_DISABLED => sub { | ||
| 1699 | __x # DNSSEC:IPV6_DISABLED | ||
| 1700 | 'IPv6 is disabled, not sending "{rrtype}" query to {ns}.', @_; | ||
| 1701 | }, | ||
| 1702 | KEY_SIZE_OK => sub { | ||
| 1703 | __x # DNSSEC:KEY_SIZE_OK | ||
| 1704 | 'All keys from the DNSKEY RRset have the correct size.', @_; | ||
| 1705 | }, | ||
| 1706 | NO_RESPONSE_DNSKEY => sub { | ||
| 1707 | __x # DNSSEC:NO_RESPONSE_DNSKEY | ||
| 1708 | 'Nameserver {ns} responded with no DNSKEY record(s).', @_; | ||
| 1709 | }, | ||
| 1710 | NO_RESPONSE => sub { | ||
| 1711 | __x # DNSSEC:NO_RESPONSE | ||
| 1712 | 'Nameserver {ns} did not respond.', @_; | ||
| 1713 | }, | ||
| 1714 | REMAINING_LONG => sub { | ||
| 1715 | __x # DNSSEC:REMAINING_LONG | ||
| 1716 | 'RRSIG with keytag {keytag} and covering type(s) {types} ' | ||
| 1717 | . 'has a remaining validity of {duration} seconds, which is too long.', | ||
| 1718 | @_; | ||
| 1719 | }, | ||
| 1720 | REMAINING_SHORT => sub { | ||
| 1721 | __x # DNSSEC:REMAINING_SHORT | ||
| 1722 | 'RRSIG with keytag {keytag} and covering type(s) {types} ' | ||
| 1723 | . 'has a remaining validity of {duration} seconds, which is too short.', | ||
| 1724 | @_; | ||
| 1725 | }, | ||
| 1726 | RRSIG_EXPIRATION => sub { | ||
| 1727 | __x # DNSSEC:RRSIG_EXPIRATION | ||
| 1728 | 'RRSIG with keytag {keytag} and covering type(s) {types} expires at ' . ': {date}.', @_; | ||
| 1729 | }, | ||
| 1730 | RRSIG_EXPIRED => sub { | ||
| 1731 | __x # DNSSEC:RRSIG_EXPIRED | ||
| 1732 | 'RRSIG with keytag {keytag} and covering type(s) {types} has already ' | ||
| 1733 | . 'expired (expiration is: {expiration}).', | ||
| 1734 | @_; | ||
| 1735 | }, | ||
| 1736 | TEST_CASE_END => sub { | ||
| 1737 | __x # DNSSEC:TEST_CASE_END | ||
| 1738 | 'TEST_CASE_END {testcase}.', @_; | ||
| 1739 | }, | ||
| 1740 | TEST_CASE_START => sub { | ||
| 1741 | __x # DNSSEC:TEST_CASE_START | ||
| 1742 | 'TEST_CASE_START {testcase}.', @_; | ||
| 1743 | } | ||
| 1744 | ); | ||
| 1745 | |||
| 1746 | =over | ||
| 1747 | |||
| 1748 | =item tag_descriptions() | ||
| 1749 | |||
| 1750 | my $hash_ref = tag_descriptions(); | ||
| 1751 | |||
| 1752 | Used by the L<built-in translation system|Zonemaster::Engine::Translator>. | ||
| 1753 | |||
| 1754 | Returns a reference to a hash, the keys of which are the message tags and the corresponding values are strings (message IDs). | ||
| 1755 | |||
| 1756 | =back | ||
| 1757 | |||
| 1758 | =cut | ||
| 1759 | |||
| 1760 | sub tag_descriptions { | ||
| 1761 | return \%TAG_DESCRIPTIONS; | ||
| 1762 | } | ||
| 1763 | |||
| 1764 | =over | ||
| 1765 | |||
| 1766 | =item version() | ||
| 1767 | |||
| 1768 | my $version_string = version(); | ||
| 1769 | |||
| 1770 | Returns a string containing the version of the current module. | ||
| 1771 | |||
| 1772 | =back | ||
| 1773 | |||
| 1774 | =cut | ||
| 1775 | |||
| 1776 | sub version { | ||
| 1777 | return "$Zonemaster::Engine::Test::DNSSEC::VERSION"; | ||
| 1778 | } | ||
| 1779 | |||
| 1780 | =head1 INTERNAL METHODS | ||
| 1781 | |||
| 1782 | =over | ||
| 1783 | |||
| 1784 | =item _emit_log() | ||
| 1785 | |||
| 1786 | my $log_entry = _emit_log( $message_tag_string, $hash_ref ); | ||
| 1787 | |||
| 1788 | Adds a message to the L<logger|Zonemaster::Engine::Logger> for this module. | ||
| 1789 | See L<Zonemaster::Engine::Logger::Entry/add($tag, $argref, $module, $testcase)> for more details. | ||
| 1790 | |||
| 1791 | Takes a string (message tag) and a reference to a hash (arguments). | ||
| 1792 | |||
| 1793 | Returns a L<Zonemaster::Engine::Logger::Entry> object. | ||
| 1794 | |||
| 1795 | =back | ||
| 1796 | |||
| 1797 | =cut | ||
| 1798 | |||
| 1799 | sub _emit_log { my ( $tag, $argref ) = @_; return Zonemaster::Engine->logger->add( $tag, $argref, 'DNSSEC' ); } | ||
| 1800 | |||
| 1801 | =over | ||
| 1802 | |||
| 1803 | =item _ip_disabled_message() | ||
| 1804 | |||
| 1805 | my $bool = _ip_disabled_message( $logentry_array_ref, $ns, @query_type_array ); | ||
| 1806 | |||
| 1807 | Checks if the IP version of a given name server is allowed to be queried. If not, it adds a logging message and returns true. Else, it returns false. | ||
| 1808 | |||
| 1809 | Takes a reference to an array of L<Zonemaster::Engine::Logger::Entry> objects, a L<Zonemaster::Engine::Nameserver> object and an array of strings (query type). | ||
| 1810 | |||
| 1811 | Returns a boolean. | ||
| 1812 | |||
| 1813 | =back | ||
| 1814 | |||
| 1815 | =cut | ||
| 1816 | |||
| 1817 | sub _ip_disabled_message { | ||
| 1818 | my ( $results_array, $ns, @rrtypes ) = @_; | ||
| 1819 | |||
| 1820 | if ( not Zonemaster::Engine::Profile->effective->get(q{net.ipv6}) and $ns->address->version == $IP_VERSION_6 ) { | ||
| 1821 | push @$results_array, map { | ||
| 1822 | _emit_log( | ||
| 1823 | IPV6_DISABLED => { | ||
| 1824 | ns => $ns->string, | ||
| 1825 | rrtype => $_ | ||
| 1826 | } | ||
| 1827 | ) | ||
| 1828 | } @rrtypes; | ||
| 1829 | return 1; | ||
| 1830 | } | ||
| 1831 | |||
| 1832 | if ( not Zonemaster::Engine::Profile->effective->get(q{net.ipv4}) and $ns->address->version == $IP_VERSION_4 ) { | ||
| 1833 | push @$results_array, map { | ||
| 1834 | _emit_log( | ||
| 1835 | IPV4_DISABLED => { | ||
| 1836 | ns => $ns->string, | ||
| 1837 | rrtype => $_, | ||
| 1838 | } | ||
| 1839 | ) | ||
| 1840 | } @rrtypes; | ||
| 1841 | return 1; | ||
| 1842 | } | ||
| 1843 | return 0; | ||
| 1844 | } | ||
| 1845 | |||
| 1846 | =head1 TESTS | ||
| 1847 | |||
| 1848 | =over | ||
| 1849 | |||
| 1850 | =item dnssec01() | ||
| 1851 | |||
| 1852 | my @logentry_array = dnssec01( $zone ); | ||
| 1853 | |||
| 1854 | Runs the L<DNSSEC01 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec01.md>. | ||
| 1855 | |||
| 1856 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 1857 | |||
| 1858 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 1859 | |||
| 1860 | =back | ||
| 1861 | |||
| 1862 | =cut | ||
| 1863 | |||
| 1864 | sub dnssec01 { | ||
| 1865 | my ( $class, $zone ) = @_; | ||
| 1866 | |||
| 1867 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC01'; | ||
| 1868 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 1869 | |||
| 1870 | my @ignored_parent_ns_ip; | ||
| 1871 | my ( @responds_without_valid_ds, @responds_with_ds ); | ||
| 1872 | my ( %algo_2_ds, %non_algo_2_ds ); | ||
| 1873 | my %sets = ( | ||
| 1874 | 'DS01_DS_ALGO_DEPRECATED' => {}, | ||
| 1875 | 'DS01_DS_ALGO_RESERVED' => {}, | ||
| 1876 | 'DS01_DS_ALGO_UNASSIGNED' => {}, | ||
| 1877 | 'DS01_DS_ALGO_PRIVATE' => {}, | ||
| 1878 | 'DS01_DS_ALGO_NOT_DS' => {}, | ||
| 1879 | 'DS01_DS_ALGO_OK' => {} | ||
| 1880 | ); | ||
| 1881 | |||
| 1882 | my $parent_nss = Zonemaster::Engine::TestMethodsV2->get_parent_ns_names_and_ips( $zone ); | ||
| 1883 | |||
| 1884 | my @undelegated_ds; | ||
| 1885 | if ( my $parent = $zone->parent ) { | ||
| 1886 | foreach my $ns ( @{ $parent->ns } ) { | ||
| 1887 | if ( $ns->fake_ds->{$zone->name} ) { | ||
| 1888 | @undelegated_ds = @{ $ns->fake_ds->{$zone->name} }; | ||
| 1889 | |||
| 1890 | if ( @undelegated_ds ) { | ||
| 1891 | my $ns_ip = "-"; | ||
| 1892 | |||
| 1893 | foreach my $ds_data ( @undelegated_ds ) { | ||
| 1894 | my $digest = $ds_data->digtype; | ||
| 1895 | my $keytag = $ds_data->keytag; | ||
| 1896 | |||
| 1897 | push @{ $sets{$dnssec01_tags_mapping{$digest}}->{$digest}{$keytag} }, $ns_ip; | ||
| 1898 | |||
| 1899 | if ( $digest == 2 ) { | ||
| 1900 | push @{ $algo_2_ds{$keytag} }, $ns_ip; | ||
| 1901 | } | ||
| 1902 | else { | ||
| 1903 | push @{ $non_algo_2_ds{$keytag} }, $ns_ip; | ||
| 1904 | } | ||
| 1905 | } | ||
| 1906 | |||
| 1907 | push @responds_with_ds, $ns_ip; | ||
| 1908 | $parent_nss = undef; | ||
| 1909 | } | ||
| 1910 | } | ||
| 1911 | } | ||
| 1912 | } | ||
| 1913 | |||
| 1914 | my @nss = @{ $parent_nss // [] }; | ||
| 1915 | |||
| 1916 | my %ip_already_processed; | ||
| 1917 | foreach my $ns ( @nss ) { | ||
| 1918 | my $ns_ip = $ns->address->short; | ||
| 1919 | |||
| 1920 | next if exists $ip_already_processed{$ns_ip}; | ||
| 1921 | $ip_already_processed{$ns_ip} = [ grep { $_->address->short eq $ns_ip } @nss ]; | ||
| 1922 | |||
| 1923 | if ( _ip_disabled_message( \@results, $ns, q{DS} ) ) { | ||
| 1924 | next; | ||
| 1925 | } | ||
| 1926 | |||
| 1927 | my @matching_nss = @{ $ip_already_processed{$ns_ip} }; | ||
| 1928 | |||
| 1929 | my $p = $ns->query( $zone->name, q{DS}, { dnssec => 1 } ); | ||
| 1930 | |||
| 1931 | if ( not $p or $p->rcode ne q{NOERROR} or not $p->has_edns or not $p->do or not $p->aa ) { | ||
| 1932 | push @ignored_parent_ns_ip, @matching_nss; | ||
| 1933 | next; | ||
| 1934 | } | ||
| 1935 | |||
| 1936 | my @rrs = $p->get_records( q{DS}, q{answer} ); | ||
| 1937 | |||
| 1938 | my $valid_ds_rr = 0; | ||
| 1939 | foreach my $ds_rr ( @rrs ) { | ||
| 1940 | if ( $ds_rr->owner eq $zone->name->fqdn ){ | ||
| 1941 | $valid_ds_rr = 1; | ||
| 1942 | last; | ||
| 1943 | } | ||
| 1944 | } | ||
| 1945 | |||
| 1946 | if ( not $valid_ds_rr ){ | ||
| 1947 | push @responds_without_valid_ds, @matching_nss; | ||
| 1948 | next; | ||
| 1949 | } | ||
| 1950 | |||
| 1951 | push @responds_with_ds, @matching_nss; | ||
| 1952 | |||
| 1953 | foreach my $ds_rr ( @rrs ) { | ||
| 1954 | my $digest = $ds_rr->digtype; | ||
| 1955 | my $keytag = $ds_rr->keytag; | ||
| 1956 | |||
| 1957 | push @{ $sets{$dnssec01_tags_mapping{$digest}}->{$digest}{$keytag} }, @matching_nss; | ||
| 1958 | |||
| 1959 | if ( $digest == 2 ) { | ||
| 1960 | push @{ $algo_2_ds{$keytag} }, @matching_nss; | ||
| 1961 | } | ||
| 1962 | else { | ||
| 1963 | push @{ $non_algo_2_ds{$keytag} }, @matching_nss; | ||
| 1964 | } | ||
| 1965 | } | ||
| 1966 | } | ||
| 1967 | |||
| 1968 | while ( my ($tag_name, $set_ref) = each %sets ) { | ||
| 1969 | my %values = %{ $set_ref }; | ||
| 1970 | if ( %values ) { | ||
| 1971 | foreach my $digest ( keys %values ) { | ||
| 1972 | foreach my $keytag ( keys %{ $values{$digest} } ) { | ||
| 1973 | push @results, | ||
| 1974 | _emit_log( | ||
| 1975 | $tag_name => { | ||
| 1976 | ns_list => join( q{;}, uniq sort @{ $values{$digest}{$keytag} } ), | ||
| 1977 | keytag => $keytag, | ||
| 1978 | ds_algo_num => $digest, | ||
| 1979 | ds_algo_descr => $digest_algorithms{$digest} | ||
| 1980 | } | ||
| 1981 | ); | ||
| 1982 | } | ||
| 1983 | } | ||
| 1984 | } | ||
| 1985 | } | ||
| 1986 | |||
| 1987 | if ( %non_algo_2_ds ) { | ||
| 1988 | while ( my ($keytag, $ns_ips) = each %non_algo_2_ds ) { | ||
| 1989 | my $lc = List::Compare->new( $ns_ips, $algo_2_ds{$keytag} ); | ||
| 1990 | my @unique_nss = $lc->get_unique; | ||
| 1991 | |||
| 1992 | if ( @unique_nss ) { | ||
| 1993 | push @results, | ||
| 1994 | _emit_log( | ||
| 1995 | DS01_DS_ALGO_2_MISSING => { | ||
| 1996 | ns_list => join( q{;}, uniq sort @unique_nss ), | ||
| 1997 | keytag => $keytag | ||
| 1998 | } | ||
| 1999 | ); | ||
| 2000 | } | ||
| 2001 | } | ||
| 2002 | } | ||
| 2003 | |||
| 2004 | if ( not @responds_without_valid_ds and not @responds_with_ds and @ignored_parent_ns_ip ) { | ||
| 2005 | push @results, | ||
| 2006 | _emit_log( | ||
| 2007 | DS01_NO_RESPONSE => { | ||
| 2008 | ns_list => join( q{;}, uniq sort @ignored_parent_ns_ip ) | ||
| 2009 | } | ||
| 2010 | ) | ||
| 2011 | } | ||
| 2012 | |||
| 2013 | if ( $zone->name eq '.' and not @undelegated_ds ) { | ||
| 2014 | push @results, | ||
| 2015 | _emit_log( | ||
| 2016 | DS01_ROOT_N_NO_UNDEL_DS => {} | ||
| 2017 | ) | ||
| 2018 | } | ||
| 2019 | |||
| 2020 | if ( $zone->name ne '.' and Zonemaster::Engine::Recursor->has_fake_addresses( $zone->name->string ) and not @undelegated_ds ) { | ||
| 2021 | push @results, | ||
| 2022 | _emit_log( | ||
| 2023 | DS01_UNDEL_N_NO_UNDEL_DS => {} | ||
| 2024 | ) | ||
| 2025 | } | ||
| 2026 | |||
| 2027 | if ( @responds_without_valid_ds ) { | ||
| 2028 | if ( not @responds_with_ds ) { | ||
| 2029 | push @results, | ||
| 2030 | _emit_log( | ||
| 2031 | DS01_PARENT_ZONE_NO_DS => { | ||
| 2032 | ns_list => join( q{;}, uniq sort @responds_without_valid_ds ) | ||
| 2033 | } | ||
| 2034 | ) | ||
| 2035 | } | ||
| 2036 | else { | ||
| 2037 | push @results, | ||
| 2038 | _emit_log( | ||
| 2039 | DS01_PARENT_SERVER_NO_DS => { | ||
| 2040 | ns_list => join( q{;}, uniq sort @responds_without_valid_ds ) | ||
| 2041 | } | ||
| 2042 | ) | ||
| 2043 | } | ||
| 2044 | } | ||
| 2045 | |||
| 2046 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 2047 | } ## end sub dnssec01 | ||
| 2048 | |||
| 2049 | =over | ||
| 2050 | |||
| 2051 | =item dnssec02() | ||
| 2052 | |||
| 2053 | my @logentry_array = dnssec02( $zone ); | ||
| 2054 | |||
| 2055 | Runs the L<DNSSEC02 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec02.md>. | ||
| 2056 | |||
| 2057 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 2058 | |||
| 2059 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 2060 | |||
| 2061 | =back | ||
| 2062 | |||
| 2063 | =cut | ||
| 2064 | |||
| 2065 | sub dnssec02 { | ||
| 2066 | my ( $self, $zone ) = @_; | ||
| 2067 | |||
| 2068 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC02'; | ||
| 2069 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 2070 | |||
| 2071 | my @ds_record; | ||
| 2072 | my %no_dnskey_for_ds; | ||
| 2073 | my %no_match_ds_dnskey; | ||
| 2074 | my %dnskey_not_for_zone_signing; | ||
| 2075 | my %dnskey_not_sep; | ||
| 2076 | my %no_matching_dnskey_rrsig; | ||
| 2077 | my %algo_not_supported_by_zm; | ||
| 2078 | my %rrsig_not_valid_by_dnskey; | ||
| 2079 | my %responding_child_ns; | ||
| 2080 | my %dnskey_matching_ds; | ||
| 2081 | my %has_dnskey_match_ds; | ||
| 2082 | my %has_rrsig_match_ds; | ||
| 2083 | my @ns_dnskey; | ||
| 2084 | my @ns_rrsig; | ||
| 2085 | my $continue_with_child_tests = 1; | ||
| 2086 | |||
| 2087 | my $parent = Zonemaster::Engine::TestMethods->method1( $zone ); | ||
| 2088 | my @nss_parent = @{ $parent->ns }; | ||
| 2089 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_parent; | ||
| 2090 | my %ip_already_processed; | ||
| 2091 | |||
| 2092 | for my $nss_key ( sort keys %nss ) { | ||
| 2093 | my $ns = $nss{$nss_key}; | ||
| 2094 | |||
| 2095 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 2096 | $ip_already_processed{$ns->address->short} = 1; | ||
| 2097 | |||
| 2098 | if ( _ip_disabled_message( \@results, $ns, q{DS} ) ) { | ||
| 2099 | next; | ||
| 2100 | } | ||
| 2101 | |||
| 2102 | my $ds_p = $ns->query( $zone->name, q{DS}, { dnssec => 1 } ); | ||
| 2103 | if ( not $ds_p or $ds_p->rcode ne q{NOERROR} or not $ds_p->has_edns or not $ds_p->do or not $ds_p->aa) { | ||
| 2104 | next; | ||
| 2105 | } | ||
| 2106 | my @tmp_ds_records = $ds_p->get_records_for_name( q{DS}, $zone->name->string, q{answer} ); | ||
| 2107 | if ( not scalar @tmp_ds_records ) { | ||
| 2108 | next; | ||
| 2109 | } | ||
| 2110 | foreach my $tmp_ds_record ( @tmp_ds_records ) { | ||
| 2111 | if ( | ||
| 2112 | not grep { | ||
| 2113 | $tmp_ds_record->keytag == $_->keytag | ||
| 2114 | and $tmp_ds_record->digtype == $_->digtype | ||
| 2115 | and $tmp_ds_record->algorithm == $_->algorithm | ||
| 2116 | and $tmp_ds_record->hexdigest eq $_->hexdigest | ||
| 2117 | } @ds_record | ||
| 2118 | ) | ||
| 2119 | { | ||
| 2120 | push @ds_record, $tmp_ds_record; | ||
| 2121 | } | ||
| 2122 | } | ||
| 2123 | } | ||
| 2124 | undef %ip_already_processed; | ||
| 2125 | |||
| 2126 | if ( not scalar @ds_record ) { | ||
| 2127 | $continue_with_child_tests = 0; | ||
| 2128 | } | ||
| 2129 | |||
| 2130 | if ( $continue_with_child_tests ) { | ||
| 2131 | |||
| 2132 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 2133 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 2134 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 2135 | my %ip_already_processed; | ||
| 2136 | |||
| 2137 | for my $nss_key ( sort keys %nss ) { | ||
| 2138 | my $ns = $nss{$nss_key}; | ||
| 2139 | |||
| 2140 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 2141 | $ip_already_processed{$ns->address->short} = 1; | ||
| 2142 | |||
| 2143 | if ( _ip_disabled_message( \@results, $ns, q{DNSKEY} ) ) { | ||
| 2144 | next; | ||
| 2145 | } | ||
| 2146 | |||
| 2147 | my $dnskey_p = $ns->query( $zone->name, q{DNSKEY}, { dnssec => 1, usevc => 0 } ); | ||
| 2148 | if ( not $dnskey_p or $dnskey_p->rcode ne q{NOERROR} or not $dnskey_p->has_edns or not $dnskey_p->do or not $dnskey_p->aa ) { | ||
| 2149 | next; | ||
| 2150 | } | ||
| 2151 | my @dnskey_rrs = $dnskey_p->get_records_for_name( q{DNSKEY}, $zone->name->string, q{answer} ); | ||
| 2152 | if ( not scalar @dnskey_rrs ) { | ||
| 2153 | next; | ||
| 2154 | } | ||
| 2155 | |||
| 2156 | $responding_child_ns{$ns->address->short} = 1; | ||
| 2157 | |||
| 2158 | my @dnskey_rrsig = $dnskey_p->get_records_for_name( q{RRSIG}, $zone->name->string, q{answer} ); | ||
| 2159 | |||
| 2160 | %dnskey_matching_ds = (); | ||
| 2161 | |||
| 2162 | foreach my $ds ( @ds_record ) { | ||
| 2163 | my $matching_dnskey = undef; | ||
| 2164 | my @matching_keytag_dnskeys = grep { $ds->keytag == $_->keytag } @dnskey_rrs; | ||
| 2165 | my $match_ds_dnskey = 0; | ||
| 2166 | |||
| 2167 | foreach my $matching_keytag_dnskey ( @matching_keytag_dnskeys ) { | ||
| 2168 | if ( exists $LDNS_digest_algorithms_supported{$ds->digtype()} ) { | ||
| 2169 | my $tmp_ds = $matching_keytag_dnskey->ds($LDNS_digest_algorithms_supported{$ds->digtype()}); | ||
| 2170 | |||
| 2171 | if ( not $tmp_ds or ( $tmp_ds->hexdigest() eq $ds->hexdigest() and $matching_keytag_dnskey->algorithm() == $ds->algorithm() ) ) { | ||
| 2172 | $matching_dnskey = $matching_keytag_dnskey; | ||
| 2173 | $match_ds_dnskey = 1; | ||
| 2174 | last; | ||
| 2175 | } | ||
| 2176 | } | ||
| 2177 | else { | ||
| 2178 | $matching_dnskey = $matching_keytag_dnskey; | ||
| 2179 | $match_ds_dnskey = 1; | ||
| 2180 | last; | ||
| 2181 | } | ||
| 2182 | } | ||
| 2183 | |||
| 2184 | if ( scalar @matching_keytag_dnskeys >= 1 and not $match_ds_dnskey) { | ||
| 2185 | $matching_dnskey = shift @matching_keytag_dnskeys; | ||
| 2186 | } | ||
| 2187 | |||
| 2188 | if ( not $matching_dnskey ) { | ||
| 2189 | push @{ $no_dnskey_for_ds{$ds->keytag} }, $ns->address->short; | ||
| 2190 | } | ||
| 2191 | else { | ||
| 2192 | if ( not $match_ds_dnskey ) { | ||
| 2193 | push @{ $no_match_ds_dnskey{$ds->keytag} }, $ns->address->short; | ||
| 2194 | } | ||
| 2195 | if ( not $matching_dnskey->flags & 256 ) { # Bit 7 (ZONE) | ||
| 2196 | push @{ $dnskey_not_for_zone_signing{$ds->keytag} }, $ns->address->short; | ||
| 2197 | next; | ||
| 2198 | } | ||
| 2199 | if ( not $matching_dnskey->flags & 1 ) { # Bit 15 (SEP) | ||
| 2200 | push @{ $dnskey_not_sep{$ds->keytag} }, $ns->address->short; | ||
| 2201 | } | ||
| 2202 | |||
| 2203 | $dnskey_matching_ds{$matching_dnskey} = $matching_dnskey->keytag; | ||
| 2204 | $has_dnskey_match_ds{$ns->address->short} = 1; | ||
| 2205 | |||
| 2206 | foreach my $dnskey ( keys %dnskey_matching_ds ) { | ||
| 2207 | my @matching_keytag_rrsigs = grep { $dnskey_matching_ds{$dnskey} == $_->keytag } @dnskey_rrsig; | ||
| 2208 | my $time = $dnskey_p->timestamp; | ||
| 2209 | my $found_match = 0; | ||
| 2210 | |||
| 2211 | foreach my $rrsig_record ( @matching_keytag_rrsigs ) { | ||
| 2212 | my $msg = q{}; | ||
| 2213 | # Does not work if we have a list with just a DNSKEY | ||
| 2214 | #my @key_list = ( $matching_dnskey ); | ||
| 2215 | #my $validate = $rrsig_record->verify_time( \@key_list, \@key_list, $time, $msg ); | ||
| 2216 | my $validate = $rrsig_record->verify_time( \@dnskey_rrs, \@dnskey_rrs, $time, $msg ); | ||
| 2217 | if ( not $validate and $msg =~ /Unknown cryptographic algorithm/ ) { | ||
| 2218 | push @{ $algo_not_supported_by_zm{$rrsig_record->keytag}{$rrsig_record->algorithm} }, $ns->address->short; | ||
| 2219 | } | ||
| 2220 | elsif ( not $validate ) { | ||
| 2221 | push @{ $rrsig_not_valid_by_dnskey{$rrsig_record->keytag} }, $ns->address->short; | ||
| 2222 | } | ||
| 2223 | else { | ||
| 2224 | $found_match++; | ||
| 2225 | } | ||
| 2226 | } | ||
| 2227 | |||
| 2228 | if ( not scalar @matching_keytag_rrsigs or not $found_match ) { | ||
| 2229 | push @{ $no_matching_dnskey_rrsig{$dnskey_matching_ds{$dnskey}} }, $ns->address->short; | ||
| 2230 | } | ||
| 2231 | else { | ||
| 2232 | $has_rrsig_match_ds{$ns->address->short} = 1; | ||
| 2233 | } | ||
| 2234 | } | ||
| 2235 | } | ||
| 2236 | } | ||
| 2237 | } | ||
| 2238 | } | ||
| 2239 | |||
| 2240 | if ( scalar keys %no_dnskey_for_ds ) { | ||
| 2241 | push @results, map { | ||
| 2242 | _emit_log( | ||
| 2243 | DS02_NO_DNSKEY_FOR_DS => { | ||
| 2244 | keytag => $_, | ||
| 2245 | ns_ip_list => join( q{;}, uniq sort @{ $no_dnskey_for_ds{$_} } ) | ||
| 2246 | } | ||
| 2247 | ) | ||
| 2248 | } keys %no_dnskey_for_ds; | ||
| 2249 | } | ||
| 2250 | if ( scalar keys %no_match_ds_dnskey ) { | ||
| 2251 | push @results, map { | ||
| 2252 | _emit_log( | ||
| 2253 | DS02_NO_MATCH_DS_DNSKEY => { | ||
| 2254 | keytag => $_, | ||
| 2255 | ns_ip_list => join( q{;}, uniq sort @{ $no_match_ds_dnskey{$_} } ) | ||
| 2256 | } | ||
| 2257 | ) | ||
| 2258 | } keys %no_match_ds_dnskey; | ||
| 2259 | } | ||
| 2260 | if ( scalar keys %dnskey_not_for_zone_signing ) { | ||
| 2261 | push @results, map { | ||
| 2262 | _emit_log( | ||
| 2263 | DS02_DNSKEY_NOT_FOR_ZONE_SIGNING => { | ||
| 2264 | keytag => $_, | ||
| 2265 | ns_ip_list => join( q{;}, uniq sort @{ $dnskey_not_for_zone_signing{$_} } ) | ||
| 2266 | } | ||
| 2267 | ) | ||
| 2268 | } keys %dnskey_not_for_zone_signing; | ||
| 2269 | } | ||
| 2270 | if ( scalar keys %dnskey_not_sep ) { | ||
| 2271 | push @results, map { | ||
| 2272 | _emit_log( | ||
| 2273 | DS02_DNSKEY_NOT_SEP => { | ||
| 2274 | keytag => $_, | ||
| 2275 | ns_ip_list => join( q{;}, uniq sort @{ $dnskey_not_sep{$_} } ) | ||
| 2276 | } | ||
| 2277 | ) | ||
| 2278 | } keys %dnskey_not_sep; | ||
| 2279 | } | ||
| 2280 | if ( scalar keys %no_matching_dnskey_rrsig ) { | ||
| 2281 | push @results, map { | ||
| 2282 | _emit_log( | ||
| 2283 | DS02_NO_MATCHING_DNSKEY_RRSIG => { | ||
| 2284 | keytag => $_, | ||
| 2285 | ns_ip_list => join( q{;}, uniq sort @{ $no_matching_dnskey_rrsig{$_} } ) | ||
| 2286 | } | ||
| 2287 | ) | ||
| 2288 | } keys %no_matching_dnskey_rrsig; | ||
| 2289 | } | ||
| 2290 | if ( scalar keys %algo_not_supported_by_zm ) { | ||
| 2291 | foreach my $keytag ( keys %algo_not_supported_by_zm ) { | ||
| 2292 | push @results, map { | ||
| 2293 | _emit_log( | ||
| 2294 | DS02_ALGO_NOT_SUPPORTED_BY_ZM => { | ||
| 2295 | keytag => $keytag, | ||
| 2296 | algo_num => $_, | ||
| 2297 | algo_mnemo => $algo_properties{$_}{mnemonic}, | ||
| 2298 | ns_ip_list => join( q{;}, uniq sort @{ $algo_not_supported_by_zm{$keytag}{$_} } ) | ||
| 2299 | } | ||
| 2300 | ) | ||
| 2301 | } keys %{ $algo_not_supported_by_zm{$keytag} }; | ||
| 2302 | } | ||
| 2303 | } | ||
| 2304 | if ( scalar keys %rrsig_not_valid_by_dnskey ) { | ||
| 2305 | push @results, map { | ||
| 2306 | _emit_log( | ||
| 2307 | DS02_RRSIG_NOT_VALID_BY_DNSKEY => { | ||
| 2308 | keytag => $_, | ||
| 2309 | ns_ip_list => join( q{;}, uniq sort @{ $rrsig_not_valid_by_dnskey{$_} } ) | ||
| 2310 | } | ||
| 2311 | ) | ||
| 2312 | } keys %rrsig_not_valid_by_dnskey; | ||
| 2313 | } | ||
| 2314 | |||
| 2315 | foreach my $ns_ip ( keys %responding_child_ns ) { | ||
| 2316 | push @ns_dnskey, $ns_ip if not exists $has_dnskey_match_ds{$ns_ip}; | ||
| 2317 | push @ns_rrsig, $ns_ip if not exists $has_rrsig_match_ds{$ns_ip}; | ||
| 2318 | } | ||
| 2319 | |||
| 2320 | if ( scalar @ns_dnskey ) { | ||
| 2321 | push @results, | ||
| 2322 | _emit_log( | ||
| 2323 | DS02_NO_VALID_DNSKEY_FOR_ANY_DS => { | ||
| 2324 | ns_ip_list => join( q{;}, sort @ns_dnskey ) | ||
| 2325 | } | ||
| 2326 | ) | ||
| 2327 | } | ||
| 2328 | else { | ||
| 2329 | if ( scalar @ns_rrsig ) { | ||
| 2330 | push @results, | ||
| 2331 | _emit_log( | ||
| 2332 | DS02_DNSKEY_NOT_SIGNED_BY_ANY_DS => { | ||
| 2333 | ns_ip_list => join( q{;}, sort @ns_rrsig ) | ||
| 2334 | } | ||
| 2335 | ) | ||
| 2336 | } | ||
| 2337 | } | ||
| 2338 | |||
| 2339 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 2340 | } ## end sub dnssec02 | ||
| 2341 | |||
| 2342 | =over | ||
| 2343 | |||
| 2344 | =item dnssec03() | ||
| 2345 | |||
| 2346 | my @logentry_array = dnssec03( $zone ); | ||
| 2347 | |||
| 2348 | Runs the L<DNSSEC03 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec03.md>. | ||
| 2349 | |||
| 2350 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 2351 | |||
| 2352 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 2353 | |||
| 2354 | =back | ||
| 2355 | |||
| 2356 | =cut | ||
| 2357 | |||
| 2358 | sub dnssec03 { | ||
| 2359 | my ( $self, $zone ) = @_; | ||
| 2360 | |||
| 2361 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC03'; | ||
| 2362 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 2363 | |||
| 2364 | my @responds_without_dnskey; | ||
| 2365 | my @responds_with_dnskey; | ||
| 2366 | my @responds_without_nsec3; | ||
| 2367 | my @responds_with_nsec3; | ||
| 2368 | my @multiple_nsec3; | ||
| 2369 | my %hash_algorithm; | ||
| 2370 | my %nsec3_flags; | ||
| 2371 | my %nsec3_iterations; | ||
| 2372 | my %nsec3_salt_length; | ||
| 2373 | my @no_response_nsec_query; | ||
| 2374 | my @error_response_nsec_query; | ||
| 2375 | |||
| 2376 | my %ip_already_processed; | ||
| 2377 | |||
| 2378 | foreach my $ns ( @{ Zonemaster::Engine::TestMethods->method4and5( $zone ) } ){ | ||
| 2379 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 2380 | $ip_already_processed{$ns->address->short} = 1; | ||
| 2381 | |||
| 2382 | if ( _ip_disabled_message( \@results, $ns, qw{DNSKEY NSEC} ) ) { | ||
| 2383 | next; | ||
| 2384 | } | ||
| 2385 | |||
| 2386 | my $p1 = $ns->query( $zone->name, q{DNSKEY}, { dnssec => 1 } ); | ||
| 2387 | |||
| 2388 | if ( not $p1 or $p1->rcode ne q{NOERROR} or not $p1->aa ) { | ||
| 2389 | next; | ||
| 2390 | } | ||
| 2391 | |||
| 2392 | if ( not scalar $p1->get_records_for_name( q{DNSKEY}, $zone->name, q{answer} ) ) { | ||
| 2393 | push @responds_without_dnskey, $ns; | ||
| 2394 | next; | ||
| 2395 | } | ||
| 2396 | |||
| 2397 | push @responds_with_dnskey, $ns; | ||
| 2398 | |||
| 2399 | my $p2 = $ns->query( $zone->name, q{NSEC}, { dnssec => 1 } ); | ||
| 2400 | |||
| 2401 | if ( not $p2 ) { | ||
| 2402 | push @no_response_nsec_query, $ns; | ||
| 2403 | next; | ||
| 2404 | } | ||
| 2405 | |||
| 2406 | if ( $p2->rcode ne q{NOERROR} or not $p2->aa ) { | ||
| 2407 | push @error_response_nsec_query, $ns; | ||
| 2408 | next; | ||
| 2409 | } | ||
| 2410 | |||
| 2411 | my @nsec3_rrs = $p2->get_records( q{NSEC3}, q{authority} ); | ||
| 2412 | |||
| 2413 | if ( not scalar @nsec3_rrs ) { | ||
| 2414 | push @responds_without_nsec3, $ns; | ||
| 2415 | next; | ||
| 2416 | } | ||
| 2417 | else { | ||
| 2418 | push @responds_with_nsec3, $ns; | ||
| 2419 | |||
| 2420 | if ( scalar @nsec3_rrs > 1 ) { | ||
| 2421 | push @multiple_nsec3, $ns; | ||
| 2422 | } | ||
| 2423 | |||
| 2424 | my $rr = ( @nsec3_rrs )[0]; | ||
| 2425 | |||
| 2426 | push @{ $hash_algorithm{$rr->algorithm} }, $ns if defined $rr->algorithm; | ||
| 2427 | push @{ $nsec3_flags{$rr->flags} }, $ns if defined $rr->flags; | ||
| 2428 | push @{ $nsec3_iterations{$rr->iterations} }, $ns if defined $rr->iterations; | ||
| 2429 | |||
| 2430 | if ( defined $rr->salt ) { | ||
| 2431 | push @{ $nsec3_salt_length{length unpack('H*', $rr->salt)} }, $ns; | ||
| 2432 | } | ||
| 2433 | else { | ||
| 2434 | push @{ $nsec3_salt_length{0} }, $ns; | ||
| 2435 | } | ||
| 2436 | } | ||
| 2437 | } | ||
| 2438 | |||
| 2439 | if ( not scalar @responds_with_dnskey and scalar @responds_without_dnskey ) { | ||
| 2440 | push @results, | ||
| 2441 | _emit_log( | ||
| 2442 | DS03_NO_DNSSEC_SUPPORT => { | ||
| 2443 | ns_list => join( q{;}, sort @responds_without_dnskey ) | ||
| 2444 | } | ||
| 2445 | ); | ||
| 2446 | } | ||
| 2447 | |||
| 2448 | if ( scalar @responds_with_dnskey and scalar @responds_without_dnskey ) { | ||
| 2449 | push @results, | ||
| 2450 | _emit_log( | ||
| 2451 | DS03_SERVER_NO_DNSSEC_SUPPORT => { | ||
| 2452 | ns_list => join( q{;}, sort @responds_without_dnskey ) | ||
| 2453 | } | ||
| 2454 | ); | ||
| 2455 | } | ||
| 2456 | |||
| 2457 | if ( not scalar @responds_with_nsec3 and scalar @responds_without_nsec3 ) { | ||
| 2458 | push @results, | ||
| 2459 | _emit_log( | ||
| 2460 | DS03_NO_NSEC3 => { | ||
| 2461 | ns_list => join( q{;}, sort @responds_without_nsec3 ) | ||
| 2462 | } | ||
| 2463 | ); | ||
| 2464 | } | ||
| 2465 | |||
| 2466 | if ( scalar @responds_with_nsec3 and scalar @responds_without_nsec3 ) { | ||
| 2467 | push @results, | ||
| 2468 | _emit_log( | ||
| 2469 | DS03_SERVER_NO_NSEC3 => { | ||
| 2470 | ns_list => join( q{;}, sort @responds_without_nsec3 ) | ||
| 2471 | } | ||
| 2472 | ); | ||
| 2473 | } | ||
| 2474 | |||
| 2475 | if ( scalar @multiple_nsec3 ) { | ||
| 2476 | push @results, | ||
| 2477 | _emit_log( | ||
| 2478 | DS03_ERR_MULT_NSEC3 => { | ||
| 2479 | ns_list => join( q{;}, sort @multiple_nsec3 ) | ||
| 2480 | } | ||
| 2481 | ); | ||
| 2482 | } | ||
| 2483 | |||
| 2484 | if ( scalar keys %hash_algorithm ) { | ||
| 2485 | if ( scalar keys %hash_algorithm > 1 ) { | ||
| 2486 | push @results, | ||
| 2487 | _emit_log( | ||
| 2488 | DS03_INCONSISTENT_HASH_ALGO => {} | ||
| 2489 | ); | ||
| 2490 | } | ||
| 2491 | |||
| 2492 | foreach my $algo ( keys %hash_algorithm ) { | ||
| 2493 | if ( $algo eq '1' ) { | ||
| 2494 | push @results, | ||
| 2495 | _emit_log( | ||
| 2496 | DS03_LEGAL_HASH_ALGO => { | ||
| 2497 | ns_list => join( q{;}, sort @{ $hash_algorithm{$algo} } ) | ||
| 2498 | } | ||
| 2499 | ); | ||
| 2500 | } | ||
| 2501 | else { | ||
| 2502 | push @results, | ||
| 2503 | _emit_log( | ||
| 2504 | DS03_ILLEGAL_HASH_ALGO => { | ||
| 2505 | ns_list => join( q{;}, sort @{ $hash_algorithm{$algo} } ), | ||
| 2506 | algo_num => $algo | ||
| 2507 | } | ||
| 2508 | ); | ||
| 2509 | } | ||
| 2510 | } | ||
| 2511 | } | ||
| 2512 | |||
| 2513 | if ( scalar keys %nsec3_flags ) { | ||
| 2514 | if ( scalar keys %nsec3_flags > 1 ) { | ||
| 2515 | push @results, | ||
| 2516 | _emit_log( | ||
| 2517 | DS03_INCONSISTENT_NSEC3_FLAGS => {} | ||
| 2518 | ); | ||
| 2519 | } | ||
| 2520 | |||
| 2521 | foreach my $flag ( keys %nsec3_flags ) { | ||
| 2522 | # Makes a list of bit positions corresponding to flags that are set, where the most-significant bit is 0. | ||
| 2523 | my @bit_positions = grep { $flag & (1 << ( 7 - $_ ) ) } (0..7); | ||
| 2524 | |||
| 2525 | foreach my $bit ( grep { $_ >= 0 and $_ <= 6 } @bit_positions ) { | ||
| 2526 | push @results, | ||
| 2527 | _emit_log( | ||
| 2528 | DS03_UNASSIGNED_FLAG_USED => { | ||
| 2529 | ns_list => join( q{;}, sort @{ $nsec3_flags{$flag} } ), | ||
| 2530 | int => $bit | ||
| 2531 | } | ||
| 2532 | ); | ||
| 2533 | } | ||
| 2534 | |||
| 2535 | if ( grep { $_ == 7 } @bit_positions ) { | ||
| 2536 | # Note below that the Public Suffix List check is not yet implemented. | ||
| 2537 | if ( $zone->name eq '.' or $zone->name->next_higher eq '.' ) { | ||
| 2538 | push @results, | ||
| 2539 | _emit_log( | ||
| 2540 | DS03_NSEC3_OPT_OUT_ENABLED_TLD => { | ||
| 2541 | ns_list => join( q{;}, sort @{ $nsec3_flags{$flag} } ) | ||
| 2542 | } | ||
| 2543 | ); | ||
| 2544 | } | ||
| 2545 | else { | ||
| 2546 | push @results, | ||
| 2547 | _emit_log( | ||
| 2548 | DS03_NSEC3_OPT_OUT_ENABLED_NON_TLD => { | ||
| 2549 | ns_list => join( q{;}, sort @{ $nsec3_flags{$flag} } ) | ||
| 2550 | } | ||
| 2551 | ); | ||
| 2552 | } | ||
| 2553 | } | ||
| 2554 | else { | ||
| 2555 | push @results, | ||
| 2556 | _emit_log( | ||
| 2557 | DS03_NSEC3_OPT_OUT_DISABLED => { | ||
| 2558 | ns_list => join( q{;}, sort @{ $nsec3_flags{$flag} } ) | ||
| 2559 | } | ||
| 2560 | ); | ||
| 2561 | } | ||
| 2562 | } | ||
| 2563 | } | ||
| 2564 | |||
| 2565 | if ( scalar keys %nsec3_iterations ) { | ||
| 2566 | if ( scalar keys %nsec3_iterations > 1 ) { | ||
| 2567 | push @results, | ||
| 2568 | _emit_log( | ||
| 2569 | DS03_INCONSISTENT_ITERATION => {} | ||
| 2570 | ); | ||
| 2571 | } | ||
| 2572 | |||
| 2573 | foreach my $iter ( keys %nsec3_iterations ) { | ||
| 2574 | if ( $iter eq '0' ) { | ||
| 2575 | push @results, | ||
| 2576 | _emit_log( | ||
| 2577 | DS03_LEGAL_ITERATION_VALUE => { | ||
| 2578 | ns_list => join( q{;}, sort @{ $nsec3_iterations{$iter} } ) | ||
| 2579 | } | ||
| 2580 | ); | ||
| 2581 | } | ||
| 2582 | else { | ||
| 2583 | push @results, | ||
| 2584 | _emit_log( | ||
| 2585 | DS03_ILLEGAL_ITERATION_VALUE => { | ||
| 2586 | ns_list => join( q{;}, sort @{ $nsec3_iterations{$iter} } ), | ||
| 2587 | int => $iter | ||
| 2588 | } | ||
| 2589 | ); | ||
| 2590 | } | ||
| 2591 | } | ||
| 2592 | } | ||
| 2593 | |||
| 2594 | if ( scalar keys %nsec3_salt_length ) { | ||
| 2595 | if ( scalar keys %nsec3_salt_length > 1 ) { | ||
| 2596 | push @results, | ||
| 2597 | _emit_log( | ||
| 2598 | DS03_INCONSISTENT_SALT_LENGTH => {} | ||
| 2599 | ); | ||
| 2600 | } | ||
| 2601 | |||
| 2602 | foreach my $salt ( keys %nsec3_salt_length ) { | ||
| 2603 | if ( $salt eq '0' ) { | ||
| 2604 | push @results, | ||
| 2605 | _emit_log( | ||
| 2606 | DS03_LEGAL_EMPTY_SALT => { | ||
| 2607 | ns_list => join( q{;}, sort @{ $nsec3_salt_length{$salt} } ) | ||
| 2608 | } | ||
| 2609 | ); | ||
| 2610 | } | ||
| 2611 | else { | ||
| 2612 | push @results, | ||
| 2613 | _emit_log( | ||
| 2614 | DS03_ILLEGAL_SALT_LENGTH => { | ||
| 2615 | ns_list => join( q{;}, sort @{ $nsec3_salt_length{$salt} } ), | ||
| 2616 | int => $salt | ||
| 2617 | } | ||
| 2618 | ); | ||
| 2619 | } | ||
| 2620 | } | ||
| 2621 | } | ||
| 2622 | |||
| 2623 | if ( scalar @no_response_nsec_query ) { | ||
| 2624 | push @results, | ||
| 2625 | _emit_log( | ||
| 2626 | DS03_NO_RESPONSE_NSEC_QUERY => { | ||
| 2627 | ns_list => join( q{;}, sort @no_response_nsec_query ) | ||
| 2628 | } | ||
| 2629 | ); | ||
| 2630 | } | ||
| 2631 | |||
| 2632 | if ( scalar @error_response_nsec_query ) { | ||
| 2633 | push @results, | ||
| 2634 | _emit_log( | ||
| 2635 | DS03_ERROR_RESPONSE_NSEC_QUERY => { | ||
| 2636 | ns_list => join( q{;}, sort @error_response_nsec_query ) | ||
| 2637 | } | ||
| 2638 | ); | ||
| 2639 | } | ||
| 2640 | |||
| 2641 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 2642 | } ## end sub dnssec03 | ||
| 2643 | |||
| 2644 | =over | ||
| 2645 | |||
| 2646 | =item dnssec04() | ||
| 2647 | |||
| 2648 | my @logentry_array = dnssec04( $zone ); | ||
| 2649 | |||
| 2650 | Runs the L<DNSSEC04 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec04.md>. | ||
| 2651 | |||
| 2652 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 2653 | |||
| 2654 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 2655 | |||
| 2656 | =back | ||
| 2657 | |||
| 2658 | =cut | ||
| 2659 | |||
| 2660 | sub dnssec04 { | ||
| 2661 | my ( $self, $zone ) = @_; | ||
| 2662 | |||
| 2663 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC04'; | ||
| 2664 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 2665 | |||
| 2666 | my $dnskey_p = $zone->query_one( $zone->name, 'DNSKEY', { dnssec => 1 } ); | ||
| 2667 | if ( not $dnskey_p ) { | ||
| 2668 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 2669 | } | ||
| 2670 | my @keys = $dnskey_p->get_records( 'DNSKEY', 'answer' ); | ||
| 2671 | my @key_sigs = $dnskey_p->get_records( 'RRSIG', 'answer' ); | ||
| 2672 | |||
| 2673 | my $soa_p = $zone->query_one( $zone->name, 'SOA', { dnssec => 1 } ); | ||
| 2674 | if ( not $soa_p ) { | ||
| 2675 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 2676 | } | ||
| 2677 | my @soas = $soa_p->get_records( 'SOA', 'answer' ); | ||
| 2678 | my @soa_sigs = $soa_p->get_records( 'RRSIG', 'answer' ); | ||
| 2679 | |||
| 2680 | foreach my $sig ( @key_sigs, @soa_sigs ) { | ||
| 2681 | push @results, | ||
| 2682 | _emit_log( | ||
| 2683 | RRSIG_EXPIRATION => { | ||
| 2684 | date => scalar( gmtime($sig->expiration) ), | ||
| 2685 | keytag => $sig->keytag, | ||
| 2686 | types => $sig->typecovered, | ||
| 2687 | } | ||
| 2688 | ); | ||
| 2689 | |||
| 2690 | my $remaining = $sig->expiration - int( $dnskey_p->timestamp ); | ||
| 2691 | my $result_remaining; | ||
| 2692 | my $remaining_short_limit = Zonemaster::Engine::Profile->effective->get( q{test_cases_vars.dnssec04.REMAINING_SHORT} ); | ||
| 2693 | my $remaining_long_limit = Zonemaster::Engine::Profile->effective->get( q{test_cases_vars.dnssec04.REMAINING_LONG} ); | ||
| 2694 | my $duration_long_limit = Zonemaster::Engine::Profile->effective->get( q{test_cases_vars.dnssec04.DURATION_LONG} ); | ||
| 2695 | |||
| 2696 | if ( $remaining < 0 ) { # already expired | ||
| 2697 | $result_remaining = _emit_log( | ||
| 2698 | RRSIG_EXPIRED => { | ||
| 2699 | expiration => $sig->expiration, | ||
| 2700 | keytag => $sig->keytag, | ||
| 2701 | types => $sig->typecovered, | ||
| 2702 | } | ||
| 2703 | ); | ||
| 2704 | } | ||
| 2705 | elsif ( $remaining < ( $remaining_short_limit ) ) { | ||
| 2706 | $result_remaining = _emit_log( | ||
| 2707 | REMAINING_SHORT => { | ||
| 2708 | duration => $remaining, | ||
| 2709 | keytag => $sig->keytag, | ||
| 2710 | types => $sig->typecovered, | ||
| 2711 | } | ||
| 2712 | ); | ||
| 2713 | } | ||
| 2714 | elsif ( $remaining > ( $remaining_long_limit ) ) { | ||
| 2715 | $result_remaining = _emit_log( | ||
| 2716 | REMAINING_LONG => { | ||
| 2717 | duration => $remaining, | ||
| 2718 | keytag => $sig->keytag, | ||
| 2719 | types => $sig->typecovered, | ||
| 2720 | } | ||
| 2721 | ); | ||
| 2722 | } | ||
| 2723 | |||
| 2724 | my $duration = $sig->expiration - $sig->inception; | ||
| 2725 | my $result_duration; | ||
| 2726 | if ( $duration > ( $duration_long_limit ) ) { | ||
| 2727 | $result_duration = _emit_log( | ||
| 2728 | DURATION_LONG => { | ||
| 2729 | duration => $duration, | ||
| 2730 | keytag => $sig->keytag, | ||
| 2731 | types => $sig->typecovered, | ||
| 2732 | } | ||
| 2733 | ); | ||
| 2734 | } | ||
| 2735 | |||
| 2736 | if ( $result_remaining or $result_duration ) { | ||
| 2737 | push @results, $result_remaining if $result_remaining; | ||
| 2738 | push @results, $result_duration if $result_duration; | ||
| 2739 | } | ||
| 2740 | else { | ||
| 2741 | push @results, | ||
| 2742 | _emit_log( | ||
| 2743 | DURATION_OK => { | ||
| 2744 | duration => $duration, | ||
| 2745 | keytag => $sig->keytag, | ||
| 2746 | types => $sig->typecovered, | ||
| 2747 | } | ||
| 2748 | ); | ||
| 2749 | } | ||
| 2750 | } ## end foreach my $sig ( @key_sigs...) | ||
| 2751 | |||
| 2752 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 2753 | } ## end sub dnssec04 | ||
| 2754 | |||
| 2755 | =over | ||
| 2756 | |||
| 2757 | =item dnssec05() | ||
| 2758 | |||
| 2759 | my @logentry_array = dnssec05( $zone ); | ||
| 2760 | |||
| 2761 | Runs the L<DNSSEC05 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec05.md>. | ||
| 2762 | |||
| 2763 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 2764 | |||
| 2765 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 2766 | |||
| 2767 | =back | ||
| 2768 | |||
| 2769 | =cut | ||
| 2770 | |||
| 2771 | sub dnssec05 { | ||
| 2772 | my ( $self, $zone ) = @_; | ||
| 2773 | |||
| 2774 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC05'; | ||
| 2775 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 2776 | |||
| 2777 | my @ignored_ns_ip; | ||
| 2778 | my @responds_without_dnskey; | ||
| 2779 | my @responds_with_dnskey; | ||
| 2780 | my %sets = ( | ||
| 2781 | 'DS05_ALGO_DEPRECATED' => {}, | ||
| 2782 | 'DS05_ALGO_RESERVED' => {}, | ||
| 2783 | 'DS05_ALGO_UNASSIGNED' => {}, | ||
| 2784 | 'DS05_ALGO_NOT_RECOMMENDED' => {}, | ||
| 2785 | 'DS05_ALGO_PRIVATE' => {}, | ||
| 2786 | 'DS05_ALGO_NOT_ZONE_SIGN' => {}, | ||
| 2787 | 'DS05_ALGO_OK' => {} | ||
| 2788 | ); | ||
| 2789 | |||
| 2790 | my @nss = uniq grep { $_->isa('Zonemaster::Engine::Nameserver') } ( | ||
| 2791 | @{ Zonemaster::Engine::TestMethodsV2->get_del_ns_names_and_ips( $zone ) // [] }, | ||
| 2792 | @{ Zonemaster::Engine::TestMethodsV2->get_zone_ns_names_and_ips( $zone ) // [] } | ||
| 2793 | ); | ||
| 2794 | |||
| 2795 | my %ip_already_processed; | ||
| 2796 | for my $ns ( @nss ) { | ||
| 2797 | my $ns_ip = $ns->address->short; | ||
| 2798 | |||
| 2799 | next if exists $ip_already_processed{$ns_ip}; | ||
| 2800 | $ip_already_processed{$ns_ip} = [ grep { $_->address->short eq $ns_ip } @nss ]; | ||
| 2801 | |||
| 2802 | if ( _ip_disabled_message( \@results, $ns, 'DNSKEY' ) ) { | ||
| 2803 | next; | ||
| 2804 | } | ||
| 2805 | |||
| 2806 | my @matching_nss = @{ $ip_already_processed{$ns_ip} }; | ||
| 2807 | |||
| 2808 | my $dnskey_p = $ns->query( $zone->name, 'DNSKEY', { dnssec => 1 } ); | ||
| 2809 | |||
| 2810 | if ( not $dnskey_p or $dnskey_p->rcode ne 'NOERROR' or not $dnskey_p->aa ) { | ||
| 2811 | push @ignored_ns_ip, @matching_nss; | ||
| 2812 | next; | ||
| 2813 | } | ||
| 2814 | |||
| 2815 | my @dnskey_rrs = $dnskey_p->get_records_for_name( 'DNSKEY', $zone->name->fqdn, 'answer' ); | ||
| 2816 | |||
| 2817 | if ( not @dnskey_rrs ) { | ||
| 2818 | push @responds_without_dnskey, @matching_nss; | ||
| 2819 | next; | ||
| 2820 | } | ||
| 2821 | |||
| 2822 | push @responds_with_dnskey, @matching_nss; | ||
| 2823 | |||
| 2824 | foreach my $rr ( @dnskey_rrs ) { | ||
| 2825 | my $algo = $rr->algorithm; | ||
| 2826 | my $keytag = $rr->keytag; | ||
| 2827 | |||
| 2828 | push @{ $sets{$dnssec05_tags_mapping{$algo}}->{$algo}{$keytag} }, @matching_nss; | ||
| 2829 | } | ||
| 2830 | } | ||
| 2831 | |||
| 2832 | while ( my ($tag_name, $set_ref) = each %sets ) { | ||
| 2833 | my %values = %{ $set_ref }; | ||
| 2834 | if ( %values ) { | ||
| 2835 | foreach my $algo ( keys %values ) { | ||
| 2836 | foreach my $keytag ( keys %{ $values{$algo} } ) { | ||
| 2837 | push @results, | ||
| 2838 | _emit_log( | ||
| 2839 | $tag_name => { | ||
| 2840 | ns_list => join( q{;}, uniq sort @{ $values{$algo}{$keytag} } ), | ||
| 2841 | keytag => $keytag, | ||
| 2842 | algo_num => $algo, | ||
| 2843 | algo_descr => $algo_properties{$algo}{description}, | ||
| 2844 | algo_mnemo => $algo_properties{$algo}{mnemonic} | ||
| 2845 | } | ||
| 2846 | ); | ||
| 2847 | } | ||
| 2848 | } | ||
| 2849 | } | ||
| 2850 | } | ||
| 2851 | |||
| 2852 | if ( not @responds_without_dnskey and not @responds_with_dnskey ) { | ||
| 2853 | push @results, | ||
| 2854 | _emit_log( | ||
| 2855 | DS05_NO_RESPONSE => { | ||
| 2856 | ns_list => join( q{;}, uniq sort @ignored_ns_ip ) | ||
| 2857 | } | ||
| 2858 | ); | ||
| 2859 | } | ||
| 2860 | |||
| 2861 | if ( @responds_without_dnskey ) { | ||
| 2862 | if ( not @responds_with_dnskey ) { | ||
| 2863 | push @results, | ||
| 2864 | _emit_log( | ||
| 2865 | DS05_ZONE_NO_DNSSEC => { | ||
| 2866 | ns_list => join( q{;}, uniq sort @responds_without_dnskey ) | ||
| 2867 | } | ||
| 2868 | ); | ||
| 2869 | } | ||
| 2870 | else { | ||
| 2871 | push @results, | ||
| 2872 | _emit_log( | ||
| 2873 | DS05_SERVER_NO_DNSSEC => { | ||
| 2874 | ns_list => join( q{;}, uniq sort @responds_without_dnskey ) | ||
| 2875 | } | ||
| 2876 | ); | ||
| 2877 | } | ||
| 2878 | } | ||
| 2879 | |||
| 2880 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 2881 | } ## end sub dnssec05 | ||
| 2882 | |||
| 2883 | =over | ||
| 2884 | |||
| 2885 | =item dnssec06() | ||
| 2886 | |||
| 2887 | my @logentry_array = dnssec06( $zone ); | ||
| 2888 | |||
| 2889 | Runs the L<DNSSEC06 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec06.md>. | ||
| 2890 | |||
| 2891 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 2892 | |||
| 2893 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 2894 | |||
| 2895 | =back | ||
| 2896 | |||
| 2897 | =cut | ||
| 2898 | |||
| 2899 | sub dnssec06 { | ||
| 2900 | my ( $self, $zone ) = @_; | ||
| 2901 | |||
| 2902 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC06'; | ||
| 2903 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 2904 | |||
| 2905 | my $dnskey_aref = $zone->query_all( $zone->name, 'DNSKEY', { dnssec => 1 } ); | ||
| 2906 | foreach my $dnskey_p ( @{$dnskey_aref} ) { | ||
| 2907 | next if not $dnskey_p; | ||
| 2908 | |||
| 2909 | my @keys = $dnskey_p->get_records( 'DNSKEY', 'answer' ); | ||
| 2910 | my @sigs = $dnskey_p->get_records( 'RRSIG', 'answer' ); | ||
| 2911 | if ( @sigs > 0 and @keys > 0 ) { | ||
| 2912 | push @results, | ||
| 2913 | _emit_log( | ||
| 2914 | EXTRA_PROCESSING_OK => { | ||
| 2915 | server => $dnskey_p->answerfrom, | ||
| 2916 | keys => scalar( @keys ), | ||
| 2917 | sigs => scalar( @sigs ), | ||
| 2918 | } | ||
| 2919 | ); | ||
| 2920 | } | ||
| 2921 | elsif ( $dnskey_p->rcode eq q{NOERROR} and ( @sigs == 0 or @keys == 0 ) ) { | ||
| 2922 | push @results, | ||
| 2923 | _emit_log( | ||
| 2924 | EXTRA_PROCESSING_BROKEN => { | ||
| 2925 | server => $dnskey_p->answerfrom, | ||
| 2926 | keys => scalar( @keys ), | ||
| 2927 | sigs => scalar( @sigs ) | ||
| 2928 | } | ||
| 2929 | ); | ||
| 2930 | } | ||
| 2931 | } ## end foreach my $dnskey_p ( @{$dnskey_aref...}) | ||
| 2932 | |||
| 2933 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 2934 | } ## end sub dnssec06 | ||
| 2935 | |||
| 2936 | =over | ||
| 2937 | |||
| 2938 | =item dnssec07() | ||
| 2939 | |||
| 2940 | my @logentry_array = dnssec07( $zone ); | ||
| 2941 | |||
| 2942 | Runs the L<DNSSEC07 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec07.md>. | ||
| 2943 | |||
| 2944 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 2945 | |||
| 2946 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 2947 | |||
| 2948 | =back | ||
| 2949 | |||
| 2950 | =cut | ||
| 2951 | |||
| 2952 | sub dnssec07 { | ||
| 2953 | my ( $self, $zone ) = @_; | ||
| 2954 | |||
| 2955 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC07'; | ||
| 2956 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 2957 | |||
| 2958 | my $type_soa = q{SOA}; | ||
| 2959 | my $type_dnskey = q{DNSKEY}; | ||
| 2960 | my $type_ds = q{DS}; | ||
| 2961 | my @query_types = ( $type_soa, $type_dnskey, $type_ds ); | ||
| 2962 | |||
| 2963 | my ( @ignored_child_ns, @ignored_parent_ns_ip ); | ||
| 2964 | my ( @no_response_dnskey, @signed_response ); | ||
| 2965 | my ( @no_auth_dnskey, %error_rcode_dnskey ); | ||
| 2966 | my ( @no_dnskey, @no_ds, @ds_in_response ); | ||
| 2967 | |||
| 2968 | my @child_nss = uniq grep { $_->isa('Zonemaster::Engine::Nameserver') } ( | ||
| 2969 | @{ Zonemaster::Engine::TestMethodsV2->get_del_ns_names_and_ips( $zone ) // [] }, | ||
| 2970 | @{ Zonemaster::Engine::TestMethodsV2->get_zone_ns_names_and_ips( $zone ) // [] } | ||
| 2971 | ); | ||
| 2972 | |||
| 2973 | my %ip_already_processed; | ||
| 2974 | for my $ns ( @child_nss ) { | ||
| 2975 | my $ns_ip = $ns->address->short; | ||
| 2976 | |||
| 2977 | next if exists $ip_already_processed{$ns_ip}; | ||
| 2978 | $ip_already_processed{$ns_ip} = [ grep { $_->address->short eq $ns_ip } @child_nss ]; | ||
| 2979 | |||
| 2980 | if ( _ip_disabled_message( \@results, $ns, @query_types ) ) { | ||
| 2981 | next; | ||
| 2982 | } | ||
| 2983 | |||
| 2984 | my @matching_nss = @{ $ip_already_processed{$ns_ip} }; | ||
| 2985 | |||
| 2986 | my $soa_p = $ns->query( $zone->name, $type_soa ); | ||
| 2987 | |||
| 2988 | if ( not $soa_p or $soa_p->rcode ne 'NOERROR' or not $soa_p->aa or not $soa_p->get_records( $type_soa, 'answer' ) ) { | ||
| 2989 | push @ignored_child_ns, @matching_nss; | ||
| 2990 | next; | ||
| 2991 | } | ||
| 2992 | |||
| 2993 | my $dnskey_p = $ns->query( $zone->name, $type_dnskey, { dnssec => 1 } ); | ||
| 2994 | |||
| 2995 | if ( not $dnskey_p ) { | ||
| 2996 | push @no_response_dnskey, @matching_nss; | ||
| 2997 | next; | ||
| 2998 | } | ||
| 2999 | |||
| 3000 | if ( not $dnskey_p->aa ) { | ||
| 3001 | push @no_auth_dnskey, @matching_nss; | ||
| 3002 | next; | ||
| 3003 | } | ||
| 3004 | |||
| 3005 | if ( $dnskey_p->rcode ne 'NOERROR' ) { | ||
| 3006 | push @{ $error_rcode_dnskey{$dnskey_p->rcode} }, @matching_nss; | ||
| 3007 | next; | ||
| 3008 | } | ||
| 3009 | |||
| 3010 | my @dnskey_rrs = $dnskey_p->get_records( $type_dnskey, 'answer' ); | ||
| 3011 | my @rrsig_rrs = $dnskey_p->get_records( 'RRSIG', 'answer' ); | ||
| 3012 | |||
| 3013 | my $covered_dnskey = 0; | ||
| 3014 | foreach my $rr ( @rrsig_rrs ) { | ||
| 3015 | if ( $rr->typecovered eq $type_dnskey ) { | ||
| 3016 | $covered_dnskey = 1; | ||
| 3017 | last; | ||
| 3018 | } | ||
| 3019 | } | ||
| 3020 | |||
| 3021 | if ( $covered_dnskey ) { | ||
| 3022 | push @signed_response, @matching_nss; | ||
| 3023 | } | ||
| 3024 | else { | ||
| 3025 | push @no_dnskey, @matching_nss; | ||
| 3026 | } | ||
| 3027 | } | ||
| 3028 | |||
| 3029 | my $parent_ref = Zonemaster::Engine::TestMethodsV2->get_parent_ns_names_and_ips( $zone ); | ||
| 3030 | |||
| 3031 | my @undelegated_ds; | ||
| 3032 | if ( my $parent = $zone->parent ) { | ||
| 3033 | foreach my $ns ( @{ $parent->ns } ) { | ||
| 3034 | if ( $ns->fake_ds->{$zone->name} ) { | ||
| 3035 | @undelegated_ds = @{ $ns->fake_ds->{$zone->name} }; | ||
| 3036 | |||
| 3037 | if ( @undelegated_ds ) { | ||
| 3038 | push @ds_in_response, '-'; | ||
| 3039 | $parent_ref = undef; | ||
| 3040 | } | ||
| 3041 | } | ||
| 3042 | } | ||
| 3043 | } | ||
| 3044 | |||
| 3045 | if ( not @signed_response ) { | ||
| 3046 | $parent_ref = undef; | ||
| 3047 | @ds_in_response = (); | ||
| 3048 | } | ||
| 3049 | |||
| 3050 | my @parent_nss = @{ $parent_ref // [] }; | ||
| 3051 | |||
| 3052 | %ip_already_processed = (); | ||
| 3053 | foreach my $ns ( @parent_nss ) { | ||
| 3054 | my $ns_ip = $ns->address->short; | ||
| 3055 | |||
| 3056 | next if exists $ip_already_processed{$ns_ip}; | ||
| 3057 | $ip_already_processed{$ns_ip} = [ grep { $_->address->short eq $ns_ip } @parent_nss ]; | ||
| 3058 | |||
| 3059 | if ( _ip_disabled_message( \@results, $ns, $type_ds ) ) { | ||
| 3060 | next; | ||
| 3061 | } | ||
| 3062 | |||
| 3063 | my @matching_nss = @{ $ip_already_processed{$ns_ip} }; | ||
| 3064 | |||
| 3065 | my $ds_p = $ns->query( $zone->name, $type_ds, { dnssec => 1 } ); | ||
| 3066 | |||
| 3067 | if ( not $ds_p or $ds_p->rcode ne q{NOERROR} or not $ds_p->has_edns or not $ds_p->do or not $ds_p->aa ) { | ||
| 3068 | push @ignored_parent_ns_ip, @matching_nss; | ||
| 3069 | next; | ||
| 3070 | } | ||
| 3071 | |||
| 3072 | my @ds_rrs = $ds_p->get_records_for_name( $type_ds, $zone->name, q{answer} ); | ||
| 3073 | my @rrsig_rrs = $ds_p->get_records_for_name( q{RRSIG}, $zone->name, q{answer} ); | ||
| 3074 | |||
| 3075 | my $covered_ds = 0; | ||
| 3076 | foreach my $rr ( @rrsig_rrs ) { | ||
| 3077 | if ( $rr->typecovered eq $type_ds ) { | ||
| 3078 | $covered_ds = 1; | ||
| 3079 | last; | ||
| 3080 | } | ||
| 3081 | } | ||
| 3082 | |||
| 3083 | if ( $covered_ds ) { | ||
| 3084 | push @ds_in_response, @matching_nss; | ||
| 3085 | } | ||
| 3086 | else { | ||
| 3087 | push @no_ds, @matching_nss; | ||
| 3088 | } | ||
| 3089 | } | ||
| 3090 | |||
| 3091 | my @combined = uniq ( @ignored_child_ns, @no_response_dnskey, @no_auth_dnskey, map { @{ $error_rcode_dnskey{$_} } } keys %error_rcode_dnskey ); | ||
| 3092 | my $lc = List::Compare->new(\@combined, \@child_nss); | ||
| 3093 | |||
| 3094 | if ( not $lc->get_symmetric_difference ) { | ||
| 3095 | push @results, | ||
| 3096 | _emit_log( | ||
| 3097 | DS07_NOT_SIGNED => {} | ||
| 3098 | ); | ||
| 3099 | } | ||
| 3100 | |||
| 3101 | if ( @no_response_dnskey ) { | ||
| 3102 | push @results, | ||
| 3103 | _emit_log( | ||
| 3104 | DS07_NO_RESPONSE_DNSKEY => { | ||
| 3105 | ns_list => join( q{;}, uniq sort @no_response_dnskey ) | ||
| 3106 | } | ||
| 3107 | ); | ||
| 3108 | } | ||
| 3109 | |||
| 3110 | if ( @no_auth_dnskey ) { | ||
| 3111 | push @results, | ||
| 3112 | _emit_log( | ||
| 3113 | DS07_NON_AUTH_RESPONSE_DNSKEY => { | ||
| 3114 | ns_list => join( q{;}, uniq sort @no_auth_dnskey ) | ||
| 3115 | } | ||
| 3116 | ); | ||
| 3117 | } | ||
| 3118 | |||
| 3119 | if ( keys %error_rcode_dnskey ) { | ||
| 3120 | push @results, | ||
| 3121 | _emit_log( | ||
| 3122 | DS07_UNEXP_RCODE_RESP_DNSKEY => { | ||
| 3123 | ns_list => join( q{;}, uniq sort @{ $error_rcode_dnskey{$_} } ), | ||
| 3124 | rcode => $_ | ||
| 3125 | } | ||
| 3126 | ) for keys %error_rcode_dnskey; | ||
| 3127 | } | ||
| 3128 | |||
| 3129 | if ( @signed_response ) { | ||
| 3130 | push @results, | ||
| 3131 | _emit_log( | ||
| 3132 | DS07_SIGNED_ON_SERVER => { | ||
| 3133 | ns_list => join( q{;}, uniq sort @signed_response ) | ||
| 3134 | } | ||
| 3135 | ); | ||
| 3136 | } | ||
| 3137 | |||
| 3138 | if ( @no_dnskey ) { | ||
| 3139 | push @results, | ||
| 3140 | _emit_log( | ||
| 3141 | DS07_NOT_SIGNED_ON_SERVER => { | ||
| 3142 | ns_list => join( q{;}, uniq sort @no_dnskey ) | ||
| 3143 | } | ||
| 3144 | ); | ||
| 3145 | } | ||
| 3146 | |||
| 3147 | if ( @signed_response and @no_dnskey ) { | ||
| 3148 | push @results, | ||
| 3149 | _emit_log( | ||
| 3150 | DS07_INCONSISTENT_SIGNED => {} | ||
| 3151 | ); | ||
| 3152 | } | ||
| 3153 | |||
| 3154 | if ( @signed_response and not @no_dnskey ) { | ||
| 3155 | push @results, | ||
| 3156 | _emit_log( | ||
| 3157 | DS07_SIGNED => {} | ||
| 3158 | ); | ||
| 3159 | } | ||
| 3160 | |||
| 3161 | if ( not @signed_response and @no_dnskey ) { | ||
| 3162 | push @results, | ||
| 3163 | _emit_log( | ||
| 3164 | DS07_NOT_SIGNED => {} | ||
| 3165 | ); | ||
| 3166 | } | ||
| 3167 | |||
| 3168 | if ( @no_ds ) { | ||
| 3169 | push @results, | ||
| 3170 | _emit_log( | ||
| 3171 | DS07_NO_DS_ON_PARENT_SERVER => { | ||
| 3172 | ns_list => join( q{;}, uniq sort @no_ds ) | ||
| 3173 | } | ||
| 3174 | ); | ||
| 3175 | } | ||
| 3176 | |||
| 3177 | if ( @ds_in_response ) { | ||
| 3178 | push @results, | ||
| 3179 | _emit_log( | ||
| 3180 | DS07_DS_ON_PARENT_SERVER => { | ||
| 3181 | ns_list => join( q{;}, uniq sort @ds_in_response ) | ||
| 3182 | } | ||
| 3183 | ); | ||
| 3184 | } | ||
| 3185 | |||
| 3186 | if ( @no_ds and @ds_in_response ) { | ||
| 3187 | push @results, | ||
| 3188 | _emit_log( | ||
| 3189 | DS07_INCONSISTENT_DS => {} | ||
| 3190 | ); | ||
| 3191 | } | ||
| 3192 | |||
| 3193 | if ( not @no_dnskey and @signed_response ) { | ||
| 3194 | if ( @no_ds and not @ds_in_response ) { | ||
| 3195 | push @results, | ||
| 3196 | _emit_log( | ||
| 3197 | DS07_NO_DS_FOR_SIGNED_ZONE => {} | ||
| 3198 | ); | ||
| 3199 | } | ||
| 3200 | if ( not @no_ds and @ds_in_response ) { | ||
| 3201 | push @results, | ||
| 3202 | _emit_log( | ||
| 3203 | DS07_DS_FOR_SIGNED_ZONE => {} | ||
| 3204 | ); | ||
| 3205 | } | ||
| 3206 | } | ||
| 3207 | |||
| 3208 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 3209 | } ## end sub dnssec07 | ||
| 3210 | |||
| 3211 | =over | ||
| 3212 | |||
| 3213 | =item dnssec08() | ||
| 3214 | |||
| 3215 | my @logentry_array = dnssec08( $zone ); | ||
| 3216 | |||
| 3217 | Runs the L<DNSSEC08 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec08.md>. | ||
| 3218 | |||
| 3219 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 3220 | |||
| 3221 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 3222 | |||
| 3223 | =back | ||
| 3224 | |||
| 3225 | =cut | ||
| 3226 | |||
| 3227 | sub dnssec08 { | ||
| 3228 | my ( $self, $zone ) = @_; | ||
| 3229 | |||
| 3230 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC08'; | ||
| 3231 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 3232 | my @dnskey_without_rrsig; | ||
| 3233 | my %dnskey_rrsig_not_yet_valid; | ||
| 3234 | my %dnskey_rrsig_expired; | ||
| 3235 | my %no_matching_dnskey; | ||
| 3236 | my %rrsig_not_valid_by_dnskey; | ||
| 3237 | my %algo_not_supported_by_zm; | ||
| 3238 | |||
| 3239 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 3240 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 3241 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 3242 | my %ip_already_processed; | ||
| 3243 | |||
| 3244 | for my $nss_key ( sort keys %nss ) { | ||
| 3245 | my $ns = $nss{$nss_key}; | ||
| 3246 | |||
| 3247 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 3248 | $ip_already_processed{$ns->address->short} = 1; | ||
| 3249 | |||
| 3250 | if ( _ip_disabled_message( \@results, $ns, q{DNSKEY} ) ) { | ||
| 3251 | next; | ||
| 3252 | } | ||
| 3253 | |||
| 3254 | my $dnskey_p = $ns->query( $zone->name, q{DNSKEY}, { dnssec => 1 } ); | ||
| 3255 | if ( not $dnskey_p ) { | ||
| 3256 | next; | ||
| 3257 | } | ||
| 3258 | if ( $dnskey_p->rcode ne q{NOERROR} ) { | ||
| 3259 | next; | ||
| 3260 | } | ||
| 3261 | if ( not $dnskey_p->aa ) { | ||
| 3262 | next; | ||
| 3263 | } | ||
| 3264 | |||
| 3265 | my @dnskey_records = $dnskey_p->get_records_for_name( q{DNSKEY}, $zone->name->string, q{answer} ); | ||
| 3266 | if ( not scalar @dnskey_records ) { | ||
| 3267 | next; | ||
| 3268 | } | ||
| 3269 | @dnskey_records = $dnskey_p->get_records( q{DNSKEY}, q{answer} ); | ||
| 3270 | my @rrsig_records = $dnskey_p->get_records( q{RRSIG}, q{answer} ); | ||
| 3271 | |||
| 3272 | if ( not scalar @rrsig_records ) { | ||
| 3273 | push @dnskey_without_rrsig, $ns->address->short; | ||
| 3274 | next; | ||
| 3275 | } | ||
| 3276 | |||
| 3277 | my $time = $dnskey_p->timestamp; | ||
| 3278 | foreach my $rrsig_record ( @rrsig_records ) { | ||
| 3279 | if ( $rrsig_record->inception > $time ) { | ||
| 3280 | push @{ $dnskey_rrsig_not_yet_valid{$rrsig_record->keytag} }, $ns->address->short; | ||
| 3281 | } | ||
| 3282 | elsif ( $rrsig_record->expiration < $time ) { | ||
| 3283 | push @{ $dnskey_rrsig_expired{$rrsig_record->keytag} }, $ns->address->short; | ||
| 3284 | } | ||
| 3285 | else { | ||
| 3286 | my $msg = q{}; | ||
| 3287 | my $validate = $rrsig_record->verify_time( \@dnskey_records, \@dnskey_records, $time, $msg ); | ||
| 3288 | if ( not $validate and $msg =~ /Unknown cryptographic algorithm/ ) { | ||
| 3289 | push @{ $algo_not_supported_by_zm{$rrsig_record->keytag}{$rrsig_record->algorithm} }, $ns->address->short; | ||
| 3290 | } | ||
| 3291 | elsif ( not scalar grep { $_->keytag == $rrsig_record->keytag } @dnskey_records ) { | ||
| 3292 | push @{ $no_matching_dnskey{$rrsig_record->keytag} }, $ns->address->short; | ||
| 3293 | } | ||
| 3294 | elsif ( not $validate ) { | ||
| 3295 | push @{ $rrsig_not_valid_by_dnskey{$rrsig_record->keytag} }, $ns->address->short; | ||
| 3296 | } | ||
| 3297 | } | ||
| 3298 | } | ||
| 3299 | } | ||
| 3300 | if ( scalar @dnskey_without_rrsig ) { | ||
| 3301 | push @results, | ||
| 3302 | _emit_log( | ||
| 3303 | DS08_MISSING_RRSIG_IN_RESPONSE => { | ||
| 3304 | ns_ip_list => join( q{;}, uniq sort @dnskey_without_rrsig ) | ||
| 3305 | } | ||
| 3306 | ); | ||
| 3307 | } | ||
| 3308 | if ( scalar keys %dnskey_rrsig_not_yet_valid ) { | ||
| 3309 | push @results, map { | ||
| 3310 | _emit_log( | ||
| 3311 | DS08_DNSKEY_RRSIG_NOT_YET_VALID => { | ||
| 3312 | keytag => $_, | ||
| 3313 | ns_ip_list => join( q{;}, uniq sort @{ $dnskey_rrsig_not_yet_valid{$_} } ) | ||
| 3314 | } | ||
| 3315 | ) | ||
| 3316 | } keys %dnskey_rrsig_not_yet_valid; | ||
| 3317 | } | ||
| 3318 | if ( scalar keys %dnskey_rrsig_expired ) { | ||
| 3319 | push @results, map { | ||
| 3320 | _emit_log( | ||
| 3321 | DS08_DNSKEY_RRSIG_EXPIRED => { | ||
| 3322 | keytag => $_, | ||
| 3323 | ns_ip_list => join( q{;}, uniq sort @{ $dnskey_rrsig_expired{$_} } ) | ||
| 3324 | } | ||
| 3325 | ) | ||
| 3326 | } keys %dnskey_rrsig_expired; | ||
| 3327 | } | ||
| 3328 | if ( scalar keys %no_matching_dnskey ) { | ||
| 3329 | push @results, map { | ||
| 3330 | _emit_log( | ||
| 3331 | DS08_NO_MATCHING_DNSKEY => { | ||
| 3332 | keytag => $_, | ||
| 3333 | ns_ip_list => join( q{;}, uniq sort @{ $no_matching_dnskey{$_} } ) | ||
| 3334 | } | ||
| 3335 | ) | ||
| 3336 | } keys %no_matching_dnskey; | ||
| 3337 | } | ||
| 3338 | if ( scalar keys %rrsig_not_valid_by_dnskey ) { | ||
| 3339 | push @results, map { | ||
| 3340 | _emit_log( | ||
| 3341 | DS08_RRSIG_NOT_VALID_BY_DNSKEY => { | ||
| 3342 | keytag => $_, | ||
| 3343 | ns_ip_list => join( q{;}, uniq sort @{ $rrsig_not_valid_by_dnskey{$_} } ) | ||
| 3344 | } | ||
| 3345 | ) | ||
| 3346 | } keys %rrsig_not_valid_by_dnskey; | ||
| 3347 | } | ||
| 3348 | if ( scalar keys %algo_not_supported_by_zm ) { | ||
| 3349 | foreach my $keytag ( keys %algo_not_supported_by_zm ) { | ||
| 3350 | push @results, map { | ||
| 3351 | _emit_log( | ||
| 3352 | DS08_ALGO_NOT_SUPPORTED_BY_ZM => { | ||
| 3353 | keytag => $keytag, | ||
| 3354 | algo_num => $_, | ||
| 3355 | algo_mnemo => $algo_properties{$_}{mnemonic}, | ||
| 3356 | ns_ip_list => join( q{;}, uniq sort @{ $algo_not_supported_by_zm{$keytag}{$_} } ) | ||
| 3357 | } | ||
| 3358 | ) | ||
| 3359 | } keys %{ $algo_not_supported_by_zm{$keytag} }; | ||
| 3360 | } | ||
| 3361 | } | ||
| 3362 | |||
| 3363 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 3364 | } ## end sub dnssec08 | ||
| 3365 | |||
| 3366 | =over | ||
| 3367 | |||
| 3368 | =item dnssec09() | ||
| 3369 | |||
| 3370 | my @logentry_array = dnssec09( $zone ); | ||
| 3371 | |||
| 3372 | Runs the L<DNSSEC09 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec09.md>. | ||
| 3373 | |||
| 3374 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 3375 | |||
| 3376 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 3377 | |||
| 3378 | =back | ||
| 3379 | |||
| 3380 | =cut | ||
| 3381 | |||
| 3382 | sub dnssec09 { | ||
| 3383 | my ( $self, $zone ) = @_; | ||
| 3384 | |||
| 3385 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC09'; | ||
| 3386 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 3387 | my @soa_without_rrsig; | ||
| 3388 | my %soa_rrsig_not_yet_valid; | ||
| 3389 | my %soa_rrsig_expired; | ||
| 3390 | my %no_matching_dnskey; | ||
| 3391 | my %rrsig_not_valid_by_dnskey; | ||
| 3392 | my %algo_not_supported_by_zm; | ||
| 3393 | |||
| 3394 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 3395 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 3396 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 3397 | my %ip_already_processed; | ||
| 3398 | |||
| 3399 | for my $nss_key ( sort keys %nss ) { | ||
| 3400 | my $ns = $nss{$nss_key}; | ||
| 3401 | |||
| 3402 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 3403 | $ip_already_processed{$ns->address->short} = 1; | ||
| 3404 | |||
| 3405 | if ( _ip_disabled_message( \@results, $ns, q{DNSKEY} ) ) { | ||
| 3406 | next; | ||
| 3407 | } | ||
| 3408 | |||
| 3409 | my $dnskey_p = $ns->query( $zone->name, q{DNSKEY}, { dnssec => 1 } ); | ||
| 3410 | if ( not $dnskey_p ) { | ||
| 3411 | next; | ||
| 3412 | } | ||
| 3413 | if ( $dnskey_p->rcode ne q{NOERROR} ) { | ||
| 3414 | next; | ||
| 3415 | } | ||
| 3416 | if ( not $dnskey_p->aa ) { | ||
| 3417 | next; | ||
| 3418 | } | ||
| 3419 | |||
| 3420 | my @dnskey_records = $dnskey_p->get_records_for_name( q{DNSKEY}, $zone->name->string, q{answer} ); | ||
| 3421 | if ( not scalar @dnskey_records ) { | ||
| 3422 | next; | ||
| 3423 | } | ||
| 3424 | |||
| 3425 | my $soa_p = $ns->query( $zone->name, q{SOA}, { dnssec => 1, usevc => 0 } ); | ||
| 3426 | if ( not $soa_p ) { | ||
| 3427 | next; | ||
| 3428 | } | ||
| 3429 | if ( $soa_p->rcode ne q{NOERROR} ) { | ||
| 3430 | next; | ||
| 3431 | } | ||
| 3432 | if ( not $soa_p->aa ) { | ||
| 3433 | next; | ||
| 3434 | } | ||
| 3435 | |||
| 3436 | my @soa_records = $soa_p->get_records_for_name( q{SOA}, $zone->name->string, q{answer} ); | ||
| 3437 | if ( not scalar @soa_records ) { | ||
| 3438 | next; | ||
| 3439 | } | ||
| 3440 | my @rrsig_records = $soa_p->get_records( q{RRSIG}, q{answer} ); | ||
| 3441 | |||
| 3442 | if ( not scalar @rrsig_records ) { | ||
| 3443 | push @soa_without_rrsig, $ns->address->short; | ||
| 3444 | next; | ||
| 3445 | } | ||
| 3446 | |||
| 3447 | my $time = $dnskey_p->timestamp; | ||
| 3448 | foreach my $rrsig_record ( @rrsig_records ) { | ||
| 3449 | if ( $rrsig_record->inception > $time ) { | ||
| 3450 | push @{ $soa_rrsig_not_yet_valid{$rrsig_record->keytag} }, $ns->address->short; | ||
| 3451 | } | ||
| 3452 | elsif ( $rrsig_record->expiration < $time ) { | ||
| 3453 | push @{ $soa_rrsig_expired{$rrsig_record->keytag} }, $ns->address->short; | ||
| 3454 | } | ||
| 3455 | else { | ||
| 3456 | my $msg = q{}; | ||
| 3457 | my $validate = $rrsig_record->verify_time( \@soa_records, \@dnskey_records, $time, $msg ); | ||
| 3458 | if ( not $validate and $msg =~ /Unknown cryptographic algorithm/ ) { | ||
| 3459 | push @{ $algo_not_supported_by_zm{$rrsig_record->keytag}{$rrsig_record->algorithm} }, $ns->address->short; | ||
| 3460 | } | ||
| 3461 | elsif ( not scalar grep { $_->keytag == $rrsig_record->keytag } @dnskey_records ) { | ||
| 3462 | push @{ $no_matching_dnskey{$rrsig_record->keytag} }, $ns->address->short; | ||
| 3463 | } | ||
| 3464 | elsif ( not $validate ) { | ||
| 3465 | push @{ $rrsig_not_valid_by_dnskey{$rrsig_record->keytag} }, $ns->address->short; | ||
| 3466 | } | ||
| 3467 | } | ||
| 3468 | } | ||
| 3469 | } | ||
| 3470 | if ( scalar @soa_without_rrsig ) { | ||
| 3471 | push @results, | ||
| 3472 | _emit_log( | ||
| 3473 | DS09_MISSING_RRSIG_IN_RESPONSE => { | ||
| 3474 | ns_ip_list => join( q{;}, uniq sort @soa_without_rrsig ) | ||
| 3475 | } | ||
| 3476 | ); | ||
| 3477 | } | ||
| 3478 | if ( scalar keys %soa_rrsig_not_yet_valid ) { | ||
| 3479 | push @results, map { | ||
| 3480 | _emit_log( | ||
| 3481 | DS09_SOA_RRSIG_NOT_YET_VALID => { | ||
| 3482 | keytag => $_, | ||
| 3483 | ns_ip_list => join( q{;}, uniq sort @{ $soa_rrsig_not_yet_valid{$_} } ) | ||
| 3484 | } | ||
| 3485 | ) | ||
| 3486 | } keys %soa_rrsig_not_yet_valid; | ||
| 3487 | } | ||
| 3488 | if ( scalar keys %soa_rrsig_expired ) { | ||
| 3489 | push @results, map { | ||
| 3490 | _emit_log( | ||
| 3491 | DS09_SOA_RRSIG_EXPIRED => { | ||
| 3492 | keytag => $_, | ||
| 3493 | ns_ip_list => join( q{;}, uniq sort @{ $soa_rrsig_expired{$_} } ) | ||
| 3494 | } | ||
| 3495 | ) | ||
| 3496 | } keys %soa_rrsig_expired; | ||
| 3497 | } | ||
| 3498 | if ( scalar keys %no_matching_dnskey ) { | ||
| 3499 | push @results, map { | ||
| 3500 | _emit_log( | ||
| 3501 | DS09_NO_MATCHING_DNSKEY => { | ||
| 3502 | keytag => $_, | ||
| 3503 | ns_ip_list => join( q{;}, uniq sort @{ $no_matching_dnskey{$_} } ) | ||
| 3504 | } | ||
| 3505 | ) | ||
| 3506 | } keys %no_matching_dnskey; | ||
| 3507 | } | ||
| 3508 | if ( scalar keys %rrsig_not_valid_by_dnskey ) { | ||
| 3509 | push @results, map { | ||
| 3510 | _emit_log( | ||
| 3511 | DS09_RRSIG_NOT_VALID_BY_DNSKEY => { | ||
| 3512 | keytag => $_, | ||
| 3513 | ns_ip_list => join( q{;}, uniq sort @{ $rrsig_not_valid_by_dnskey{$_} } ) | ||
| 3514 | } | ||
| 3515 | ) | ||
| 3516 | } keys %rrsig_not_valid_by_dnskey; | ||
| 3517 | } | ||
| 3518 | if ( scalar keys %algo_not_supported_by_zm ) { | ||
| 3519 | foreach my $keytag ( keys %algo_not_supported_by_zm ) { | ||
| 3520 | push @results, map { | ||
| 3521 | _emit_log( | ||
| 3522 | DS09_ALGO_NOT_SUPPORTED_BY_ZM => { | ||
| 3523 | keytag => $keytag, | ||
| 3524 | algo_num => $_, | ||
| 3525 | algo_mnemo => $algo_properties{$_}{mnemonic}, | ||
| 3526 | ns_ip_list => join( q{;}, uniq sort @{ $algo_not_supported_by_zm{$keytag}{$_} } ) | ||
| 3527 | } | ||
| 3528 | ) | ||
| 3529 | } keys %{ $algo_not_supported_by_zm{$keytag} } | ||
| 3530 | } | ||
| 3531 | } | ||
| 3532 | |||
| 3533 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 3534 | } ## end sub dnssec09 | ||
| 3535 | |||
| 3536 | =over | ||
| 3537 | |||
| 3538 | =item dnssec10() | ||
| 3539 | |||
| 3540 | my @logentry_array = dnssec10( $zone ); | ||
| 3541 | |||
| 3542 | Runs the L<DNSSEC10 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec10.md>. | ||
| 3543 | |||
| 3544 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 3545 | |||
| 3546 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 3547 | |||
| 3548 | =back | ||
| 3549 | |||
| 3550 | =cut | ||
| 3551 | |||
| 3552 | sub dnssec10 { | ||
| 3553 | my ( $class, $zone ) = @_; | ||
| 3554 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC10'; | ||
| 3555 | |||
| 3556 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 3557 | |||
| 3558 | my $type_soa = q{SOA}; | ||
| 3559 | my $type_dnskey = q{DNSKEY}; | ||
| 3560 | my $type_nsec = q{NSEC}; | ||
| 3561 | my $type_nsec3 = q{NSEC3}; | ||
| 3562 | my $type_nsec3param = q{NSEC3PARAM}; | ||
| 3563 | my @query_types = ( $type_dnskey, $type_nsec, $type_nsec3param ); | ||
| 3564 | |||
| 3565 | my %algo_not_supported_by_zm; | ||
| 3566 | my ( @erroneous_multiple_nsec, @erroneous_multiple_nsec3 ); | ||
| 3567 | my ( @nsec_in_response, @nsec_nonstandard_nodata, @nsec3param_in_answer ); | ||
| 3568 | my ( @nsec_incorrect_type_list, @nsec3_incorrect_type_list ); | ||
| 3569 | my ( @nsec_mismatches_apex, @nsec3_mismatches_apex, @nsec3param_mismatches_apex ); | ||
| 3570 | my ( @nsec_missing_signature, @nsec3_missing_signature ); | ||
| 3571 | my ( %nsec_nodata_wrong_soa, %nsec3_nodata_wrong_soa ); | ||
| 3572 | my ( @nsec_nodata_missing_soa, @nsec3_nodata_missing_soa ); | ||
| 3573 | my ( @nsec_erroneous_answer, @nsec3param_erroneous_answer ); | ||
| 3574 | my ( @nsec_nsec3_nodata, @nsec3param_nsec_nodata ); | ||
| 3575 | my ( %nsec_rrsig_verify_error, %nsec3_rrsig_verify_error ); | ||
| 3576 | my ( %nsec_rrsig_expired, %nsec3_rrsig_expired ); | ||
| 3577 | my ( %nsec_rrsig_not_yet_valid, %nsec3_rrsig_not_yet_valid ); | ||
| 3578 | my ( %nsec_rrsig_no_dnskey, %nsec3_rrsig_no_dnskey ); | ||
| 3579 | my ( @nsec_rrsig_verified, @nsec3_rrsig_verified ); | ||
| 3580 | my ( @nsec_response_error, @nsec3param_response_error ); | ||
| 3581 | my ( @with_dnskey, @without_dnskey ); | ||
| 3582 | |||
| 3583 | my @all_ns = uniq grep { $_->isa('Zonemaster::Engine::Nameserver') } ( | ||
| 3584 | @{ Zonemaster::Engine::TestMethodsV2->get_del_ns_names_and_ips( $zone ) // [] }, | ||
| 3585 | @{ Zonemaster::Engine::TestMethodsV2->get_zone_ns_names_and_ips( $zone ) // [] } | ||
| 3586 | ); | ||
| 3587 | |||
| 3588 | my @ignored_nss; | ||
| 3589 | my %nss; | ||
| 3590 | push @{ $nss{$_->address->short} }, $_ for @all_ns; | ||
| 3591 | |||
| 3592 | my $testing_time = time; | ||
| 3593 | |||
| 3594 | for my $ns_ip ( keys %nss ) { | ||
| 3595 | my $ns = $nss{$ns_ip}[0]; | ||
| 3596 | my @all_ns_for_ip = @{ $nss{$ns_ip} }; | ||
| 3597 | |||
| 3598 | if ( _ip_disabled_message( \@results, $ns, @query_types ) ) { | ||
| 3599 | push @ignored_nss, @all_ns_for_ip; | ||
| 3600 | next; | ||
| 3601 | } | ||
| 3602 | |||
| 3603 | my $dnskey_p = $ns->query( $zone->name, $type_dnskey, { dnssec => 1 } ); | ||
| 3604 | |||
| 3605 | if ( not $dnskey_p or $dnskey_p->rcode ne q{NOERROR} or not $dnskey_p->aa ) { | ||
| 3606 | push @ignored_nss, @all_ns_for_ip; | ||
| 3607 | next; | ||
| 3608 | } | ||
| 3609 | |||
| 3610 | my @dnskey_records = $dnskey_p->get_records_for_name( $type_dnskey, $zone->name->string, q{answer} ); | ||
| 3611 | |||
| 3612 | if ( not scalar @dnskey_records ) { | ||
| 3613 | push @without_dnskey, @all_ns_for_ip; | ||
| 3614 | next; | ||
| 3615 | } | ||
| 3616 | |||
| 3617 | push @with_dnskey, @all_ns_for_ip; | ||
| 3618 | |||
| 3619 | my $nsec_p = $ns->query( $zone->name, $type_nsec, { dnssec => 1 } ); | ||
| 3620 | |||
| 3621 | if ( not $nsec_p or $nsec_p->rcode ne q{NOERROR} or not $nsec_p->aa ) { | ||
| 3622 | push @nsec_response_error, @all_ns_for_ip; | ||
| 3623 | } | ||
| 3624 | elsif ( $nsec_p->answer ) { | ||
| 3625 | if ( scalar $nsec_p->get_records( $type_nsec, q{answer} ) ) { | ||
| 3626 | push @nsec_in_response, @all_ns_for_ip; | ||
| 3627 | |||
| 3628 | if ( scalar $nsec_p->get_records( $type_nsec, q{answer} ) > 1 ) { | ||
| 3629 | push @erroneous_multiple_nsec, @all_ns_for_ip; | ||
| 3630 | } | ||
| 3631 | elsif ( ($nsec_p->get_records( $type_nsec, q{answer} ))[0]->owner ne $zone->name ) { | ||
| 3632 | push @nsec_mismatches_apex, @all_ns_for_ip; | ||
| 3633 | } | ||
| 3634 | } | ||
| 3635 | else { | ||
| 3636 | push @nsec_erroneous_answer, @all_ns_for_ip; | ||
| 3637 | } | ||
| 3638 | } | ||
| 3639 | elsif ( not $nsec_p->answer and scalar $nsec_p->get_records( $type_nsec, q{authority} ) ) { | ||
| 3640 | push @nsec_in_response, @all_ns_for_ip; | ||
| 3641 | push @nsec_nonstandard_nodata, @all_ns_for_ip; | ||
| 3642 | |||
| 3643 | unless ( scalar $nsec_p->get_records( $type_soa, q{authority} ) ) { | ||
| 3644 | push @nsec_nodata_missing_soa, @all_ns_for_ip; | ||
| 3645 | } | ||
| 3646 | elsif ( ($nsec_p->get_records( $type_soa, q{authority} ))[0]->owner ne $zone->name ) { | ||
| 3647 | push @{ $nsec_nodata_wrong_soa{$zone->name} }, @all_ns_for_ip; | ||
| 3648 | } | ||
| 3649 | |||
| 3650 | my @nsec_rrs = $nsec_p->get_records( $type_nsec, q{authority} ); | ||
| 3651 | |||
| 3652 | if ( scalar @nsec_rrs > 1 ) { | ||
| 3653 | push @erroneous_multiple_nsec, @all_ns_for_ip; | ||
| 3654 | } | ||
| 3655 | else { | ||
| 3656 | if ( $nsec_rrs[0]->owner ne $zone->name ) { | ||
| 3657 | push @nsec_mismatches_apex, @all_ns_for_ip; | ||
| 3658 | } | ||
| 3659 | else { | ||
| 3660 | my @mandatory_typelist = qw( SOA NS DNSKEY NSEC RRSIG ); | ||
| 3661 | my @forbidden_typelist = qw( NSEC3PARAM NSEC3 ); | ||
| 3662 | my %typelist = %{ $nsec_rrs[0]->typehref }; | ||
| 3663 | |||
| 3664 | foreach my $type ( @mandatory_typelist ) { | ||
| 3665 | if ( not exists $typelist{$type} ) { | ||
| 3666 | push @nsec_incorrect_type_list, @all_ns_for_ip; | ||
| 3667 | last; | ||
| 3668 | } | ||
| 3669 | } | ||
| 3670 | |||
| 3671 | foreach my $type ( @forbidden_typelist ) { | ||
| 3672 | if ( exists $typelist{$type} ) { | ||
| 3673 | push @nsec_incorrect_type_list, @all_ns_for_ip; | ||
| 3674 | last; | ||
| 3675 | } | ||
| 3676 | } | ||
| 3677 | } | ||
| 3678 | |||
| 3679 | my @nsec_rrsig_rrs = grep { $_->typecovered eq q{NSEC} } $nsec_p->get_records_for_name( q{RRSIG}, $nsec_rrs[0]->name ); | ||
| 3680 | |||
| 3681 | unless ( scalar @nsec_rrsig_rrs ) { | ||
| 3682 | push @nsec_missing_signature, @all_ns_for_ip; | ||
| 3683 | } | ||
| 3684 | else { | ||
| 3685 | foreach my $rr ( @nsec_rrsig_rrs ) { | ||
| 3686 | my @matching_dnskeys = grep { $rr->keytag == $_->keytag } @dnskey_records; | ||
| 3687 | |||
| 3688 | unless ( scalar @matching_dnskeys ) { | ||
| 3689 | push @{ $nsec_rrsig_no_dnskey{$rr->keytag} }, @all_ns_for_ip; | ||
| 3690 | } | ||
| 3691 | elsif ( $rr->expiration < $testing_time ) { | ||
| 3692 | push @{ $nsec_rrsig_expired{$rr->keytag} }, @all_ns_for_ip; | ||
| 3693 | } | ||
| 3694 | elsif ( $rr->inception > $testing_time ) { | ||
| 3695 | push @{ $nsec_rrsig_not_yet_valid{$rr->keytag} }, @all_ns_for_ip; | ||
| 3696 | } | ||
| 3697 | else { | ||
| 3698 | my $i = 1; | ||
| 3699 | foreach my $dnskey ( @matching_dnskeys ) { | ||
| 3700 | my $msg = q{}; | ||
| 3701 | my $validated = $rr->verify_time( [grep { name( $_->name ) eq name( $rr->name ) } @nsec_rrs], [ $dnskey ], $testing_time, $msg ); | ||
| 3702 | |||
| 3703 | if ( $validated ) { | ||
| 3704 | push @nsec_rrsig_verified, @all_ns_for_ip; | ||
| 3705 | last; | ||
| 3706 | } | ||
| 3707 | |||
| 3708 | if ( $i >= scalar @matching_dnskeys ) { | ||
| 3709 | if ( $msg =~ /Unknown cryptographic algorithm/ ) { | ||
| 3710 | push @{ $algo_not_supported_by_zm{$dnskey->keytag}{$dnskey->algorithm} }, @all_ns_for_ip; | ||
| 3711 | } | ||
| 3712 | else { | ||
| 3713 | push @{ $nsec_rrsig_verify_error{$dnskey->keytag} }, @all_ns_for_ip; | ||
| 3714 | } | ||
| 3715 | } | ||
| 3716 | |||
| 3717 | $i++; | ||
| 3718 | } | ||
| 3719 | } | ||
| 3720 | } | ||
| 3721 | } | ||
| 3722 | } | ||
| 3723 | } | ||
| 3724 | elsif ( not $nsec_p->answer and scalar $nsec_p->get_records( $type_nsec3, q{authority} ) ) { | ||
| 3725 | push @nsec_nsec3_nodata, @all_ns_for_ip; | ||
| 3726 | |||
| 3727 | unless ( scalar $nsec_p->get_records( $type_soa, q{authority} ) ) { | ||
| 3728 | push @nsec3_nodata_missing_soa, @all_ns_for_ip; | ||
| 3729 | } | ||
| 3730 | elsif ( ($nsec_p->get_records( $type_soa, q{authority} ))[0]->owner ne $zone->name ) { | ||
| 3731 | push @{ $nsec3_nodata_wrong_soa{$zone->name} }, @all_ns_for_ip; | ||
| 3732 | } | ||
| 3733 | |||
| 3734 | my @nsec3_rrs = $nsec_p->get_records( $type_nsec3, q{authority} ); | ||
| 3735 | |||
| 3736 | if ( scalar @nsec3_rrs > 1 ) { | ||
| 3737 | push @erroneous_multiple_nsec3, @all_ns_for_ip; | ||
| 3738 | } | ||
| 3739 | else { | ||
| 3740 | unless ( $nsec3_rrs[0]->hash_name( $zone->name ) eq lc( @{ name($nsec3_rrs[0]->owner)->labels }[0] ) ) { | ||
| 3741 | push @nsec3_mismatches_apex, @all_ns_for_ip; | ||
| 3742 | } | ||
| 3743 | else { | ||
| 3744 | my @mandatory_typelist = qw( SOA NS DNSKEY NSEC3PARAM RRSIG ); | ||
| 3745 | my @forbidden_typelist = qw( NSEC NSEC3 ); | ||
| 3746 | my %typelist = %{ $nsec3_rrs[0]->typehref }; | ||
| 3747 | |||
| 3748 | foreach my $type ( @mandatory_typelist ) { | ||
| 3749 | if ( not exists $typelist{$type} ) { | ||
| 3750 | push @nsec3_incorrect_type_list, @all_ns_for_ip; | ||
| 3751 | last; | ||
| 3752 | } | ||
| 3753 | } | ||
| 3754 | |||
| 3755 | foreach my $type ( @forbidden_typelist ) { | ||
| 3756 | if ( exists $typelist{$type} ) { | ||
| 3757 | push @nsec3_incorrect_type_list, @all_ns_for_ip; | ||
| 3758 | last; | ||
| 3759 | } | ||
| 3760 | } | ||
| 3761 | } | ||
| 3762 | |||
| 3763 | my @nsec3_rrsig_rrs = grep { $_->typecovered eq q{NSEC3} } $nsec_p->get_records_for_name( q{RRSIG}, $nsec3_rrs[0]->name ); | ||
| 3764 | |||
| 3765 | unless ( scalar @nsec3_rrsig_rrs ) { | ||
| 3766 | push @nsec3_missing_signature, @all_ns_for_ip; | ||
| 3767 | } | ||
| 3768 | else { | ||
| 3769 | foreach my $rr ( @nsec3_rrsig_rrs ) { | ||
| 3770 | my @matching_dnskeys = grep { $rr->keytag == $_->keytag } @dnskey_records; | ||
| 3771 | |||
| 3772 | unless ( scalar @matching_dnskeys ) { | ||
| 3773 | push @{ $nsec3_rrsig_no_dnskey{$rr->keytag} }, @all_ns_for_ip; | ||
| 3774 | } | ||
| 3775 | elsif ( $rr->expiration < $testing_time ) { | ||
| 3776 | push @{ $nsec3_rrsig_expired{$rr->keytag} }, @all_ns_for_ip; | ||
| 3777 | } | ||
| 3778 | elsif ( $rr->inception > $testing_time ) { | ||
| 3779 | push @{ $nsec3_rrsig_not_yet_valid{$rr->keytag} }, @all_ns_for_ip; | ||
| 3780 | } | ||
| 3781 | else { | ||
| 3782 | my $i = 1; | ||
| 3783 | foreach my $dnskey ( @matching_dnskeys ) { | ||
| 3784 | my $msg = q{}; | ||
| 3785 | my $validated = $rr->verify_time( [grep { name( $_->name ) eq name( $rr->name ) } @nsec3_rrs], [ $dnskey ], $testing_time, $msg ); | ||
| 3786 | |||
| 3787 | if ( $validated ) { | ||
| 3788 | push @nsec3_rrsig_verified, @all_ns_for_ip; | ||
| 3789 | last; | ||
| 3790 | } | ||
| 3791 | |||
| 3792 | if ( $i >= scalar @matching_dnskeys ) { | ||
| 3793 | if ( $msg =~ /Unknown cryptographic algorithm/ ) { | ||
| 3794 | push @{ $algo_not_supported_by_zm{$dnskey->keytag}{$dnskey->algorithm} }, @all_ns_for_ip; | ||
| 3795 | } | ||
| 3796 | else { | ||
| 3797 | push @{ $nsec3_rrsig_verify_error{$dnskey->keytag} }, @all_ns_for_ip; | ||
| 3798 | } | ||
| 3799 | } | ||
| 3800 | |||
| 3801 | $i++; | ||
| 3802 | } | ||
| 3803 | } | ||
| 3804 | } | ||
| 3805 | } | ||
| 3806 | } | ||
| 3807 | } | ||
| 3808 | |||
| 3809 | my $nsec3param_p = $ns->query( $zone->name, $type_nsec3param, { dnssec => 1 } ); | ||
| 3810 | |||
| 3811 | if ( not $nsec3param_p or $nsec3param_p->rcode ne q{NOERROR} or not $nsec3param_p->aa ) { | ||
| 3812 | push @nsec3param_response_error, @all_ns_for_ip; | ||
| 3813 | } | ||
| 3814 | elsif ( $nsec3param_p->answer ) { | ||
| 3815 | if ( scalar $nsec3param_p->get_records( $type_nsec3param, q{answer} ) ) { | ||
| 3816 | push @nsec3param_in_answer, @all_ns_for_ip; | ||
| 3817 | |||
| 3818 | if ( ($nsec3param_p->get_records( $type_nsec3param, q{answer} ))[0]->owner ne $zone->name ) { | ||
| 3819 | push @nsec3param_mismatches_apex, @all_ns_for_ip; | ||
| 3820 | } | ||
| 3821 | } | ||
| 3822 | else { | ||
| 3823 | push @nsec3param_erroneous_answer, @all_ns_for_ip; | ||
| 3824 | } | ||
| 3825 | } | ||
| 3826 | elsif ( not $nsec3param_p->answer and scalar $nsec3param_p->get_records( $type_nsec, q{authority} ) ) { | ||
| 3827 | my @nsec_rrs = $nsec3param_p->get_records( $type_nsec, q{authority} ); | ||
| 3828 | |||
| 3829 | push @nsec3param_nsec_nodata, @all_ns_for_ip; | ||
| 3830 | |||
| 3831 | unless ( scalar $nsec3param_p->get_records( $type_soa, q{authority} ) ) { | ||
| 3832 | push @nsec_nodata_missing_soa, @all_ns_for_ip; | ||
| 3833 | } | ||
| 3834 | elsif ( ($nsec3param_p->get_records( $type_soa, q{authority} ))[0]->owner ne $zone->name ) { | ||
| 3835 | push @{ $nsec_nodata_wrong_soa{$zone->name} }, @all_ns_for_ip; | ||
| 3836 | } | ||
| 3837 | |||
| 3838 | if ( scalar @nsec_rrs > 1 ) { | ||
| 3839 | push @erroneous_multiple_nsec, @all_ns_for_ip; | ||
| 3840 | } | ||
| 3841 | else { | ||
| 3842 | unless ( $nsec_rrs[0]->owner eq $zone->name ) { | ||
| 3843 | push @nsec_mismatches_apex, @all_ns_for_ip; | ||
| 3844 | } | ||
| 3845 | else { | ||
| 3846 | my @mandatory_typelist = qw( SOA NS DNSKEY NSEC RRSIG ); | ||
| 3847 | my @forbidden_typelist = qw( NSEC3PARAM NSEC3 ); | ||
| 3848 | my %typelist = %{ $nsec_rrs[0]->typehref }; | ||
| 3849 | |||
| 3850 | foreach my $type ( @mandatory_typelist ) { | ||
| 3851 | if ( not exists $typelist{$type} ) { | ||
| 3852 | push @nsec_incorrect_type_list, @all_ns_for_ip; | ||
| 3853 | last; | ||
| 3854 | } | ||
| 3855 | } | ||
| 3856 | |||
| 3857 | foreach my $type ( @forbidden_typelist ) { | ||
| 3858 | if ( exists $typelist{$type} ) { | ||
| 3859 | push @nsec_incorrect_type_list, @all_ns_for_ip; | ||
| 3860 | last; | ||
| 3861 | } | ||
| 3862 | } | ||
| 3863 | } | ||
| 3864 | |||
| 3865 | my @nsec_rrsig_rrs = grep { $_->typecovered eq q{NSEC} } $nsec3param_p->get_records_for_name( q{RRSIG}, $nsec_rrs[0]->name ); | ||
| 3866 | |||
| 3867 | unless ( scalar @nsec_rrsig_rrs ) { | ||
| 3868 | push @nsec_missing_signature, @all_ns_for_ip; | ||
| 3869 | } | ||
| 3870 | else { | ||
| 3871 | foreach my $rr ( @nsec_rrsig_rrs ) { | ||
| 3872 | my @matching_dnskeys = grep { $rr->keytag == $_->keytag } @dnskey_records; | ||
| 3873 | |||
| 3874 | unless ( scalar @matching_dnskeys ) { | ||
| 3875 | push @{ $nsec_rrsig_no_dnskey{$rr->keytag} }, @all_ns_for_ip; | ||
| 3876 | } | ||
| 3877 | elsif ( $rr->expiration < $testing_time ) { | ||
| 3878 | push @{ $nsec_rrsig_expired{$rr->keytag} }, @all_ns_for_ip; | ||
| 3879 | } | ||
| 3880 | elsif ( $rr->inception > $testing_time ) { | ||
| 3881 | push @{ $nsec_rrsig_not_yet_valid{$rr->keytag} }, @all_ns_for_ip; | ||
| 3882 | } | ||
| 3883 | else { | ||
| 3884 | my $i = 1; | ||
| 3885 | foreach my $dnskey ( @matching_dnskeys ) { | ||
| 3886 | my $msg = q{}; | ||
| 3887 | my $validated = $rr->verify_time( [grep { name( $_->name ) eq name( $rr->name ) } @nsec_rrs], [ $dnskey ], $testing_time, $msg ); | ||
| 3888 | |||
| 3889 | if ( $validated ) { | ||
| 3890 | push @nsec_rrsig_verified, @all_ns_for_ip; | ||
| 3891 | last; | ||
| 3892 | } | ||
| 3893 | |||
| 3894 | if ( $i >= scalar @matching_dnskeys ) { | ||
| 3895 | if ( $msg =~ /Unknown cryptographic algorithm/ ) { | ||
| 3896 | push @{ $algo_not_supported_by_zm{$dnskey->keytag}{$dnskey->algorithm} }, @all_ns_for_ip; | ||
| 3897 | } | ||
| 3898 | else { | ||
| 3899 | push @{ $nsec_rrsig_verify_error{$dnskey->keytag} }, @all_ns_for_ip; | ||
| 3900 | } | ||
| 3901 | } | ||
| 3902 | |||
| 3903 | $i++; | ||
| 3904 | } | ||
| 3905 | } | ||
| 3906 | } | ||
| 3907 | } | ||
| 3908 | } | ||
| 3909 | } | ||
| 3910 | } | ||
| 3911 | |||
| 3912 | if ( scalar @erroneous_multiple_nsec ) { | ||
| 3913 | push @results, | ||
| 3914 | _emit_log( | ||
| 3915 | DS10_ERR_MULT_NSEC => { | ||
| 3916 | ns_list => join( q{;}, uniq sort @erroneous_multiple_nsec ) | ||
| 3917 | } | ||
| 3918 | ); | ||
| 3919 | } | ||
| 3920 | |||
| 3921 | if ( scalar @erroneous_multiple_nsec3 ) { | ||
| 3922 | push @results, | ||
| 3923 | _emit_log( | ||
| 3924 | DS10_ERR_MULT_NSEC3 => { | ||
| 3925 | ns_list => join( q{;}, uniq sort @erroneous_multiple_nsec3 ) | ||
| 3926 | } | ||
| 3927 | ); | ||
| 3928 | } | ||
| 3929 | |||
| 3930 | if ( scalar @nsec_nonstandard_nodata ) { | ||
| 3931 | push @results, | ||
| 3932 | _emit_log( | ||
| 3933 | DS10_NONSTANDARD_NSEC_RESPONSE => { | ||
| 3934 | ns_list => join( q{;}, uniq sort @nsec_nonstandard_nodata ) | ||
| 3935 | } | ||
| 3936 | ); | ||
| 3937 | } | ||
| 3938 | |||
| 3939 | my $lc = List::Compare->new( \@nsec_in_response, \@nsec3param_nsec_nodata ); | ||
| 3940 | my @diff = $lc->get_symmetric_difference; | ||
| 3941 | my @union = uniq map { $_->string } ( @nsec3param_in_answer, @nsec_nsec3_nodata ); | ||
| 3942 | my $lc2 = List::Compare->new( \@diff, \@union ); | ||
| 3943 | my @final_diff = $lc2->get_symmetric_difference; | ||
| 3944 | |||
| 3945 | if ( scalar @diff and scalar @final_diff ) { | ||
| 3946 | push @results, | ||
| 3947 | _emit_log( | ||
| 3948 | DS10_INCONSISTENT_NSEC => { | ||
| 3949 | ns_list => join( q{;}, uniq sort @final_diff ) | ||
| 3950 | } | ||
| 3951 | ); | ||
| 3952 | } | ||
| 3953 | |||
| 3954 | $lc = List::Compare->new( \@nsec3param_in_answer, \@nsec_nsec3_nodata ); | ||
| 3955 | @diff = $lc->get_symmetric_difference; | ||
| 3956 | @union = uniq map { $_->string } ( @nsec_in_response, @nsec3param_nsec_nodata ); | ||
| 3957 | $lc2 = List::Compare->new( \@diff, \@union ); | ||
| 3958 | @final_diff = $lc2->get_symmetric_difference; | ||
| 3959 | |||
| 3960 | if ( scalar @diff and scalar @final_diff ) { | ||
| 3961 | push @results, | ||
| 3962 | _emit_log( | ||
| 3963 | DS10_INCONSISTENT_NSEC3 => { | ||
| 3964 | ns_list => join( q{;}, uniq sort @final_diff ) | ||
| 3965 | } | ||
| 3966 | ); | ||
| 3967 | } | ||
| 3968 | |||
| 3969 | $lc = List::Compare->new( [ @nsec3param_in_answer, @nsec_nsec3_nodata ], [ @nsec_in_response, @nsec3param_nsec_nodata ] ); | ||
| 3970 | my @intersection = $lc->get_intersection; | ||
| 3971 | |||
| 3972 | if ( @intersection ) { | ||
| 3973 | push @results, | ||
| 3974 | _emit_log( | ||
| 3975 | DS10_MIXED_NSEC_NSEC3 => { | ||
| 3976 | ns_list => join( q{;}, uniq sort @intersection ) | ||
| 3977 | } | ||
| 3978 | ); | ||
| 3979 | } | ||
| 3980 | |||
| 3981 | if ( ( scalar @nsec_in_response or @nsec3param_nsec_nodata ) and not scalar @nsec3param_in_answer and not scalar @nsec_nsec3_nodata ) { | ||
| 3982 | push @results, | ||
| 3983 | _emit_log( | ||
| 3984 | DS10_HAS_NSEC => { | ||
| 3985 | ns_list => join( q{;}, uniq sort ( @nsec_in_response, @nsec3param_nsec_nodata ) ) | ||
| 3986 | } | ||
| 3987 | ); | ||
| 3988 | } | ||
| 3989 | |||
| 3990 | if ( ( scalar @nsec3param_in_answer or @nsec_nsec3_nodata ) and not scalar @nsec_in_response and not scalar @nsec3param_nsec_nodata ) { | ||
| 3991 | push @results, | ||
| 3992 | _emit_log( | ||
| 3993 | DS10_HAS_NSEC3 => { | ||
| 3994 | ns_list => join( q{;}, uniq sort ( @nsec3param_in_answer, @nsec_nsec3_nodata ) ) | ||
| 3995 | } | ||
| 3996 | ); | ||
| 3997 | } | ||
| 3998 | |||
| 3999 | @union = ( @nsec3param_in_answer, @nsec_nsec3_nodata ); | ||
| 4000 | my @second_union = ( @nsec_in_response, @nsec3param_nsec_nodata ); | ||
| 4001 | $lc = List::Compare->new( \@union, \@second_union ); | ||
| 4002 | my @first = $lc->get_unique; | ||
| 4003 | my @second = $lc->get_complement; | ||
| 4004 | |||
| 4005 | if ( scalar @first and scalar @second ) { | ||
| 4006 | push @results, | ||
| 4007 | _emit_log( | ||
| 4008 | DS10_INCONSISTENT_NSEC_NSEC3 => { | ||
| 4009 | ns_list => join( q{;}, uniq sort ( @union, @second_union ) ) | ||
| 4010 | } | ||
| 4011 | ); | ||
| 4012 | } | ||
| 4013 | |||
| 4014 | if ( scalar @nsec_incorrect_type_list ) { | ||
| 4015 | push @results, | ||
| 4016 | _emit_log( | ||
| 4017 | DS10_NSEC_ERR_TYPE_LIST => { | ||
| 4018 | ns_list => join( q{;}, uniq sort @nsec_incorrect_type_list ) | ||
| 4019 | } | ||
| 4020 | ); | ||
| 4021 | } | ||
| 4022 | |||
| 4023 | if ( scalar @nsec_mismatches_apex ) { | ||
| 4024 | push @results, | ||
| 4025 | _emit_log( | ||
| 4026 | DS10_NSEC_MISMATCHES_APEX => { | ||
| 4027 | ns_list => join( q{;}, uniq sort @nsec_mismatches_apex ) | ||
| 4028 | } | ||
| 4029 | ); | ||
| 4030 | } | ||
| 4031 | |||
| 4032 | if ( scalar keys %nsec_nodata_wrong_soa ) { | ||
| 4033 | push @results, map { | ||
| 4034 | _emit_log( | ||
| 4035 | DS10_NSEC_NODATA_WRONG_SOA => { | ||
| 4036 | domain => $_, | ||
| 4037 | ns_list => join( q{;}, uniq sort @{ $nsec_nodata_wrong_soa{$_} } ) | ||
| 4038 | } | ||
| 4039 | ) | ||
| 4040 | } keys %nsec_nodata_wrong_soa; | ||
| 4041 | } | ||
| 4042 | |||
| 4043 | if ( scalar @nsec_nodata_missing_soa ) { | ||
| 4044 | push @results, | ||
| 4045 | _emit_log( | ||
| 4046 | DS10_NSEC_NODATA_MISSING_SOA => { | ||
| 4047 | ns_list => join( q{;}, uniq sort @nsec_nodata_missing_soa ) | ||
| 4048 | } | ||
| 4049 | ); | ||
| 4050 | } | ||
| 4051 | |||
| 4052 | if ( scalar @nsec_erroneous_answer ) { | ||
| 4053 | push @results, | ||
| 4054 | _emit_log( | ||
| 4055 | DS10_NSEC_GIVES_ERR_ANSWER => { | ||
| 4056 | ns_list => join( q{;}, uniq sort @nsec_erroneous_answer ) | ||
| 4057 | } | ||
| 4058 | ); | ||
| 4059 | } | ||
| 4060 | |||
| 4061 | if ( scalar @nsec_response_error ) { | ||
| 4062 | push @results, | ||
| 4063 | _emit_log( | ||
| 4064 | DS10_NSEC_QUERY_RESPONSE_ERR => { | ||
| 4065 | ns_list => join( q{;}, uniq sort @nsec_response_error ) | ||
| 4066 | } | ||
| 4067 | ); | ||
| 4068 | } | ||
| 4069 | |||
| 4070 | if ( scalar @nsec3_incorrect_type_list ) { | ||
| 4071 | push @results, | ||
| 4072 | _emit_log( | ||
| 4073 | DS10_NSEC3_ERR_TYPE_LIST => { | ||
| 4074 | ns_list => join( q{;}, uniq sort @nsec3_incorrect_type_list ) | ||
| 4075 | } | ||
| 4076 | ); | ||
| 4077 | } | ||
| 4078 | |||
| 4079 | if ( scalar @nsec3_mismatches_apex ) { | ||
| 4080 | push @results, | ||
| 4081 | _emit_log( | ||
| 4082 | DS10_NSEC3_MISMATCHES_APEX => { | ||
| 4083 | ns_list => join( q{;}, uniq sort @nsec3_mismatches_apex ) | ||
| 4084 | } | ||
| 4085 | ); | ||
| 4086 | } | ||
| 4087 | |||
| 4088 | if ( scalar keys %nsec3_nodata_wrong_soa ) { | ||
| 4089 | push @results, map { | ||
| 4090 | _emit_log( | ||
| 4091 | DS10_NSEC3_NODATA_WRONG_SOA => { | ||
| 4092 | domain => $_, | ||
| 4093 | ns_list => join( q{;}, uniq sort @{ $nsec3_nodata_wrong_soa{$_} } ) | ||
| 4094 | } | ||
| 4095 | ) | ||
| 4096 | } keys %nsec3_nodata_wrong_soa; | ||
| 4097 | } | ||
| 4098 | |||
| 4099 | if ( scalar @nsec3_nodata_missing_soa ) { | ||
| 4100 | push @results, | ||
| 4101 | _emit_log( | ||
| 4102 | DS10_NSEC3_NODATA_MISSING_SOA => { | ||
| 4103 | ns_list => join( q{;}, uniq sort @nsec3_nodata_missing_soa ) | ||
| 4104 | } | ||
| 4105 | ); | ||
| 4106 | } | ||
| 4107 | |||
| 4108 | if ( scalar @nsec3param_erroneous_answer ) { | ||
| 4109 | push @results, | ||
| 4110 | _emit_log( | ||
| 4111 | DS10_NSEC3PARAM_GIVES_ERR_ANSWER => { | ||
| 4112 | ns_list => join( q{;}, uniq sort @nsec3param_erroneous_answer ) | ||
| 4113 | } | ||
| 4114 | ); | ||
| 4115 | } | ||
| 4116 | |||
| 4117 | if ( scalar @nsec3param_mismatches_apex ) { | ||
| 4118 | push @results, | ||
| 4119 | _emit_log( | ||
| 4120 | DS10_NSEC3PARAM_MISMATCHES_APEX => { | ||
| 4121 | ns_list => join( q{;}, uniq sort @nsec3param_mismatches_apex ) | ||
| 4122 | } | ||
| 4123 | ); | ||
| 4124 | } | ||
| 4125 | |||
| 4126 | if ( scalar @nsec3param_response_error ) { | ||
| 4127 | push @results, | ||
| 4128 | _emit_log( | ||
| 4129 | DS10_NSEC3PARAM_QUERY_RESPONSE_ERR => { | ||
| 4130 | ns_list => join( q{;}, uniq sort @nsec3param_response_error ) | ||
| 4131 | } | ||
| 4132 | ); | ||
| 4133 | } | ||
| 4134 | |||
| 4135 | if ( scalar @nsec_missing_signature ) { | ||
| 4136 | push @results, | ||
| 4137 | _emit_log( | ||
| 4138 | DS10_NSEC_MISSING_SIGNATURE => { | ||
| 4139 | ns_list => join( q{;}, uniq sort @nsec_missing_signature ) | ||
| 4140 | } | ||
| 4141 | ); | ||
| 4142 | } | ||
| 4143 | |||
| 4144 | if ( scalar @nsec3_missing_signature ) { | ||
| 4145 | push @results, | ||
| 4146 | _emit_log( | ||
| 4147 | DS10_NSEC3_MISSING_SIGNATURE => { | ||
| 4148 | ns_list => join( q{;}, uniq sort @nsec3_missing_signature ) | ||
| 4149 | } | ||
| 4150 | ); | ||
| 4151 | } | ||
| 4152 | |||
| 4153 | if ( scalar keys %nsec_rrsig_no_dnskey ) { | ||
| 4154 | push @results, map { | ||
| 4155 | _emit_log( | ||
| 4156 | DS10_NSEC_RRSIG_NO_DNSKEY => { | ||
| 4157 | keytag => $_, | ||
| 4158 | ns_list => join( q{;}, uniq sort @{ $nsec_rrsig_no_dnskey{$_} } ) | ||
| 4159 | } | ||
| 4160 | ) | ||
| 4161 | } keys %nsec_rrsig_no_dnskey; | ||
| 4162 | } | ||
| 4163 | |||
| 4164 | if ( scalar keys %nsec_rrsig_expired ) { | ||
| 4165 | push @results, map { | ||
| 4166 | _emit_log( | ||
| 4167 | DS10_NSEC_RRSIG_EXPIRED => { | ||
| 4168 | keytag => $_, | ||
| 4169 | ns_list => join( q{;}, uniq sort @{ $nsec_rrsig_expired{$_} } ) | ||
| 4170 | } | ||
| 4171 | ) | ||
| 4172 | } keys %nsec_rrsig_expired; | ||
| 4173 | } | ||
| 4174 | |||
| 4175 | if ( scalar keys %nsec_rrsig_not_yet_valid ) { | ||
| 4176 | push @results, map { | ||
| 4177 | _emit_log( | ||
| 4178 | DS10_NSEC_RRSIG_NOT_YET_VALID => { | ||
| 4179 | keytag => $_, | ||
| 4180 | ns_list => join( q{;}, uniq sort @{ $nsec_rrsig_not_yet_valid{$_} } ) | ||
| 4181 | } | ||
| 4182 | ) | ||
| 4183 | } keys %nsec_rrsig_not_yet_valid; | ||
| 4184 | } | ||
| 4185 | |||
| 4186 | if ( scalar keys %nsec_rrsig_verify_error ) { | ||
| 4187 | push @results, map { | ||
| 4188 | _emit_log( | ||
| 4189 | DS10_NSEC_RRSIG_VERIFY_ERROR => { | ||
| 4190 | keytag => $_, | ||
| 4191 | ns_list => join( q{;}, uniq sort @{ $nsec_rrsig_verify_error{$_} } ) | ||
| 4192 | } | ||
| 4193 | ) | ||
| 4194 | } keys %nsec_rrsig_verify_error; | ||
| 4195 | } | ||
| 4196 | |||
| 4197 | if ( values %nsec_rrsig_no_dnskey or values %nsec_rrsig_expired or values %nsec_rrsig_not_yet_valid or values %nsec_rrsig_verify_error ) { | ||
| 4198 | my @combined_ns = uniq ( values %nsec_rrsig_no_dnskey, values %nsec_rrsig_expired, values %nsec_rrsig_not_yet_valid, values %nsec_rrsig_verify_error ); | ||
| 4199 | my @ns_list; | ||
| 4200 | |||
| 4201 | foreach my $ns_aref ( @combined_ns ) { | ||
| 4202 | foreach my $ns ( @$ns_aref ) { | ||
| 4203 | push @ns_list, $ns unless grep { $_ eq $ns } @nsec_rrsig_verified; | ||
| 4204 | } | ||
| 4205 | } | ||
| 4206 | |||
| 4207 | push @results, | ||
| 4208 | _emit_log( | ||
| 4209 | DS10_NSEC_NO_VERIFIED_SIGNATURE => { | ||
| 4210 | ns_list => join( q{;}, uniq sort @ns_list ) | ||
| 4211 | } | ||
| 4212 | ) if scalar @ns_list; | ||
| 4213 | } | ||
| 4214 | |||
| 4215 | if ( scalar keys %nsec3_rrsig_no_dnskey ) { | ||
| 4216 | push @results, map { | ||
| 4217 | _emit_log( | ||
| 4218 | DS10_NSEC3_RRSIG_NO_DNSKEY => { | ||
| 4219 | keytag => $_, | ||
| 4220 | ns_list => join( q{;}, uniq sort @{ $nsec3_rrsig_no_dnskey{$_} } ) | ||
| 4221 | } | ||
| 4222 | ) | ||
| 4223 | } keys %nsec3_rrsig_no_dnskey; | ||
| 4224 | } | ||
| 4225 | |||
| 4226 | if ( scalar keys %nsec3_rrsig_expired ) { | ||
| 4227 | push @results, map { | ||
| 4228 | _emit_log( | ||
| 4229 | DS10_NSEC3_RRSIG_EXPIRED => { | ||
| 4230 | keytag => $_, | ||
| 4231 | ns_list => join( q{;}, uniq sort @{ $nsec3_rrsig_expired{$_} } ) | ||
| 4232 | } | ||
| 4233 | ) | ||
| 4234 | } keys %nsec3_rrsig_expired; | ||
| 4235 | } | ||
| 4236 | |||
| 4237 | if ( scalar keys %nsec3_rrsig_not_yet_valid ) { | ||
| 4238 | push @results, map { | ||
| 4239 | _emit_log( | ||
| 4240 | DS10_NSEC3_RRSIG_NOT_YET_VALID => { | ||
| 4241 | keytag => $_, | ||
| 4242 | ns_list => join( q{;}, uniq sort @{ $nsec3_rrsig_not_yet_valid{$_} } ) | ||
| 4243 | } | ||
| 4244 | ) | ||
| 4245 | } keys %nsec3_rrsig_not_yet_valid; | ||
| 4246 | } | ||
| 4247 | |||
| 4248 | if ( scalar keys %nsec3_rrsig_verify_error ) { | ||
| 4249 | push @results, map { | ||
| 4250 | _emit_log( | ||
| 4251 | DS10_NSEC3_RRSIG_VERIFY_ERROR => { | ||
| 4252 | keytag => $_, | ||
| 4253 | ns_list => join( q{;}, uniq sort @{ $nsec3_rrsig_verify_error{$_} } ) | ||
| 4254 | } | ||
| 4255 | ) | ||
| 4256 | } keys %nsec3_rrsig_verify_error; | ||
| 4257 | } | ||
| 4258 | |||
| 4259 | if ( values %nsec3_rrsig_no_dnskey or values %nsec3_rrsig_expired or values %nsec3_rrsig_not_yet_valid or values %nsec3_rrsig_verify_error ) { | ||
| 4260 | my @combined_ns = uniq ( values %nsec3_rrsig_no_dnskey, values %nsec3_rrsig_expired, values %nsec3_rrsig_not_yet_valid, values %nsec3_rrsig_verify_error ); | ||
| 4261 | my @ns_list; | ||
| 4262 | |||
| 4263 | foreach my $ns_aref ( @combined_ns ) { | ||
| 4264 | foreach my $ns ( @$ns_aref ) { | ||
| 4265 | push @ns_list, $ns unless grep { $_ eq $ns } @nsec3_rrsig_verified; | ||
| 4266 | } | ||
| 4267 | } | ||
| 4268 | |||
| 4269 | push @results, | ||
| 4270 | _emit_log( | ||
| 4271 | DS10_NSEC3_NO_VERIFIED_SIGNATURE => { | ||
| 4272 | ns_list => join( q{;}, uniq sort @ns_list ) | ||
| 4273 | } | ||
| 4274 | ) if scalar @ns_list; | ||
| 4275 | } | ||
| 4276 | |||
| 4277 | if ( scalar keys %algo_not_supported_by_zm ) { | ||
| 4278 | foreach my $keytag ( keys %algo_not_supported_by_zm ) { | ||
| 4279 | push @results, map { | ||
| 4280 | _emit_log( | ||
| 4281 | DS10_ALGO_NOT_SUPPORTED_BY_ZM => { | ||
| 4282 | keytag => $keytag, | ||
| 4283 | algo_num => $_, | ||
| 4284 | algo_mnemo => $algo_properties{$_}{mnemonic}, | ||
| 4285 | ns_ip_list => join( q{;}, uniq sort @{ $algo_not_supported_by_zm{$keytag}{$_} } ) | ||
| 4286 | } | ||
| 4287 | ) | ||
| 4288 | } keys %{ $algo_not_supported_by_zm{$keytag} }; | ||
| 4289 | } | ||
| 4290 | } | ||
| 4291 | |||
| 4292 | if ( not scalar @with_dnskey and scalar @without_dnskey ) { | ||
| 4293 | push @results, | ||
| 4294 | _emit_log( | ||
| 4295 | DS10_ZONE_NO_DNSSEC => { | ||
| 4296 | ns_list => join( q{;}, uniq sort @without_dnskey ) | ||
| 4297 | } | ||
| 4298 | ); | ||
| 4299 | } | ||
| 4300 | |||
| 4301 | if ( scalar @with_dnskey and scalar @without_dnskey ) { | ||
| 4302 | push @results, | ||
| 4303 | _emit_log( | ||
| 4304 | DS10_SERVER_NO_DNSSEC => { | ||
| 4305 | ns_list => join( q{;}, uniq sort @without_dnskey ) | ||
| 4306 | } | ||
| 4307 | ); | ||
| 4308 | } | ||
| 4309 | |||
| 4310 | $lc = List::Compare->new( [ @all_ns ], [ @ignored_nss, @without_dnskey, @nsec_in_response, @nsec3param_nsec_nodata, @nsec3param_in_answer, @nsec_nsec3_nodata ] ); | ||
| 4311 | @first = $lc->get_unique; | ||
| 4312 | |||
| 4313 | if ( @first ) { | ||
| 4314 | push @results, | ||
| 4315 | _emit_log( | ||
| 4316 | DS10_EXPECTED_NSEC_NSEC3_MISSING => { | ||
| 4317 | ns_list => join( q{;}, uniq sort @first ) | ||
| 4318 | } | ||
| 4319 | ); | ||
| 4320 | } | ||
| 4321 | |||
| 4322 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 4323 | } ## end sub dnssec10 | ||
| 4324 | |||
| 4325 | =over | ||
| 4326 | |||
| 4327 | =item dnssec11() | ||
| 4328 | |||
| 4329 | my @logentry_array = dnssec11( $zone ); | ||
| 4330 | |||
| 4331 | Runs the L<DNSSEC11 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec11.md>. | ||
| 4332 | |||
| 4333 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 4334 | |||
| 4335 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 4336 | |||
| 4337 | =back | ||
| 4338 | |||
| 4339 | =cut | ||
| 4340 | |||
| 4341 | sub dnssec11 { | ||
| 4342 | my ( $class, $zone ) = @_; | ||
| 4343 | |||
| 4344 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC11'; | ||
| 4345 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 4346 | my @undetermined_ds; | ||
| 4347 | my @no_ds_record; | ||
| 4348 | my @has_ds_record; | ||
| 4349 | my $continue_with_child_tests = 1; | ||
| 4350 | |||
| 4351 | my $parent = Zonemaster::Engine::TestMethods->method1( $zone ); | ||
| 4352 | my @nss_parent = @{ $parent->ns }; | ||
| 4353 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_parent; | ||
| 4354 | my %ip_already_processed; | ||
| 4355 | |||
| 4356 | my $is_undelegated = Zonemaster::Engine::Recursor->has_fake_addresses( $zone->name->string ); | ||
| 4357 | |||
| 4358 | for my $nss_key ( sort keys %nss ) { | ||
| 4359 | my $ns = $nss{$nss_key}; | ||
| 4360 | |||
| 4361 | if ( $is_undelegated ){ | ||
| 4362 | if ( not $ns->fake_ds->{$zone->name->string} ){ | ||
| 4363 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 4364 | } | ||
| 4365 | last; | ||
| 4366 | } | ||
| 4367 | |||
| 4368 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 4369 | $ip_already_processed{$ns->address->short} = 1; | ||
| 4370 | |||
| 4371 | if ( _ip_disabled_message( \@results, $ns, q{DS} ) ) { | ||
| 4372 | next; | ||
| 4373 | } | ||
| 4374 | |||
| 4375 | my $ds_p = $ns->query( $zone->name, q{DS}, { dnssec => 1, usevc => 0 } ); | ||
| 4376 | if ( $ds_p and $ds_p->tc ) { | ||
| 4377 | $ds_p = $ns->query( $zone->name, q{DS}, { dnssec => 1, usevc => 1 } ); | ||
| 4378 | } | ||
| 4379 | |||
| 4380 | if ( not $ds_p or $ds_p->rcode ne q{NOERROR} or not $ds_p->aa ) { | ||
| 4381 | push @undetermined_ds, $ns->address->short; | ||
| 4382 | next; | ||
| 4383 | } | ||
| 4384 | my @ds = $ds_p->get_records_for_name( q{DS}, $zone->name->string, q{answer} ); | ||
| 4385 | if ( not scalar @ds ) { | ||
| 4386 | push @no_ds_record, $ns->address->short; | ||
| 4387 | } | ||
| 4388 | else { | ||
| 4389 | push @has_ds_record, $ns->address->short; | ||
| 4390 | } | ||
| 4391 | } | ||
| 4392 | undef %ip_already_processed; | ||
| 4393 | |||
| 4394 | if ( scalar @undetermined_ds and not scalar @no_ds_record and not scalar @has_ds_record ) { | ||
| 4395 | push @results, _emit_log( DS11_UNDETERMINED_DS => {} ); | ||
| 4396 | $continue_with_child_tests = 0; | ||
| 4397 | } | ||
| 4398 | elsif ( scalar @no_ds_record and not scalar @has_ds_record ) { | ||
| 4399 | $continue_with_child_tests = 0; | ||
| 4400 | } | ||
| 4401 | elsif ( scalar @no_ds_record and scalar @has_ds_record ) { | ||
| 4402 | push @results, _emit_log( DS11_INCONSISTENT_DS => {} ); | ||
| 4403 | push @results, | ||
| 4404 | _emit_log( | ||
| 4405 | DS11_PARENT_WITHOUT_DS => { | ||
| 4406 | ns_ip_list => join( q{;}, sort @no_ds_record ) | ||
| 4407 | } | ||
| 4408 | ); | ||
| 4409 | push @results, | ||
| 4410 | _emit_log( | ||
| 4411 | DS11_PARENT_WITH_DS => { | ||
| 4412 | ns_ip_list => join( q{;}, sort @has_ds_record ) | ||
| 4413 | } | ||
| 4414 | ); | ||
| 4415 | } | ||
| 4416 | |||
| 4417 | if ( $continue_with_child_tests ) { | ||
| 4418 | my @query_types = qw{SOA DNSKEY}; | ||
| 4419 | my @undetermined_dnskey; | ||
| 4420 | my @no_dnskey_record; | ||
| 4421 | my @has_dnskey_record; | ||
| 4422 | |||
| 4423 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 4424 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 4425 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 4426 | my %ip_already_processed; | ||
| 4427 | |||
| 4428 | for my $nss_key ( sort keys %nss ) { | ||
| 4429 | my $ns = $nss{$nss_key}; | ||
| 4430 | |||
| 4431 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 4432 | $ip_already_processed{$ns->address->short} = 1; | ||
| 4433 | |||
| 4434 | if ( _ip_disabled_message( \@results, $ns, @query_types ) ) { | ||
| 4435 | next; | ||
| 4436 | } | ||
| 4437 | |||
| 4438 | my $soa_p = $ns->query( $zone->name, q{SOA}, { usevc => 0 } ); | ||
| 4439 | if ( not $soa_p ) { | ||
| 4440 | next; | ||
| 4441 | } | ||
| 4442 | if ( $soa_p->rcode ne q{NOERROR} ) { | ||
| 4443 | next; | ||
| 4444 | } | ||
| 4445 | if ( not $soa_p->aa ) { | ||
| 4446 | next; | ||
| 4447 | } | ||
| 4448 | my @soa = $soa_p->get_records_for_name( q{SOA}, $zone->name->string, q{answer} ); | ||
| 4449 | if ( not scalar @soa ) { | ||
| 4450 | next; | ||
| 4451 | } | ||
| 4452 | |||
| 4453 | my $dnskey_p = $ns->query( $zone->name, q{DNSKEY}, { usevc => 0 } ); | ||
| 4454 | if ( $dnskey_p and $dnskey_p->tc ) { | ||
| 4455 | $dnskey_p = $ns->query( $zone->name, q{DNSKEY}, { usevc => 1 } ); | ||
| 4456 | } | ||
| 4457 | |||
| 4458 | if ( not $dnskey_p or $dnskey_p->rcode ne q{NOERROR} or not $dnskey_p->aa ) { | ||
| 4459 | push @undetermined_dnskey, $ns->address->short; | ||
| 4460 | next; | ||
| 4461 | } | ||
| 4462 | my @dnskey = $dnskey_p->get_records_for_name( q{DNSKEY}, $zone->name->string, q{answer} ); | ||
| 4463 | if ( not scalar @dnskey ) { | ||
| 4464 | push @no_dnskey_record, $ns->address->short; | ||
| 4465 | } | ||
| 4466 | else { | ||
| 4467 | push @has_dnskey_record, $ns->address->short; | ||
| 4468 | } | ||
| 4469 | } | ||
| 4470 | undef %ip_already_processed; | ||
| 4471 | |||
| 4472 | if ( scalar @undetermined_dnskey and not scalar @no_dnskey_record and not scalar @has_dnskey_record ) { | ||
| 4473 | push @results, _emit_log( DS11_UNDETERMINED_SIGNED_ZONE => {} ); | ||
| 4474 | } | ||
| 4475 | elsif ( scalar @no_dnskey_record and not scalar @has_dnskey_record ) { | ||
| 4476 | push @results, _emit_log( DS11_DS_BUT_UNSIGNED_ZONE => {} ); | ||
| 4477 | } | ||
| 4478 | elsif ( scalar @no_dnskey_record and scalar @has_dnskey_record ) { | ||
| 4479 | push @results, _emit_log( DS11_INCONSISTENT_SIGNED_ZONE => {} ); | ||
| 4480 | push @results, | ||
| 4481 | _emit_log( | ||
| 4482 | DS11_NS_WITH_UNSIGNED_ZONE => { | ||
| 4483 | ns_ip_list => join( q{;}, sort @no_dnskey_record ) | ||
| 4484 | } | ||
| 4485 | ); | ||
| 4486 | push @results, | ||
| 4487 | _emit_log( | ||
| 4488 | DS11_NS_WITH_SIGNED_ZONE => { | ||
| 4489 | ns_ip_list => join( q{;}, sort @has_dnskey_record ) | ||
| 4490 | } | ||
| 4491 | ); | ||
| 4492 | } | ||
| 4493 | } | ||
| 4494 | |||
| 4495 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 4496 | } ## end sub dnssec11 | ||
| 4497 | |||
| 4498 | =over | ||
| 4499 | |||
| 4500 | =item dnssec13() | ||
| 4501 | |||
| 4502 | my @logentry_array = dnssec13( $zone ); | ||
| 4503 | |||
| 4504 | Runs the L<DNSSEC13 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec13.md>. | ||
| 4505 | |||
| 4506 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 4507 | |||
| 4508 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 4509 | |||
| 4510 | =back | ||
| 4511 | |||
| 4512 | =cut | ||
| 4513 | |||
| 4514 | sub dnssec13 { | ||
| 4515 | my ( $class, $zone ) = @_; | ||
| 4516 | |||
| 4517 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC13'; | ||
| 4518 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 4519 | my @query_types = qw{DNSKEY SOA NS}; | ||
| 4520 | my %algo_not_signed; | ||
| 4521 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 4522 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 4523 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 4524 | my %ip_already_processed; | ||
| 4525 | |||
| 4526 | for my $nss_key ( sort keys %nss ) { | ||
| 4527 | my $ns = $nss{$nss_key}; | ||
| 4528 | |||
| 4529 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 4530 | $ip_already_processed{$ns->address->short} = 1; | ||
| 4531 | |||
| 4532 | if ( _ip_disabled_message( \@results, $ns, @query_types ) ) { | ||
| 4533 | next; | ||
| 4534 | } | ||
| 4535 | |||
| 4536 | my %dnskey_algorithm; | ||
| 4537 | foreach my $query_type ( @query_types ) { | ||
| 4538 | |||
| 4539 | my $p = $ns->query( $zone->name, $query_type, { dnssec => 1, usevc => 0 } ); | ||
| 4540 | if ( not $p ) { | ||
| 4541 | next; | ||
| 4542 | } | ||
| 4543 | if ( $p->rcode ne q{NOERROR} ) { | ||
| 4544 | next; | ||
| 4545 | } | ||
| 4546 | if ( not $p->aa ) { | ||
| 4547 | next; | ||
| 4548 | } | ||
| 4549 | my @type_records = $p->get_records( $query_type, q{answer} ); | ||
| 4550 | if ( not scalar @type_records ) { | ||
| 4551 | next; | ||
| 4552 | } | ||
| 4553 | my @rrsig_records = $p->get_records( q{RRSIG} , q{answer} ); | ||
| 4554 | if ( not scalar @rrsig_records ) { | ||
| 4555 | next; | ||
| 4556 | } | ||
| 4557 | |||
| 4558 | if ( $query_type eq q{DNSKEY} ) { | ||
| 4559 | %dnskey_algorithm = map { $_->algorithm => 1 } @type_records; | ||
| 4560 | } | ||
| 4561 | foreach my $algorithm ( keys %dnskey_algorithm ) { | ||
| 4562 | if ( not scalar grep { $_->algorithm == $algorithm } @rrsig_records ) { | ||
| 4563 | push @{ $algo_not_signed{ lc($query_type) }{$algorithm} }, $ns->address->short; | ||
| 4564 | } | ||
| 4565 | } | ||
| 4566 | } | ||
| 4567 | } | ||
| 4568 | |||
| 4569 | foreach my $query_type ( @query_types ) { | ||
| 4570 | if ( exists $algo_not_signed{ lc($query_type) } ) { | ||
| 4571 | foreach my $algorithm ( keys %{ $algo_not_signed{ lc($query_type) } } ) { | ||
| 4572 | push @results, | ||
| 4573 | _emit_log( | ||
| 4574 | "DS13_ALGO_NOT_SIGNED_${query_type}" => { | ||
| 4575 | ns_ip_list => join( q{;}, uniq sort @{ $algo_not_signed{ lc($query_type) }{$algorithm} }), | ||
| 4576 | algo_num => $algorithm, | ||
| 4577 | algo_mnemo => $algo_properties{$algorithm}{mnemonic} | ||
| 4578 | } | ||
| 4579 | ); | ||
| 4580 | } | ||
| 4581 | } | ||
| 4582 | } | ||
| 4583 | |||
| 4584 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 4585 | } ## end sub dnssec13 | ||
| 4586 | |||
| 4587 | =over | ||
| 4588 | |||
| 4589 | =item dnssec14() | ||
| 4590 | |||
| 4591 | my @logentry_array = dnssec14( $zone ); | ||
| 4592 | |||
| 4593 | Runs the L<DNSSEC14 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec14.md>. | ||
| 4594 | |||
| 4595 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 4596 | |||
| 4597 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 4598 | |||
| 4599 | =back | ||
| 4600 | |||
| 4601 | =cut | ||
| 4602 | |||
| 4603 | sub dnssec14 { | ||
| 4604 | my ( $class, $zone ) = @_; | ||
| 4605 | |||
| 4606 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC14'; | ||
| 4607 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 4608 | my @dnskey_rrs; | ||
| 4609 | |||
| 4610 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 4611 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 4612 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 4613 | |||
| 4614 | for my $nss_key ( sort keys %nss ) { | ||
| 4615 | my $ns = $nss{$nss_key}; | ||
| 4616 | |||
| 4617 | if ( _ip_disabled_message( \@results, $ns, q{DNSKEY} ) ) { | ||
| 4618 | next; | ||
| 4619 | } | ||
| 4620 | |||
| 4621 | my $dnskey_p = $ns->query( $zone->name, 'DNSKEY', { dnssec => 1, usevc => 0 } ); | ||
| 4622 | if ( not $dnskey_p ) { | ||
| 4623 | push @results, _emit_log( NO_RESPONSE => { ns => $ns->string } ); | ||
| 4624 | next; | ||
| 4625 | } | ||
| 4626 | |||
| 4627 | my @keys = $dnskey_p->get_records( 'DNSKEY', 'answer' ); | ||
| 4628 | if ( not @keys ) { | ||
| 4629 | push @results, _emit_log( NO_RESPONSE_DNSKEY => { ns => $ns->string } ); | ||
| 4630 | next; | ||
| 4631 | } else { | ||
| 4632 | push @dnskey_rrs, @keys; | ||
| 4633 | } | ||
| 4634 | } | ||
| 4635 | |||
| 4636 | my %investigated_keys; | ||
| 4637 | foreach my $key ( @dnskey_rrs ) { | ||
| 4638 | my $algo = $key->algorithm; | ||
| 4639 | |||
| 4640 | next if not exists $rsa_key_size_details{$algo}; | ||
| 4641 | |||
| 4642 | # Only test once per keytag, keysize and algorithm | ||
| 4643 | my $key_ref = join ':', $key->keytag, $key->keysize, $algo; | ||
| 4644 | next if exists $investigated_keys{$key_ref}; | ||
| 4645 | |||
| 4646 | my $algo_args = { | ||
| 4647 | algo_num => $algo, | ||
| 4648 | algo_descr => $algo_properties{$algo}{description}, | ||
| 4649 | keytag => $key->keytag, | ||
| 4650 | keysize => $key->keysize, | ||
| 4651 | keysizemin => $rsa_key_size_details{$algo}{min_size}, | ||
| 4652 | keysizemax => $rsa_key_size_details{$algo}{max_size}, | ||
| 4653 | keysizerec => $rsa_key_size_details{$algo}{rec_size}, | ||
| 4654 | }; | ||
| 4655 | |||
| 4656 | if ( $key->keysize < $rsa_key_size_details{$algo}{min_size} ) { | ||
| 4657 | push @results, _emit_log( DNSKEY_TOO_SMALL_FOR_ALGO => $algo_args ); | ||
| 4658 | } | ||
| 4659 | |||
| 4660 | if ( $key->keysize < $rsa_key_size_details{$algo}{rec_size} ) { | ||
| 4661 | push @results, _emit_log( DNSKEY_SMALLER_THAN_REC => $algo_args ); | ||
| 4662 | } | ||
| 4663 | |||
| 4664 | if ( $key->keysize > $rsa_key_size_details{$algo}{max_size} ) { | ||
| 4665 | push @results, _emit_log( DNSKEY_TOO_LARGE_FOR_ALGO => $algo_args ); | ||
| 4666 | } | ||
| 4667 | |||
| 4668 | $investigated_keys{$key_ref} = 1; | ||
| 4669 | |||
| 4670 | } ## end foreach my $key ( @keys ) | ||
| 4671 | |||
| 4672 | if ( scalar @dnskey_rrs and scalar @results == scalar grep { $_->tag eq 'NO_RESPONSE' } @results) { | ||
| 4673 | push @results, _emit_log( KEY_SIZE_OK => {} ); | ||
| 4674 | } | ||
| 4675 | |||
| 4676 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 4677 | } ## end sub dnssec14 | ||
| 4678 | |||
| 4679 | =over | ||
| 4680 | |||
| 4681 | =item dnssec15() | ||
| 4682 | |||
| 4683 | my @logentry_array = dnssec15( $zone ); | ||
| 4684 | |||
| 4685 | Runs the L<DNSSEC15 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec15.md>. | ||
| 4686 | |||
| 4687 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 4688 | |||
| 4689 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 4690 | |||
| 4691 | =back | ||
| 4692 | |||
| 4693 | =cut | ||
| 4694 | |||
| 4695 | sub dnssec15 { | ||
| 4696 | my ( $class, $zone ) = @_; | ||
| 4697 | |||
| 4698 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC15'; | ||
| 4699 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 4700 | |||
| 4701 | my @query_types = qw{CDS CDNSKEY}; | ||
| 4702 | my %cds_rrsets; | ||
| 4703 | my %cdnskey_rrsets; | ||
| 4704 | my %mismatch_cds_cdnskey; | ||
| 4705 | my %has_cds_no_cdnskey; | ||
| 4706 | my %has_cdnskey_no_cds; | ||
| 4707 | my %has_cds_and_cdnskey; | ||
| 4708 | |||
| 4709 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 4710 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 4711 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 4712 | my %ip_already_processed; | ||
| 4713 | |||
| 4714 | for my $nss_key ( sort keys %nss ) { | ||
| 4715 | my $ns = $nss{$nss_key}; | ||
| 4716 | |||
| 4717 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 4718 | $ip_already_processed{$ns->address->short} = 1; | ||
| 4719 | |||
| 4720 | if ( _ip_disabled_message( \@results, $ns, @query_types ) ) { | ||
| 4721 | next; | ||
| 4722 | } | ||
| 4723 | |||
| 4724 | my $cds_p = $ns->query( $zone->name, q{CDS}, { dnssec => 1, usevc => 0 } ); | ||
| 4725 | if ( not $cds_p ) { | ||
| 4726 | next; | ||
| 4727 | } | ||
| 4728 | if ( not $cds_p->aa ) { | ||
| 4729 | next; | ||
| 4730 | } | ||
| 4731 | if ( $cds_p->rcode ne q{NOERROR} ) { | ||
| 4732 | next; | ||
| 4733 | } | ||
| 4734 | my @cds_records = $cds_p->get_records( q{CDS}, q{answer} ); | ||
| 4735 | push @{ $cds_rrsets{ $ns->address->short } }, @cds_records; | ||
| 4736 | |||
| 4737 | my $cdnskey_p = $ns->query( $zone->name, q{CDNSKEY}, { dnssec => 1, usevc => 0 } ); | ||
| 4738 | if ( not $cdnskey_p ) { | ||
| 4739 | next; | ||
| 4740 | } | ||
| 4741 | if ( not $cdnskey_p->aa ) { | ||
| 4742 | next; | ||
| 4743 | } | ||
| 4744 | if ( $cdnskey_p->rcode ne q{NOERROR} ) { | ||
| 4745 | next; | ||
| 4746 | } | ||
| 4747 | my @cdnskey_records = $cdnskey_p->get_records( q{CDNSKEY}, q{answer} ); | ||
| 4748 | push @{ $cdnskey_rrsets{ $ns->address->short } }, @cdnskey_records; | ||
| 4749 | } | ||
| 4750 | undef %ip_already_processed; | ||
| 4751 | |||
| 4752 | my $no_cds_cdnskey = 1; | ||
| 4753 | for my $ns_ip ( keys %cds_rrsets ) { | ||
| 4754 | if ( scalar @{ $cds_rrsets{ $ns_ip } } ) { | ||
| 4755 | $no_cds_cdnskey = 0; | ||
| 4756 | } | ||
| 4757 | } | ||
| 4758 | for my $ns_ip ( keys %cdnskey_rrsets ) { | ||
| 4759 | if ( scalar @{ $cdnskey_rrsets{ $ns_ip } } ) { | ||
| 4760 | $no_cds_cdnskey = 0; | ||
| 4761 | } | ||
| 4762 | } | ||
| 4763 | |||
| 4764 | if ( $no_cds_cdnskey ) { | ||
| 4765 | push @results, _emit_log( DS15_NO_CDS_CDNSKEY => {} ); | ||
| 4766 | } | ||
| 4767 | else { | ||
| 4768 | for my $ns_ip ( keys %cds_rrsets ) { | ||
| 4769 | |||
| 4770 | if ( not exists $cdnskey_rrsets{ $ns_ip } ) { | ||
| 4771 | next; | ||
| 4772 | } | ||
| 4773 | |||
| 4774 | if ( | ||
| 4775 | scalar @{ $cds_rrsets{ $ns_ip } } | ||
| 4776 | and not scalar @{ $cdnskey_rrsets{ $ns_ip } } | ||
| 4777 | ) | ||
| 4778 | { | ||
| 4779 | $has_cds_no_cdnskey{ $ns_ip } = 1; | ||
| 4780 | } | ||
| 4781 | elsif ( | ||
| 4782 | scalar @{ $cdnskey_rrsets{ $ns_ip } } | ||
| 4783 | and not scalar @{ $cds_rrsets{ $ns_ip } } | ||
| 4784 | ) | ||
| 4785 | { | ||
| 4786 | $has_cdnskey_no_cds{ $ns_ip } = 1; | ||
| 4787 | } | ||
| 4788 | elsif ( | ||
| 4789 | scalar @{ $cds_rrsets{ $ns_ip } } | ||
| 4790 | and scalar @{ $cdnskey_rrsets{ $ns_ip } } | ||
| 4791 | ) | ||
| 4792 | { | ||
| 4793 | $has_cds_and_cdnskey{ $ns_ip } = 1; | ||
| 4794 | } | ||
| 4795 | } | ||
| 4796 | |||
| 4797 | for my $ns_ip ( keys %cds_rrsets ) { | ||
| 4798 | if ( | ||
| 4799 | scalar @{ $cds_rrsets{ $ns_ip } } | ||
| 4800 | and exists $cdnskey_rrsets{ $ns_ip } | ||
| 4801 | and scalar @{ $cdnskey_rrsets{ $ns_ip } } | ||
| 4802 | ) | ||
| 4803 | { | ||
| 4804 | # | ||
| 4805 | # Quick hack. Proper fix should be available in LDNS 1.8.5: https://github.com/NLnetLabs/ldns/commit/b39813870a5fb0f4e8ff1570b3b09416aaee716c | ||
| 4806 | # | ||
| 4807 | my @dnskey; | ||
| 4808 | foreach my $cdnskey ( @{ $cdnskey_rrsets{ $ns_ip } } ) { | ||
| 4809 | my $rr_string = $cdnskey->string; | ||
| 4810 | $rr_string =~ s/\s+CDNSKEY\s+/ DNSKEY /; | ||
| 4811 | push @dnskey, Zonemaster::LDNS::RR->new( $rr_string ); | ||
| 4812 | } | ||
| 4813 | |||
| 4814 | foreach my $cds ( @{ $cds_rrsets{ $ns_ip } } ) { | ||
| 4815 | my @matching_keys = grep { $cds->keytag == $_->keytag or ($cds->algorithm == 0 and $_->algorithm == 0)} @dnskey; | ||
| 4816 | if ( not scalar @matching_keys ) { | ||
| 4817 | $mismatch_cds_cdnskey{ $ns_ip } = 1; | ||
| 4818 | } | ||
| 4819 | } | ||
| 4820 | |||
| 4821 | foreach my $dnskey ( @dnskey ) { | ||
| 4822 | my @matching_keys = grep { $dnskey->keytag == $_->keytag or ($dnskey->algorithm == 0 and $_->algorithm == 0)} @{ $cds_rrsets{ $ns_ip } }; | ||
| 4823 | if ( not scalar @matching_keys ) { | ||
| 4824 | $mismatch_cds_cdnskey{ $ns_ip } = 1; | ||
| 4825 | } | ||
| 4826 | } | ||
| 4827 | } | ||
| 4828 | } | ||
| 4829 | |||
| 4830 | if ( scalar keys %has_cds_no_cdnskey ) { | ||
| 4831 | push @results, | ||
| 4832 | _emit_log( | ||
| 4833 | DS15_HAS_CDS_NO_CDNSKEY => { | ||
| 4834 | ns_ip_list => join( q{;}, sort keys %has_cds_no_cdnskey ) | ||
| 4835 | } | ||
| 4836 | ); | ||
| 4837 | } | ||
| 4838 | |||
| 4839 | if ( scalar keys %has_cdnskey_no_cds ) { | ||
| 4840 | push @results, | ||
| 4841 | _emit_log( | ||
| 4842 | DS15_HAS_CDNSKEY_NO_CDS => { | ||
| 4843 | ns_ip_list => join( q{;}, sort keys %has_cdnskey_no_cds ) | ||
| 4844 | } | ||
| 4845 | ); | ||
| 4846 | } | ||
| 4847 | |||
| 4848 | if ( scalar keys %has_cds_and_cdnskey ) { | ||
| 4849 | push @results, | ||
| 4850 | _emit_log( | ||
| 4851 | DS15_HAS_CDS_AND_CDNSKEY => { | ||
| 4852 | ns_ip_list => join( q{;}, sort keys %has_cds_and_cdnskey ) | ||
| 4853 | } | ||
| 4854 | ); | ||
| 4855 | } | ||
| 4856 | |||
| 4857 | my $first = 1; | ||
| 4858 | my $first_rrlist; | ||
| 4859 | my $inconsistent_rrset = 0; | ||
| 4860 | for my $ns_ip ( keys %cds_rrsets ) { | ||
| 4861 | if ( $first ) { | ||
| 4862 | $first_rrlist = Zonemaster::LDNS::RRList->new( $cds_rrsets{ $ns_ip } ); | ||
| 4863 | $first = 0; | ||
| 4864 | next; | ||
| 4865 | } | ||
| 4866 | |||
| 4867 | my $rrlist = Zonemaster::LDNS::RRList->new( $cds_rrsets{ $ns_ip } ); | ||
| 4868 | |||
| 4869 | if ( $rrlist ne $first_rrlist ) { | ||
| 4870 | $inconsistent_rrset = 1; | ||
| 4871 | last; | ||
| 4872 | } | ||
| 4873 | } | ||
| 4874 | |||
| 4875 | push @results, _emit_log( DS15_INCONSISTENT_CDS => {} ) if $inconsistent_rrset; | ||
| 4876 | |||
| 4877 | $first = 1; | ||
| 4878 | $inconsistent_rrset = 0; | ||
| 4879 | for my $ns_ip ( keys %cdnskey_rrsets ) { | ||
| 4880 | if ( $first ) { | ||
| 4881 | $first_rrlist = Zonemaster::LDNS::RRList->new( $cdnskey_rrsets{ $ns_ip } ); | ||
| 4882 | $first = 0; | ||
| 4883 | next; | ||
| 4884 | } | ||
| 4885 | |||
| 4886 | my $rrlist = Zonemaster::LDNS::RRList->new( $cdnskey_rrsets{ $ns_ip } ); | ||
| 4887 | |||
| 4888 | if ( $rrlist ne $first_rrlist ) { | ||
| 4889 | $inconsistent_rrset = 1; | ||
| 4890 | last; | ||
| 4891 | } | ||
| 4892 | } | ||
| 4893 | |||
| 4894 | push @results, _emit_log( DS15_INCONSISTENT_CDNSKEY => {} ) if $inconsistent_rrset; | ||
| 4895 | |||
| 4896 | if ( scalar keys %mismatch_cds_cdnskey ) { | ||
| 4897 | push @results, | ||
| 4898 | _emit_log( | ||
| 4899 | DS15_MISMATCH_CDS_CDNSKEY => { | ||
| 4900 | ns_ip_list => join( q{;}, sort keys %mismatch_cds_cdnskey ) | ||
| 4901 | } | ||
| 4902 | ); | ||
| 4903 | } | ||
| 4904 | } | ||
| 4905 | |||
| 4906 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 4907 | } ## end sub dnssec15 | ||
| 4908 | |||
| 4909 | =over | ||
| 4910 | |||
| 4911 | =item dnssec16() | ||
| 4912 | |||
| 4913 | my @logentry_array = dnssec16( $zone ); | ||
| 4914 | |||
| 4915 | Runs the L<DNSSEC16 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec16.md>. | ||
| 4916 | |||
| 4917 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 4918 | |||
| 4919 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 4920 | |||
| 4921 | =back | ||
| 4922 | |||
| 4923 | =cut | ||
| 4924 | |||
| 4925 | sub dnssec16 { | ||
| 4926 | my ( $class, $zone ) = @_; | ||
| 4927 | |||
| 4928 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC16'; | ||
| 4929 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 4930 | my @query_types = qw{CDS DNSKEY}; | ||
| 4931 | my %cds_rrsets; | ||
| 4932 | my %dnskey_rrsets; | ||
| 4933 | my %no_dnskey_rrset; | ||
| 4934 | my %mixed_delete_cds; | ||
| 4935 | my %delete_cds; | ||
| 4936 | my %no_match_cds_with_dnskey; | ||
| 4937 | my %cds_points_to_non_zone_dnskey; | ||
| 4938 | my %cds_points_to_non_sep_dnskey; | ||
| 4939 | my %dnskey_not_signed_by_cds; | ||
| 4940 | my %cds_not_signed_by_cds; | ||
| 4941 | my %cds_not_signed; | ||
| 4942 | my %cds_signed_by_unknown_dnskey; | ||
| 4943 | my %cds_invalid_rrsig; | ||
| 4944 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 4945 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 4946 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 4947 | my %ip_already_processed; | ||
| 4948 | my $testing_time = time; | ||
| 4949 | |||
| 4950 | for my $nss_key ( sort keys %nss ) { | ||
| 4951 | my $ns = $nss{$nss_key}; | ||
| 4952 | |||
| 4953 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 4954 | $ip_already_processed{$ns->address->short} = 1; | ||
| 4955 | |||
| 4956 | if ( _ip_disabled_message( \@results, $ns, @query_types ) ) { | ||
| 4957 | next; | ||
| 4958 | } | ||
| 4959 | |||
| 4960 | my $cds_p = $ns->query( $zone->name, q{CDS}, { dnssec => 1, usevc => 0 } ); | ||
| 4961 | if ( not $cds_p ) { | ||
| 4962 | next; | ||
| 4963 | } | ||
| 4964 | if ( not $cds_p->aa ) { | ||
| 4965 | next; | ||
| 4966 | } | ||
| 4967 | if ( $cds_p->rcode ne q{NOERROR} ) { | ||
| 4968 | next; | ||
| 4969 | } | ||
| 4970 | my @cds_records = $cds_p->get_records( q{CDS}, q{answer} ); | ||
| 4971 | if ( not scalar @cds_records ) { | ||
| 4972 | next; | ||
| 4973 | } | ||
| 4974 | my @cds_rrsig_records = $cds_p->get_records( q{RRSIG} , q{answer} ); | ||
| 4975 | push @{ $cds_rrsets{ $ns->address->short }{cds} }, @cds_records; | ||
| 4976 | push @{ $cds_rrsets{ $ns->address->short }{rrsig} }, @cds_rrsig_records; | ||
| 4977 | foreach my $cds ( @{ $cds_rrsets{ $ns->address->short }{cds} } ) { | ||
| 4978 | my $rr_string = $cds->string; | ||
| 4979 | $rr_string =~ s/\s+CDS\s+/ DS /; | ||
| 4980 | push @{ $cds_rrsets{ $ns->address->short }{ds} }, Zonemaster::LDNS::RR->new( $rr_string ); | ||
| 4981 | } | ||
| 4982 | |||
| 4983 | my $dnskey_p = $ns->query( $zone->name, q{DNSKEY}, { dnssec => 1, usevc => 0 } ); | ||
| 4984 | if ( not $dnskey_p ) { | ||
| 4985 | next; | ||
| 4986 | } | ||
| 4987 | if ( not $dnskey_p->aa ) { | ||
| 4988 | next; | ||
| 4989 | } | ||
| 4990 | if ( $dnskey_p->rcode ne q{NOERROR} ) { | ||
| 4991 | next; | ||
| 4992 | } | ||
| 4993 | my @dnskey_records = $dnskey_p->get_records( q{DNSKEY}, q{answer} ); | ||
| 4994 | if ( not scalar @dnskey_records ) { | ||
| 4995 | next; | ||
| 4996 | } | ||
| 4997 | my @dnskey_rrsig_records = $dnskey_p->get_records( q{RRSIG} , q{answer} ); | ||
| 4998 | push @{ $dnskey_rrsets{ $ns->address->short }{dnskey} }, @dnskey_records; | ||
| 4999 | push @{ $dnskey_rrsets{ $ns->address->short }{rrsig} }, @dnskey_rrsig_records; | ||
| 5000 | $testing_time = $dnskey_p->timestamp; | ||
| 5001 | |||
| 5002 | } | ||
| 5003 | undef %ip_already_processed; | ||
| 5004 | |||
| 5005 | if ( scalar keys %cds_rrsets ) { | ||
| 5006 | for my $ns_ip ( keys %cds_rrsets ) { | ||
| 5007 | if ( not scalar @{ $cds_rrsets{ $ns_ip }{cds} } ) { | ||
| 5008 | next; | ||
| 5009 | } | ||
| 5010 | if ( scalar grep { $_->algorithm == 0 } @{ $cds_rrsets{ $ns_ip }{ds} } ) { | ||
| 5011 | if ( scalar grep { $_->algorithm != 0 } @{ $cds_rrsets{ $ns_ip }{ds} } ) { | ||
| 5012 | $mixed_delete_cds{ $ns_ip } = 1; | ||
| 5013 | } | ||
| 5014 | else { | ||
| 5015 | $delete_cds{ $ns_ip } = 1; | ||
| 5016 | } | ||
| 5017 | next; | ||
| 5018 | } | ||
| 5019 | if ( not defined $dnskey_rrsets{ $ns_ip }{dnskey} or not scalar @{ $dnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5020 | $no_dnskey_rrset{ $ns_ip } = 1; | ||
| 5021 | next; | ||
| 5022 | } | ||
| 5023 | foreach my $ds ( @{ $cds_rrsets{ $ns_ip }{ds} } ) { | ||
| 5024 | next if $ds->algorithm == 0; | ||
| 5025 | if ( not scalar grep { $ds->keytag == $_->keytag } @{ $dnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5026 | push @{ $no_match_cds_with_dnskey{ $ds->keytag } }, $ns_ip; | ||
| 5027 | } | ||
| 5028 | elsif ( scalar grep { $ds->keytag == $_->keytag and not $_->flags & 256 } @{ $dnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5029 | push @{ $cds_points_to_non_zone_dnskey{ $ds->keytag } }, $ns_ip; | ||
| 5030 | } | ||
| 5031 | else { | ||
| 5032 | if ( not scalar grep { $ds->keytag == $_->keytag } @{ $dnskey_rrsets{ $ns_ip }{rrsig} } ) { | ||
| 5033 | push @{ $dnskey_not_signed_by_cds{ $ds->keytag } }, $ns_ip; | ||
| 5034 | } | ||
| 5035 | if ( not scalar grep { $ds->keytag == $_->keytag } @{ $cds_rrsets{ $ns_ip }{rrsig} } ) { | ||
| 5036 | push @{ $cds_not_signed_by_cds{ $ds->keytag } }, $ns_ip; | ||
| 5037 | } | ||
| 5038 | if ( scalar grep { $ds->keytag == $_->keytag and not $_->flags & 1 } @{ $dnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5039 | push @{ $cds_points_to_non_sep_dnskey{ $ds->keytag } }, $ns_ip; | ||
| 5040 | } | ||
| 5041 | } | ||
| 5042 | } | ||
| 5043 | if ( not scalar @{ $cds_rrsets{ $ns_ip }{rrsig} } ) { | ||
| 5044 | $cds_not_signed{ $ns_ip } = 1; | ||
| 5045 | } | ||
| 5046 | else { | ||
| 5047 | foreach my $rrsig ( @{ $cds_rrsets{ $ns_ip }{rrsig} } ) { | ||
| 5048 | my $msg = q{}; | ||
| 5049 | my @matching_dnskeys = grep { $rrsig->keytag == $_->keytag } @{ $dnskey_rrsets{ $ns_ip }{dnskey} }; | ||
| 5050 | if ( not scalar @matching_dnskeys ) { | ||
| 5051 | push @{ $cds_signed_by_unknown_dnskey{ $rrsig->keytag } }, $ns_ip; | ||
| 5052 | } | ||
| 5053 | elsif ( not $rrsig->verify_time( $cds_rrsets{ $ns_ip }{cds} , \@matching_dnskeys, $testing_time, $msg) ) { | ||
| 5054 | push @{ $cds_invalid_rrsig{ $rrsig->keytag } }, $ns_ip; | ||
| 5055 | } | ||
| 5056 | } | ||
| 5057 | } | ||
| 5058 | } | ||
| 5059 | |||
| 5060 | if ( scalar keys %no_dnskey_rrset ) { | ||
| 5061 | push @results, | ||
| 5062 | _emit_log( | ||
| 5063 | DS16_CDS_WITHOUT_DNSKEY => { | ||
| 5064 | ns_ip_list => join( q{;}, sort keys %no_dnskey_rrset ) | ||
| 5065 | } | ||
| 5066 | ); | ||
| 5067 | } | ||
| 5068 | |||
| 5069 | if ( scalar keys %mixed_delete_cds ) { | ||
| 5070 | push @results, | ||
| 5071 | _emit_log( | ||
| 5072 | DS16_MIXED_DELETE_CDS => { | ||
| 5073 | ns_ip_list => join( q{;}, sort keys %mixed_delete_cds ) | ||
| 5074 | } | ||
| 5075 | ); | ||
| 5076 | } | ||
| 5077 | |||
| 5078 | if ( scalar keys %delete_cds ) { | ||
| 5079 | push @results, | ||
| 5080 | _emit_log( | ||
| 5081 | DS16_DELETE_CDS => { | ||
| 5082 | ns_ip_list => join( q{;}, sort keys %delete_cds ) | ||
| 5083 | } | ||
| 5084 | ); | ||
| 5085 | } | ||
| 5086 | |||
| 5087 | if ( scalar keys %no_match_cds_with_dnskey ) { | ||
| 5088 | push @results, map { | ||
| 5089 | _emit_log( | ||
| 5090 | DS16_CDS_MATCHES_NO_DNSKEY => { | ||
| 5091 | keytag => $_, | ||
| 5092 | ns_ip_list => join( q{;}, uniq sort @{ $no_match_cds_with_dnskey{ $_ } } ) | ||
| 5093 | } | ||
| 5094 | ) | ||
| 5095 | } keys %no_match_cds_with_dnskey; | ||
| 5096 | } | ||
| 5097 | |||
| 5098 | if ( scalar keys %cds_points_to_non_zone_dnskey ) { | ||
| 5099 | push @results, map { | ||
| 5100 | _emit_log( | ||
| 5101 | DS16_CDS_MATCHES_NON_ZONE_DNSKEY => { | ||
| 5102 | keytag => $_, | ||
| 5103 | ns_ip_list => join( q{;}, uniq sort @{ $cds_points_to_non_zone_dnskey{ $_ } } ) | ||
| 5104 | } | ||
| 5105 | ) | ||
| 5106 | } keys %cds_points_to_non_zone_dnskey; | ||
| 5107 | } | ||
| 5108 | |||
| 5109 | if ( scalar keys %cds_points_to_non_sep_dnskey ) { | ||
| 5110 | push @results, map { | ||
| 5111 | _emit_log( | ||
| 5112 | DS16_CDS_MATCHES_NON_SEP_DNSKEY => { | ||
| 5113 | keytag => $_, | ||
| 5114 | ns_ip_list => join( q{;}, uniq sort @{ $cds_points_to_non_sep_dnskey{ $_ } } ) | ||
| 5115 | } | ||
| 5116 | ) | ||
| 5117 | } keys %cds_points_to_non_sep_dnskey; | ||
| 5118 | } | ||
| 5119 | |||
| 5120 | if ( scalar keys %dnskey_not_signed_by_cds ) { | ||
| 5121 | push @results, map { | ||
| 5122 | _emit_log( | ||
| 5123 | DS16_DNSKEY_NOT_SIGNED_BY_CDS => { | ||
| 5124 | keytag => $_, | ||
| 5125 | ns_ip_list => join( q{;}, uniq sort @{ $dnskey_not_signed_by_cds{ $_ } } ) | ||
| 5126 | } | ||
| 5127 | ) | ||
| 5128 | } keys %dnskey_not_signed_by_cds; | ||
| 5129 | } | ||
| 5130 | |||
| 5131 | if ( scalar keys %cds_not_signed_by_cds ) { | ||
| 5132 | push @results, map { | ||
| 5133 | _emit_log( | ||
| 5134 | DS16_CDS_NOT_SIGNED_BY_CDS => { | ||
| 5135 | keytag => $_, | ||
| 5136 | ns_ip_list => join( q{;}, uniq sort @{ $cds_not_signed_by_cds{ $_ } } ) | ||
| 5137 | } | ||
| 5138 | ) | ||
| 5139 | } keys %cds_not_signed_by_cds; | ||
| 5140 | } | ||
| 5141 | |||
| 5142 | if ( scalar keys %cds_invalid_rrsig ) { | ||
| 5143 | push @results, map { | ||
| 5144 | _emit_log( | ||
| 5145 | DS16_CDS_INVALID_RRSIG => { | ||
| 5146 | keytag => $_, | ||
| 5147 | ns_ip_list => join( q{;}, uniq sort @{ $cds_invalid_rrsig{ $_ } } ) | ||
| 5148 | } | ||
| 5149 | ) | ||
| 5150 | } keys %cds_invalid_rrsig; | ||
| 5151 | } | ||
| 5152 | |||
| 5153 | if ( scalar keys %cds_not_signed ) { | ||
| 5154 | push @results, | ||
| 5155 | _emit_log( | ||
| 5156 | DS16_CDS_UNSIGNED => { | ||
| 5157 | ns_ip_list => join( q{;}, sort keys %cds_not_signed ) | ||
| 5158 | } | ||
| 5159 | ); | ||
| 5160 | } | ||
| 5161 | |||
| 5162 | if ( scalar keys %cds_signed_by_unknown_dnskey ) { | ||
| 5163 | push @results, map { | ||
| 5164 | _emit_log( | ||
| 5165 | DS16_CDS_SIGNED_BY_UNKNOWN_DNSKEY => { | ||
| 5166 | keytag => $_, | ||
| 5167 | ns_ip_list => join( q{;}, uniq sort @{ $cds_signed_by_unknown_dnskey{ $_ } } ) | ||
| 5168 | } | ||
| 5169 | ) | ||
| 5170 | } keys %cds_signed_by_unknown_dnskey; | ||
| 5171 | } | ||
| 5172 | } | ||
| 5173 | |||
| 5174 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 5175 | } ## end sub dnssec16 | ||
| 5176 | |||
| 5177 | =over | ||
| 5178 | |||
| 5179 | =item dnssec17() | ||
| 5180 | |||
| 5181 | my @logentry_array = dnssec17( $zone ); | ||
| 5182 | |||
| 5183 | Runs the L<DNSSEC17 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec17.md>. | ||
| 5184 | |||
| 5185 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 5186 | |||
| 5187 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 5188 | |||
| 5189 | =back | ||
| 5190 | |||
| 5191 | =cut | ||
| 5192 | |||
| 5193 | sub dnssec17 { | ||
| 5194 | my ( $class, $zone ) = @_; | ||
| 5195 | |||
| 5196 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC17'; | ||
| 5197 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 5198 | my @query_types = qw{CDNSKEY DNSKEY}; | ||
| 5199 | my %cdnskey_rrsets; | ||
| 5200 | my %dnskey_rrsets; | ||
| 5201 | my %no_dnskey_rrset; | ||
| 5202 | my %mixed_delete_cdnskey; | ||
| 5203 | my %cdnskey_is_non_zone_key; | ||
| 5204 | my %cdnskey_is_non_sep_key; | ||
| 5205 | my %delete_cdnskey; | ||
| 5206 | my %no_match_cdnskey_with_dnskey; | ||
| 5207 | my %dnskey_not_signed_by_cdnskey; | ||
| 5208 | my %cdnskey_not_signed_by_cdnskey; | ||
| 5209 | my %cdnskey_not_signed; | ||
| 5210 | my %cdnskey_signed_by_unknown_dnskey; | ||
| 5211 | my %cdnskey_invalid_rrsig; | ||
| 5212 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 5213 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 5214 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 5215 | my %ip_already_processed; | ||
| 5216 | my $testing_time = time; | ||
| 5217 | |||
| 5218 | for my $nss_key ( sort keys %nss ) { | ||
| 5219 | my $ns = $nss{$nss_key}; | ||
| 5220 | |||
| 5221 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 5222 | $ip_already_processed{$ns->address->short} = 1; | ||
| 5223 | |||
| 5224 | if ( _ip_disabled_message( \@results, $ns, @query_types ) ) { | ||
| 5225 | next; | ||
| 5226 | } | ||
| 5227 | |||
| 5228 | my $cdnskey_p = $ns->query( $zone->name, q{CDNSKEY}, { dnssec => 1, usevc => 0 } ); | ||
| 5229 | if ( not $cdnskey_p ) { | ||
| 5230 | next; | ||
| 5231 | } | ||
| 5232 | if ( not $cdnskey_p->aa ) { | ||
| 5233 | next; | ||
| 5234 | } | ||
| 5235 | if ( $cdnskey_p->rcode ne q{NOERROR} ) { | ||
| 5236 | next; | ||
| 5237 | } | ||
| 5238 | my @cdnskey_records = $cdnskey_p->get_records( q{CDNSKEY}, q{answer} ); | ||
| 5239 | if ( not scalar @cdnskey_records ) { | ||
| 5240 | next; | ||
| 5241 | } | ||
| 5242 | my @cdnskey_rrsig_records = $cdnskey_p->get_records( q{RRSIG} , q{answer} ); | ||
| 5243 | push @{ $cdnskey_rrsets{ $ns->address->short }{cdnskey} }, @cdnskey_records; | ||
| 5244 | push @{ $cdnskey_rrsets{ $ns->address->short }{rrsig} }, @cdnskey_rrsig_records; | ||
| 5245 | foreach my $cdnskey ( @{ $cdnskey_rrsets{ $ns->address->short }{cdnskey} } ) { | ||
| 5246 | my $rr_string = $cdnskey->string; | ||
| 5247 | $rr_string =~ s/\s+CDNSKEY\s+/ DNSKEY /; | ||
| 5248 | push @{ $cdnskey_rrsets{ $ns->address->short }{dnskey} }, Zonemaster::LDNS::RR->new( $rr_string ); | ||
| 5249 | } | ||
| 5250 | |||
| 5251 | my $dnskey_p = $ns->query( $zone->name, q{DNSKEY}, { dnssec => 1, usevc => 0 } ); | ||
| 5252 | if ( not $dnskey_p ) { | ||
| 5253 | next; | ||
| 5254 | } | ||
| 5255 | if ( not $dnskey_p->aa ) { | ||
| 5256 | next; | ||
| 5257 | } | ||
| 5258 | if ( $dnskey_p->rcode ne q{NOERROR} ) { | ||
| 5259 | next; | ||
| 5260 | } | ||
| 5261 | my @dnskey_records = $dnskey_p->get_records( q{DNSKEY}, q{answer} ); | ||
| 5262 | if ( not scalar @dnskey_records ) { | ||
| 5263 | next; | ||
| 5264 | } | ||
| 5265 | my @dnskey_rrsig_records = $dnskey_p->get_records( q{RRSIG} , q{answer} ); | ||
| 5266 | push @{ $dnskey_rrsets{ $ns->address->short }{dnskey} }, @dnskey_records; | ||
| 5267 | push @{ $dnskey_rrsets{ $ns->address->short }{rrsig} }, @dnskey_rrsig_records; | ||
| 5268 | $testing_time = $dnskey_p->timestamp; | ||
| 5269 | |||
| 5270 | } | ||
| 5271 | undef %ip_already_processed; | ||
| 5272 | |||
| 5273 | if ( scalar keys %cdnskey_rrsets ) { | ||
| 5274 | for my $ns_ip ( keys %cdnskey_rrsets ) { | ||
| 5275 | if ( not scalar @{ $cdnskey_rrsets{ $ns_ip }{cdnskey} } ) { | ||
| 5276 | next; | ||
| 5277 | } | ||
| 5278 | if ( scalar grep { $_->algorithm == 0 } @{ $cdnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5279 | if ( scalar grep { $_->algorithm != 0 } @{ $cdnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5280 | $mixed_delete_cdnskey{ $ns_ip } = 1; | ||
| 5281 | } | ||
| 5282 | else { | ||
| 5283 | $delete_cdnskey{ $ns_ip } = 1; | ||
| 5284 | } | ||
| 5285 | next; | ||
| 5286 | } | ||
| 5287 | if ( not defined $dnskey_rrsets{ $ns_ip }{dnskey} or not scalar @{ $dnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5288 | $no_dnskey_rrset{ $ns_ip } = 1; | ||
| 5289 | next; | ||
| 5290 | } | ||
| 5291 | foreach my $dnskey ( @{ $cdnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5292 | next if $dnskey->algorithm == 0; | ||
| 5293 | if ( not $dnskey->flags & 256 ) { | ||
| 5294 | push @{ $cdnskey_is_non_zone_key{ $dnskey->keytag } }, $ns_ip; | ||
| 5295 | } | ||
| 5296 | else { | ||
| 5297 | if ( not $dnskey->flags & 1 ) { | ||
| 5298 | push @{ $cdnskey_is_non_sep_key{ $dnskey->keytag } }, $ns_ip; | ||
| 5299 | } | ||
| 5300 | if ( not scalar grep { $dnskey->keytag == $_->keytag } @{ $dnskey_rrsets{ $ns_ip }{dnskey} } ) { | ||
| 5301 | push @{ $no_match_cdnskey_with_dnskey{ $dnskey->keytag } }, $ns_ip; | ||
| 5302 | } | ||
| 5303 | else { | ||
| 5304 | if ( not scalar grep { $dnskey->keytag == $_->keytag } @{ $dnskey_rrsets{ $ns_ip }{rrsig} } ) { | ||
| 5305 | push @{ $dnskey_not_signed_by_cdnskey{ $dnskey->keytag } }, $ns_ip; | ||
| 5306 | } | ||
| 5307 | if ( not scalar grep { $dnskey->keytag == $_->keytag } @{ $cdnskey_rrsets{ $ns_ip }{rrsig} } ) { | ||
| 5308 | push @{ $cdnskey_not_signed_by_cdnskey{ $dnskey->keytag } }, $ns_ip; | ||
| 5309 | } | ||
| 5310 | } | ||
| 5311 | } | ||
| 5312 | } | ||
| 5313 | if ( not scalar @{ $cdnskey_rrsets{ $ns_ip }{rrsig} } ) { | ||
| 5314 | $cdnskey_not_signed{ $ns_ip } = 1; | ||
| 5315 | } | ||
| 5316 | else { | ||
| 5317 | foreach my $rrsig ( @{ $cdnskey_rrsets{ $ns_ip }{rrsig} } ) { | ||
| 5318 | my $msg = q{}; | ||
| 5319 | my @matching_dnskeys = grep { $rrsig->keytag == $_->keytag } @{ $dnskey_rrsets{ $ns_ip }{dnskey} }; | ||
| 5320 | if ( not scalar @matching_dnskeys ) { | ||
| 5321 | push @{ $cdnskey_signed_by_unknown_dnskey{ $rrsig->keytag } }, $ns_ip; | ||
| 5322 | } | ||
| 5323 | elsif ( not $rrsig->verify_time( $cdnskey_rrsets{ $ns_ip }{cdnskey} , \@matching_dnskeys, $testing_time, $msg) ) { | ||
| 5324 | push @{ $cdnskey_invalid_rrsig{ $rrsig->keytag } }, $ns_ip; | ||
| 5325 | } | ||
| 5326 | } | ||
| 5327 | } | ||
| 5328 | } | ||
| 5329 | |||
| 5330 | if ( scalar keys %no_dnskey_rrset ) { | ||
| 5331 | push @results, | ||
| 5332 | _emit_log( | ||
| 5333 | DS17_CDNSKEY_WITHOUT_DNSKEY => { | ||
| 5334 | ns_ip_list => join( q{;}, sort keys %no_dnskey_rrset ) | ||
| 5335 | } | ||
| 5336 | ); | ||
| 5337 | } | ||
| 5338 | |||
| 5339 | if ( scalar keys %mixed_delete_cdnskey ) { | ||
| 5340 | push @results, | ||
| 5341 | _emit_log( | ||
| 5342 | DS17_MIXED_DELETE_CDNSKEY => { | ||
| 5343 | ns_ip_list => join( q{;}, sort keys %mixed_delete_cdnskey ) | ||
| 5344 | } | ||
| 5345 | ); | ||
| 5346 | } | ||
| 5347 | |||
| 5348 | if ( scalar keys %delete_cdnskey ) { | ||
| 5349 | push @results, | ||
| 5350 | _emit_log( | ||
| 5351 | DS17_DELETE_CDNSKEY => { | ||
| 5352 | ns_ip_list => join( q{;}, sort keys %delete_cdnskey ) | ||
| 5353 | } | ||
| 5354 | ); | ||
| 5355 | } | ||
| 5356 | |||
| 5357 | if ( scalar keys %no_match_cdnskey_with_dnskey ) { | ||
| 5358 | push @results, map { | ||
| 5359 | _emit_log( | ||
| 5360 | DS17_CDNSKEY_MATCHES_NO_DNSKEY => { | ||
| 5361 | keytag => $_, | ||
| 5362 | ns_ip_list => join( q{;}, uniq sort @{ $no_match_cdnskey_with_dnskey{ $_ } } ) | ||
| 5363 | } | ||
| 5364 | ) | ||
| 5365 | } keys %no_match_cdnskey_with_dnskey; | ||
| 5366 | } | ||
| 5367 | |||
| 5368 | if ( scalar keys %cdnskey_is_non_zone_key ) { | ||
| 5369 | push @results, map { | ||
| 5370 | _emit_log( | ||
| 5371 | DS17_CDNSKEY_IS_NON_ZONE => { | ||
| 5372 | keytag => $_, | ||
| 5373 | ns_ip_list => join( q{;}, uniq sort @{ $cdnskey_is_non_zone_key{ $_ } } ) | ||
| 5374 | } | ||
| 5375 | ) | ||
| 5376 | } keys %cdnskey_is_non_zone_key; | ||
| 5377 | } | ||
| 5378 | |||
| 5379 | |||
| 5380 | if ( scalar keys %cdnskey_is_non_sep_key ) { | ||
| 5381 | push @results, map { | ||
| 5382 | _emit_log( | ||
| 5383 | DS17_CDNSKEY_IS_NON_SEP => { | ||
| 5384 | keytag => $_, | ||
| 5385 | ns_ip_list => join( q{;}, uniq sort @{ $cdnskey_is_non_sep_key{ $_ } } ) | ||
| 5386 | } | ||
| 5387 | ) | ||
| 5388 | } keys %cdnskey_is_non_sep_key; | ||
| 5389 | } | ||
| 5390 | |||
| 5391 | if ( scalar keys %dnskey_not_signed_by_cdnskey ) { | ||
| 5392 | push @results, map { | ||
| 5393 | _emit_log( | ||
| 5394 | DS17_DNSKEY_NOT_SIGNED_BY_CDNSKEY => { | ||
| 5395 | keytag => $_, | ||
| 5396 | ns_ip_list => join( q{;}, uniq sort @{ $dnskey_not_signed_by_cdnskey{ $_ } } ) | ||
| 5397 | } | ||
| 5398 | ) | ||
| 5399 | } keys %dnskey_not_signed_by_cdnskey; | ||
| 5400 | } | ||
| 5401 | |||
| 5402 | if ( scalar keys %cdnskey_not_signed_by_cdnskey ) { | ||
| 5403 | push @results, map { | ||
| 5404 | _emit_log( | ||
| 5405 | DS17_CDNSKEY_NOT_SIGNED_BY_CDNSKEY => { | ||
| 5406 | keytag => $_, | ||
| 5407 | ns_ip_list => join( q{;}, uniq sort @{ $cdnskey_not_signed_by_cdnskey{ $_ } } ) | ||
| 5408 | } | ||
| 5409 | ) | ||
| 5410 | } keys %cdnskey_not_signed_by_cdnskey; | ||
| 5411 | } | ||
| 5412 | |||
| 5413 | if ( scalar keys %cdnskey_invalid_rrsig ) { | ||
| 5414 | push @results, map { | ||
| 5415 | _emit_log( | ||
| 5416 | DS17_CDNSKEY_INVALID_RRSIG => { | ||
| 5417 | keytag => $_, | ||
| 5418 | ns_ip_list => join( q{;}, uniq sort @{ $cdnskey_invalid_rrsig{ $_ } } ) | ||
| 5419 | } | ||
| 5420 | ) | ||
| 5421 | } keys %cdnskey_invalid_rrsig; | ||
| 5422 | } | ||
| 5423 | |||
| 5424 | if ( scalar keys %cdnskey_not_signed ) { | ||
| 5425 | push @results, | ||
| 5426 | _emit_log( | ||
| 5427 | DS17_CDNSKEY_UNSIGNED => { | ||
| 5428 | ns_ip_list => join( q{;}, sort keys %cdnskey_not_signed ) | ||
| 5429 | } | ||
| 5430 | ); | ||
| 5431 | } | ||
| 5432 | |||
| 5433 | if ( scalar keys %cdnskey_signed_by_unknown_dnskey ) { | ||
| 5434 | push @results, map { | ||
| 5435 | _emit_log( | ||
| 5436 | DS17_CDNSKEY_SIGNED_BY_UNKNOWN_DNSKEY => { | ||
| 5437 | keytag => $_, | ||
| 5438 | ns_ip_list => join( q{;}, uniq sort @{ $cdnskey_signed_by_unknown_dnskey{ $_ } } ) | ||
| 5439 | } | ||
| 5440 | ) | ||
| 5441 | } keys %cdnskey_signed_by_unknown_dnskey; | ||
| 5442 | } | ||
| 5443 | } | ||
| 5444 | |||
| 5445 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 5446 | } ## end sub dnssec17 | ||
| 5447 | |||
| 5448 | =over | ||
| 5449 | |||
| 5450 | =item dnssec18() | ||
| 5451 | |||
| 5452 | my @logentry_array = dnssec18( $zone ); | ||
| 5453 | |||
| 5454 | Runs the L<DNSSEC18 Test Case|https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/tests/DNSSEC-TP/dnssec18.md>. | ||
| 5455 | |||
| 5456 | Takes a L<Zonemaster::Engine::Zone> object. | ||
| 5457 | |||
| 5458 | Returns a list of L<Zonemaster::Engine::Logger::Entry> objects. | ||
| 5459 | |||
| 5460 | =back | ||
| 5461 | |||
| 5462 | =cut | ||
| 5463 | |||
| 5464 | sub dnssec18 { | ||
| 5465 | my ( $class, $zone ) = @_; | ||
| 5466 | |||
| 5467 | local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'DNSSEC18'; | ||
| 5468 | push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ); | ||
| 5469 | my %cds_rrsets; | ||
| 5470 | my %cdnskey_rrsets; | ||
| 5471 | my %dnskey_rrsets; | ||
| 5472 | my @ds_records; | ||
| 5473 | my %ds_no_match_cds_rrsig; | ||
| 5474 | my %ds_no_match_cdnskey_rrsig; | ||
| 5475 | my $continue_with_child_tests = 1; | ||
| 5476 | |||
| 5477 | my $parent = Zonemaster::Engine::TestMethods->method1( $zone ); | ||
| 5478 | my @nss_parent = @{ $parent->ns }; | ||
| 5479 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_parent; | ||
| 5480 | my %ip_already_processed; | ||
| 5481 | |||
| 5482 | for my $nss_key ( sort keys %nss ) { | ||
| 5483 | my $ns = $nss{$nss_key}; | ||
| 5484 | |||
| 5485 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 5486 | $ip_already_processed{$ns->address->short} = 1; | ||
| 5487 | |||
| 5488 | if ( _ip_disabled_message( \@results, $ns, q{DS} ) ) { | ||
| 5489 | next; | ||
| 5490 | } | ||
| 5491 | |||
| 5492 | my $ds_p = $ns->query( $zone->name, q{DS}, { dnssec => 1, usevc => 0 } ); | ||
| 5493 | if ( not $ds_p or $ds_p->rcode ne q{NOERROR} or not $ds_p->aa ) { | ||
| 5494 | next; | ||
| 5495 | } | ||
| 5496 | my @tmp_ds_records = $ds_p->get_records_for_name( q{DS}, $zone->name->string, q{answer} ); | ||
| 5497 | if ( not scalar @tmp_ds_records ) { | ||
| 5498 | next; | ||
| 5499 | } | ||
| 5500 | foreach my $tmp_ds_record ( @tmp_ds_records ) { | ||
| 5501 | if ( | ||
| 5502 | not grep { | ||
| 5503 | $tmp_ds_record->keytag == $_->keytag | ||
| 5504 | and $tmp_ds_record->digtype == $_->digtype | ||
| 5505 | and $tmp_ds_record->algorithm == $_->algorithm | ||
| 5506 | and $tmp_ds_record->hexdigest eq $_->hexdigest | ||
| 5507 | } @ds_records | ||
| 5508 | ) | ||
| 5509 | { | ||
| 5510 | push @ds_records, $tmp_ds_record; | ||
| 5511 | } | ||
| 5512 | } | ||
| 5513 | } | ||
| 5514 | undef %ip_already_processed; | ||
| 5515 | |||
| 5516 | if ( not scalar @ds_records ) { | ||
| 5517 | $continue_with_child_tests = 0; | ||
| 5518 | } | ||
| 5519 | |||
| 5520 | if ( $continue_with_child_tests ) { | ||
| 5521 | |||
| 5522 | my @query_types = qw{CDNSKEY CDS DNSKEY}; | ||
| 5523 | my @nss_del = @{ Zonemaster::Engine::TestMethods->method4( $zone ) }; | ||
| 5524 | my @nss_child = @{ Zonemaster::Engine::TestMethods->method5( $zone ) }; | ||
| 5525 | my %nss = map { $_->name->string . '/' . $_->address->short => $_ } @nss_del, @nss_child; | ||
| 5526 | my %ip_already_processed; | ||
| 5527 | |||
| 5528 | for my $nss_key ( sort keys %nss ) { | ||
| 5529 | my $ns = $nss{$nss_key}; | ||
| 5530 | |||
| 5531 | next if exists $ip_already_processed{$ns->address->short}; | ||
| 5532 | $ip_already_processed{$ns->address->short} = 1; | ||
| 5533 | |||
| 5534 | if ( _ip_disabled_message( \@results, $ns, @query_types ) ) { | ||
| 5535 | next; | ||
| 5536 | } | ||
| 5537 | |||
| 5538 | my $cds_p = $ns->query( $zone->name, q{CDS}, { dnssec => 1, usevc => 0 } ); | ||
| 5539 | if ( not $cds_p or not $cds_p->aa or $cds_p->rcode ne q{NOERROR} ) { | ||
| 5540 | next; | ||
| 5541 | } | ||
| 5542 | my @cds_records = $cds_p->get_records( q{CDS}, q{answer} ); | ||
| 5543 | if ( scalar @cds_records ) { | ||
| 5544 | my @cds_rrsig_records = $cds_p->get_records( q{RRSIG} , q{answer} ); | ||
| 5545 | push @{ $cds_rrsets{ $ns->address->short }{cds} }, @cds_records; | ||
| 5546 | push @{ $cds_rrsets{ $ns->address->short }{rrsig} }, @cds_rrsig_records; | ||
| 5547 | foreach my $cds ( @{ $cds_rrsets{ $ns->address->short }{cds} } ) { | ||
| 5548 | my $rr_string = $cds->string; | ||
| 5549 | $rr_string =~ s/\s+CDS\s+/ DS /; | ||
| 5550 | push @{ $cds_rrsets{ $ns->address->short }{ds} }, Zonemaster::LDNS::RR->new( $rr_string ); | ||
| 5551 | } | ||
| 5552 | } | ||
| 5553 | |||
| 5554 | my $cdnskey_p = $ns->query( $zone->name, q{CDNSKEY}, { dnssec => 1, usevc => 0 } ); | ||
| 5555 | if ( not $cdnskey_p or not $cdnskey_p->aa or $cdnskey_p->rcode ne q{NOERROR} ) { | ||
| 5556 | next; | ||
| 5557 | } | ||
| 5558 | my @cdnskey_records = $cdnskey_p->get_records( q{CDNSKEY}, q{answer} ); | ||
| 5559 | if ( scalar @cdnskey_records ) { | ||
| 5560 | my @cdnskey_rrsig_records = $cdnskey_p->get_records( q{RRSIG} , q{answer} ); | ||
| 5561 | push @{ $cdnskey_rrsets{ $ns->address->short }{cdnskey} }, @cdnskey_records; | ||
| 5562 | push @{ $cdnskey_rrsets{ $ns->address->short }{rrsig} }, @cdnskey_rrsig_records; | ||
| 5563 | foreach my $cdnskey ( @{ $cdnskey_rrsets{ $ns->address->short }{cdnskey} } ) { | ||
| 5564 | my $rr_string = $cdnskey->string; | ||
| 5565 | $rr_string =~ s/\s+CDNSKEY\s+/ DNSKEY /; | ||
| 5566 | push @{ $cdnskey_rrsets{ $ns->address->short }{dnskey} }, Zonemaster::LDNS::RR->new( $rr_string ); | ||
| 5567 | } | ||
| 5568 | } | ||
| 5569 | |||
| 5570 | my $dnskey_p = $ns->query( $zone->name, q{DNSKEY}, { dnssec => 1, usevc => 0 } ); | ||
| 5571 | if ( not $dnskey_p or $dnskey_p->rcode ne q{NOERROR} or not $dnskey_p->aa ) { | ||
| 5572 | next; | ||
| 5573 | } | ||
| 5574 | my @dnskey_records = $dnskey_p->get_records( q{DNSKEY}, q{answer} ); | ||
| 5575 | if ( scalar @dnskey_records ) { | ||
| 5576 | push @{ $dnskey_rrsets{ $ns->address->short }{dnskey} }, @dnskey_records; | ||
| 5577 | } | ||
| 5578 | } | ||
| 5579 | undef %ip_already_processed; | ||
| 5580 | |||
| 5581 | if ( not( not scalar keys %cds_rrsets and not scalar keys %cdnskey_rrsets ) | ||
| 5582 | and not( not scalar keys %dnskey_rrsets ) ) | ||
| 5583 | { | ||
| 5584 | for my $ns_ip ( keys %cds_rrsets ) { | ||
| 5585 | my (@rrsig, @dnskey); | ||
| 5586 | push @rrsig, @{ $cds_rrsets{ $ns_ip }{rrsig} }; | ||
| 5587 | push @dnskey, @{ $dnskey_rrsets{ $ns_ip }{dnskey} }; | ||
| 5588 | my $match = 0; | ||
| 5589 | foreach my $ds ( @ds_records ) { | ||
| 5590 | if ( not scalar grep { $ds->keytag == $_->keytag } @dnskey ) { | ||
| 5591 | next; | ||
| 5592 | } | ||
| 5593 | elsif ( scalar grep { $ds->keytag == $_->keytag } @rrsig ) { | ||
| 5594 | $match = 1; | ||
| 5595 | last; | ||
| 5596 | } | ||
| 5597 | } | ||
| 5598 | if ( not $match ) { | ||
| 5599 | $ds_no_match_cds_rrsig{ $ns_ip } = 1; | ||
| 5600 | } | ||
| 5601 | } | ||
| 5602 | for my $ns_ip ( keys %cdnskey_rrsets ) { | ||
| 5603 | my (@rrsig, @dnskey); | ||
| 5604 | push @rrsig, @{ $cdnskey_rrsets{ $ns_ip }{rrsig} }; | ||
| 5605 | push @dnskey, @{ $dnskey_rrsets{ $ns_ip }{dnskey} }; | ||
| 5606 | my $match = 0; | ||
| 5607 | foreach my $ds ( @ds_records ) { | ||
| 5608 | if ( not scalar grep { $ds->keytag == $_->keytag } @dnskey ) { | ||
| 5609 | next; | ||
| 5610 | } | ||
| 5611 | elsif ( scalar grep { $ds->keytag == $_->keytag } @rrsig ) { | ||
| 5612 | $match = 1; | ||
| 5613 | last; | ||
| 5614 | } | ||
| 5615 | } | ||
| 5616 | if ( not $match ) { | ||
| 5617 | $ds_no_match_cdnskey_rrsig{ $ns_ip } = 1; | ||
| 5618 | } | ||
| 5619 | } | ||
| 5620 | if ( scalar keys %ds_no_match_cds_rrsig ) { | ||
| 5621 | push @results, | ||
| 5622 | _emit_log( | ||
| 5623 | DS18_NO_MATCH_CDS_RRSIG_DS => { | ||
| 5624 | ns_ip_list => join( q{;}, sort keys %ds_no_match_cds_rrsig ) | ||
| 5625 | } | ||
| 5626 | ); | ||
| 5627 | } | ||
| 5628 | if ( scalar keys %ds_no_match_cdnskey_rrsig ) { | ||
| 5629 | push @results, | ||
| 5630 | _emit_log( | ||
| 5631 | DS18_NO_MATCH_CDNSKEY_RRSIG_DS => { | ||
| 5632 | ns_ip_list => join( q{;}, sort keys %ds_no_match_cdnskey_rrsig ) | ||
| 5633 | } | ||
| 5634 | ); | ||
| 5635 | } | ||
| 5636 | } | ||
| 5637 | } | ||
| 5638 | |||
| 5639 | return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) ); | ||
| 5640 | } ## end sub dnssec18 | ||
| 5641 | |||
| 5642 | 1; |