Skip to content

Commit

Permalink
Fix code in Basic01
Browse files Browse the repository at this point in the history
These changes are to align the code with the specification:
- Update and add missing code (step 7.3 of the specification - relates to issue #1248)
- Add missing conditional checks for the start of the Basic module and test cases ("scope" section of the specification")
- Refactoring
  • Loading branch information
tgreenx committed Jul 4, 2023
1 parent 76b9dd9 commit 9df575a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/Zonemaster/Engine/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ sub run_all_for {
push @results, Zonemaster::Engine::Test::Basic->all( $zone );
info( MODULE_END => { module => 'Zonemaster::Engine::Test::Basic' } );

if ( Zonemaster::Engine::Test::Basic->can_continue( @results ) and Zonemaster::Engine->can_continue() ) {
if ( Zonemaster::Engine::Test::Basic->can_continue( $zone, @results ) and Zonemaster::Engine->can_continue() ) {
foreach my $mod ( __PACKAGE__->modules ) {

my $module = "Zonemaster::Engine::Test::$mod";
Expand Down
18 changes: 11 additions & 7 deletions lib/Zonemaster/Engine/Test/Basic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ sub all {
{
push @results, $class->basic01( $zone );

push @results, $class->basic02( $zone );
if ( grep { $_->tag eq q{B01_CHILD_FOUND} } @results ) {
push @results, $class->basic02( $zone );
}

# Perform BASIC3 if BASIC2 failed
if ( none { $_->tag eq q{B02_AUTH_RESPONSE_SOA} } @results ) {
Expand All @@ -61,14 +63,15 @@ sub all {
} ## end sub all

sub can_continue {
my ( $class, @results ) = @_;
my ( $class, $zone, @results ) = @_;
my %tag = map { $_->tag => 1 } @results;
my $is_undelegated = Zonemaster::Engine::Recursor->has_fake_addresses( $zone->name->string );

if ( not $tag{B02_NO_DELEGATION} and $tag{B02_AUTH_RESPONSE_SOA} ) {
return 1;
}
else {
return;
return $is_undelegated;
}
}

Expand Down Expand Up @@ -450,11 +453,11 @@ sub basic01 {
}

if ( $p->is_redirect and index( $zone_name, name( lc( ( $p->get_records( 'NS' ) )[0]->owner ) ) ) == -1
and index( $zone->name->fqdn, name( lc( ( $p->get_records( 'NS' ) )[0]->owner ) ) ) == -1 ) {
and index( $zone->name, name( lc( ( $p->get_records( 'NS' ) )[0]->owner ) ) ) == -1 ) {
next;
}

if ( $p->is_redirect and index( $zone->name->fqdn, name( lc( ( $p->get_records( 'NS' ) )[0]->owner ) ) ) > 0 ) {
if ( $p->is_redirect and index( $zone->name, name( lc( ( $p->get_records( 'NS' ) )[0]->owner ) ) ) > 0 ) {
$rrs_ns{$_->nsdname}{'referral'} = $_->owner for $p->get_records( 'NS' );
$rrs_ns{$_->owner}{'addresses'}{$_->address} = 1 for ( $p->get_records( q{A} ), $p->get_records( 'AAAA' ) );

Expand All @@ -475,7 +478,7 @@ sub basic01 {

foreach my $ns_ip ( keys %{ $rrs_ns{$ns_name}{'addresses'} } ) {
unless ( grep { $_ eq $ns_ip } @handled_servers ) {
$all_servers{$ns_name . '/' . $ns_ip} = $rrs_ns{$ns_name}{'referral'};
$all_servers{$ns_name . '/' . $ns_ip} = name( $rrs_ns{$ns_name}{'referral'} );
push @remaining_servers, $ns_name . '/' . $ns_ip;
push @handled_servers, $ns_ip;
}
Expand Down Expand Up @@ -584,8 +587,9 @@ sub basic01 {

if ( $p->aa and scalar $p->get_records_for_name( 'SOA', $zone->name->string, q{answer} ) ) {
if ( $zone->name->next_higher eq $zone_name ) {
push @{ $aa_soa{$zone_name} }, $ns_string;
push @{ $parent_found{$zone_name} }, $ns_string;
}
push @{ $aa_soa{$zone_name} }, $ns_string;
}

if ( $p->aa and scalar $p->get_records_for_name( 'CNAME', $zone->name->string, q{answer} ) ) {
Expand Down

0 comments on commit 9df575a

Please sign in to comment.