Skip to content

Commit

Permalink
Fixes in Basic01 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreenx committed Jun 6, 2024
1 parent acf31d2 commit c5bea3c
Show file tree
Hide file tree
Showing 2 changed files with 293 additions and 291 deletions.
36 changes: 19 additions & 17 deletions lib/Zonemaster/Engine/Test/Basic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ sub metadata {
B01_PARENT_FOUND
B01_PARENT_NOT_FOUND
B01_PARENT_UNDETERMINED
B01_SERVER_ZONE_ERROR
TEST_CASE_END
TEST_CASE_START
)
Expand Down Expand Up @@ -601,11 +602,12 @@ sub basic01 {
}

my $intermediate_query_name = name( $zone_name );
my $loop_zone_name = $zone_name;

LOOP:
while() {
$intermediate_query_name = name( @{ $zone->name->labels }[ ( scalar @{ $zone->name->labels } - scalar @{ $intermediate_query_name->labels } ) - 1 ] . '.' . $intermediate_query_name->string )
unless scalar @{ $intermediate_query_name->labels } > scalar @{ $zone->name->labels };
last if scalar @{ $intermediate_query_name->labels } >= scalar @{ $zone->name->labels };
$intermediate_query_name = name( @{ $zone->name->labels }[ ( scalar @{ $zone->name->labels } - scalar @{ $intermediate_query_name->labels } ) - 1 ] . '.' . $intermediate_query_name->string );

$p_soa = $ns->query( $intermediate_query_name, $type_soa );

Expand All @@ -624,8 +626,8 @@ sub basic01 {

if ( $p_soa->rcode eq 'NOERROR' and $p_soa->aa and scalar $p_soa->get_records_for_name( $type_soa, $intermediate_query_name, 'answer' ) == 1 ) {
if ( $intermediate_query_name->string eq $zone->name->string ) {
push @{ $parent_found{$zone_name} }, $ns->string;
push @{ $aa_soa{$zone_name} }, $ns->string;
push @{ $parent_found{$loop_zone_name} }, $ns->string;
push @{ $aa_soa{$loop_zone_name} }, $ns->string;
}
else {
$p_ns = $ns->query( $intermediate_query_name, $type_ns );
Expand Down Expand Up @@ -681,18 +683,18 @@ sub basic01 {
}
}

$zone_name = $intermediate_query_name->string;
$loop_zone_name = $intermediate_query_name->string;
next LOOP;
}
}
elsif ( $p_soa->rcode eq 'NXDOMAIN' and $p_soa->aa ) {
push @{ $parent_found{$zone_name} }, $ns->string;
push @{ $aa_nxdomain{$zone_name} }, $ns->string;
push @{ $parent_found{$loop_zone_name} }, $ns->string;
push @{ $aa_nxdomain{$loop_zone_name} }, $ns->string;
}
elsif ( $p_soa->is_redirect and scalar $p_soa->get_records_for_name( $type_ns, $intermediate_query_name, 'authority' ) ) {
if ( $intermediate_query_name->string eq $zone->name->string ) {
push @{ $parent_found{$zone_name} }, $ns->string;
push @{ $delegation_found{$zone_name} }, $ns->string;
push @{ $parent_found{$loop_zone_name} }, $ns->string;
push @{ $delegation_found{$loop_zone_name} }, $ns->string;
}
else {
my %rrs_ns_bis;
Expand Down Expand Up @@ -736,25 +738,25 @@ sub basic01 {
next LOOP if $intermediate_query_name->string ne $zone->name->string;

if ( scalar $p_soa->get_records_for_name( 'CNAME', $zone->name, 'answer' ) ) {
push @{ $parent_found{$zone_name} }, $ns->string;
push @{ $aa_cname{$zone_name} }, $ns->string;
push @{ $parent_found{$loop_zone_name} }, $ns->string;
push @{ $aa_cname{$loop_zone_name} }, $ns->string;
}
else {
my $p_dname = $ns->query( $zone->name->string , $type_dname );

if ( $p_dname and $p_dname->aa and $p_dname->rcode eq 'NOERROR' and scalar $p_dname->get_records_for_name( $type_dname, $zone->name, 'answer' ) == 1 ) {
push @{ $parent_found{$zone_name} }, $ns->string;
push @{ $aa_dname{($p_dname->get_records_for_name( $type_dname, $zone->name, 'answer' ))[0]->dname}{$zone_name} }, $ns->string;
push @{ $parent_found{$loop_zone_name} }, $ns->string;
push @{ $aa_dname{($p_dname->get_records_for_name( $type_dname, $zone->name, 'answer' ))[0]->dname}{$loop_zone_name} }, $ns->string;
}
else {
push @{ $parent_found{$zone_name} }, $ns->string;
push @{ $aa_nodata{$zone_name} }, $ns->string;
push @{ $parent_found{$loop_zone_name} }, $ns->string;
push @{ $aa_nodata{$loop_zone_name} }, $ns->string;
}
}
}
elsif ( $p_soa->is_redirect and scalar $p_soa->get_records_for_name( 'CNAME', $zone->name, 'answer' ) ) {
push @{ $parent_found{$zone_name} }, $ns->string;
push @{ $cname_with_referral{$zone_name} }, $ns->string;
push @{ $parent_found{$loop_zone_name} }, $ns->string;
push @{ $cname_with_referral{$loop_zone_name} }, $ns->string;
}
else {
push @results,
Expand Down
Loading

0 comments on commit c5bea3c

Please sign in to comment.