Skip to content

Commit

Permalink
Update Delegation01 - zonemaster#1203
Browse files Browse the repository at this point in the history
Update some message ids to report name server names and addresses together instead of separately
  • Loading branch information
tgreenx committed Sep 12, 2023
1 parent c5cdf80 commit b9f58a0
Showing 1 changed file with 36 additions and 44 deletions.
80 changes: 36 additions & 44 deletions lib/Zonemaster/Engine/Test/Delegation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,26 @@ Readonly my %TAG_DESCRIPTIONS => (
},
ENOUGH_IPV4_NS_CHILD => sub {
__x # DELEGATION:ENOUGH_IPV4_NS_CHILD
"Child lists enough ({count}) nameservers ({nsname_list}) "
. "that resolve to IPv4 addresses ({ns_ip_list}). Lower limit set to {minimum}.",
"Child lists enough ({count}) nameservers ({ns_list}) "
. "that resolve to IPv4 addresses. Lower limit set to {minimum}.",
@_;
},
ENOUGH_IPV4_NS_DEL => sub {
__x # DELEGATION:ENOUGH_IPV4_NS_DEL
"Delegation lists enough ({count}) nameservers ({nsname_list}) "
. "that resolve to IPv4 addresses ({ns_ip_list}). Lower limit set to {minimum}.",
"Delegation lists enough ({count}) nameservers ({ns_list}) "
. "that resolve to IPv4 addresses. Lower limit set to {minimum}.",
@_;
},
ENOUGH_IPV6_NS_CHILD => sub {
__x # DELEGATION:ENOUGH_IPV6_NS_CHILD
"Child lists enough ({count}) nameservers ({nsname_list}) "
. "that resolve to IPv6 addresses ({ns_ip_list}). Lower limit set to {minimum}.",
"Child lists enough ({count}) nameservers ({ns_list}) "
. "that resolve to IPv6 addresses. Lower limit set to {minimum}.",
@_;
},
ENOUGH_IPV6_NS_DEL => sub {
__x # DELEGATION:ENOUGH_IPV6_NS_DEL
"Delegation lists enough ({count}) nameservers ({nsname_list}) "
. "that resolve to IPv6 addresses ({ns_ip_list}). Lower limit set to {minimum}.",
"Delegation lists enough ({count}) nameservers ({ns_list}) "
. "that resolve to IPv6 addresses. Lower limit set to {minimum}.",
@_;
},
ENOUGH_NS_CHILD => sub {
Expand Down Expand Up @@ -248,26 +248,26 @@ Readonly my %TAG_DESCRIPTIONS => (
},
NOT_ENOUGH_IPV4_NS_CHILD => sub {
__x # DELEGATION:NOT_ENOUGH_IPV4_NS_CHILD
"Child does not list enough ({count}) nameservers ({nsname_list}) "
. "that resolve to IPv4 addresses ({ns_ip_list}). Lower limit set to {minimum}.",
"Child does not list enough ({count}) nameservers ({ns_list}) "
. "that resolve to IPv4 addresses. Lower limit set to {minimum}.",
@_;
},
NOT_ENOUGH_IPV4_NS_DEL => sub {
__x # DELEGATION:NOT_ENOUGH_IPV4_NS_DEL
"Delegation does not list enough ({count}) nameservers ({nsname_list}) "
. "that resolve to IPv4 addresses ({ns_ip_list}). Lower limit set to {minimum}.",
"Delegation does not list enough ({count}) nameservers ({ns_list}) "
. "that resolve to IPv4 addresses. Lower limit set to {minimum}.",
@_;
},
NOT_ENOUGH_IPV6_NS_CHILD => sub {
__x # DELEGATION:NOT_ENOUGH_IPV6_NS_CHILD
"Child does not list enough ({count}) nameservers ({nsname_list}) "
. "that resolve to IPv6 addresses ({ns_ip_list}). Lower limit set to {minimum}.",
"Child does not list enough ({count}) nameservers ({ns_list}) "
. "that resolve to IPv6 addresses. Lower limit set to {minimum}.",
@_;
},
NOT_ENOUGH_IPV6_NS_DEL => sub {
__x # DELEGATION:NOT_ENOUGH_IPV6_NS_DEL
"Delegation does not list enough ({count}) nameservers ({nsname_list}) "
. "that resolve to IPv6 addresses ({ns_ip_list}). Lower limit set to {minimum}.",
"Delegation does not list enough ({count}) nameservers ({ns_list}) "
. "that resolve to IPv6 addresses. Lower limit set to {minimum}.",
@_;
},
NOT_ENOUGH_NS_CHILD => sub {
Expand Down Expand Up @@ -428,38 +428,34 @@ sub delegation01 {

# Determine child NS names with addresses
my @child_ns = @{ Zonemaster::Engine::TestMethods->method5( $zone ) };
my @child_ns_ipv4 = uniq map { $_->name->string } grep { $_->address->version == 4 } @child_ns;
my @child_ns_ipv6 = uniq map { $_->name->string } grep { $_->address->version == 6 } @child_ns;
my @child_ns_ipv4_addrs = uniq map { $_->address->ip } grep { $_->address->version == 4 } @child_ns;
my @child_ns_ipv6_addrs = uniq map { $_->address->short } grep { $_->address->version == 6 } @child_ns;
my @child_ns_ipv4 = map { $_ } grep { $_->address->version == 4 } @child_ns;
my @child_ns_ipv6 = map { $_ } grep { $_->address->version == 6 } @child_ns;

my $child_ns_ipv4_args = {
count => scalar( @child_ns_ipv4 ),
count => scalar( uniq map { $_->name->string } @child_ns_ipv4 ),
minimum => $MINIMUM_NUMBER_OF_NAMESERVERS,
nsname_list => join( q{;}, sort @child_ns_ipv4 ),
ns_ip_list => join( q{;}, sort @child_ns_ipv4_addrs ),
ns_list => join( q{;}, sort map { $_->string } @child_ns_ipv4 ),
};
my $child_ns_ipv6_args = {
count => scalar( @child_ns_ipv6 ),
count => scalar( uniq map { $_->name->string } @child_ns_ipv6 ),
minimum => $MINIMUM_NUMBER_OF_NAMESERVERS,
nsname_list => join( q{;}, sort @child_ns_ipv6 ),
ns_ip_list => join( q{;}, sort @child_ns_ipv6_addrs ),
ns_list => join( q{;}, sort map { $_->string } @child_ns_ipv6 ),
};

if ( scalar( @child_ns_ipv4 ) >= $MINIMUM_NUMBER_OF_NAMESERVERS ) {
if ( scalar( uniq map { $_->name->string } @child_ns_ipv4 ) >= $MINIMUM_NUMBER_OF_NAMESERVERS ) {
push @results, info( ENOUGH_IPV4_NS_CHILD => $child_ns_ipv4_args );
}
elsif ( scalar( @child_ns_ipv4 ) > 0 ) {
elsif ( scalar( uniq map { $_->name->string } @child_ns_ipv4 ) > 0 ) {
push @results, info( NOT_ENOUGH_IPV4_NS_CHILD => $child_ns_ipv4_args );
}
else {
push @results, info( NO_IPV4_NS_CHILD => $child_ns_ipv4_args );
}

if ( scalar( @child_ns_ipv6 ) >= $MINIMUM_NUMBER_OF_NAMESERVERS ) {
if ( scalar( uniq map { $_->name->string } @child_ns_ipv6 ) >= $MINIMUM_NUMBER_OF_NAMESERVERS ) {
push @results, info( ENOUGH_IPV6_NS_CHILD => $child_ns_ipv6_args );
}
elsif ( scalar( @child_ns_ipv6 ) > 0 ) {
elsif ( scalar( uniq map { $_->name->string } @child_ns_ipv6 ) > 0 ) {
push @results, info( NOT_ENOUGH_IPV6_NS_CHILD => $child_ns_ipv6_args );
}
else {
Expand All @@ -468,38 +464,34 @@ sub delegation01 {

# Determine delegation NS names with addresses
my @del_ns = @{ Zonemaster::Engine::TestMethods->method4( $zone ) };
my @del_ns_ipv4 = uniq map { $_->name->string } grep { $_->address->version == 4 } @del_ns;
my @del_ns_ipv6 = uniq map { $_->name->string } grep { $_->address->version == 6 } @del_ns;
my @del_ns_ipv4_addrs = uniq map { $_->address->ip } grep { $_->address->version == 4 } @del_ns;
my @del_ns_ipv6_addrs = uniq map { $_->address->short } grep { $_->address->version == 6 } @del_ns;
my @del_ns_ipv4 = map { $_ } grep { $_->address->version == 4 } @del_ns;
my @del_ns_ipv6 = map { $_ } grep { $_->address->version == 6 } @del_ns;

my $del_ns_ipv4_args = {
count => scalar( @del_ns_ipv4 ),
count => scalar( uniq map { $_->name->string } @del_ns_ipv4 ),
minimum => $MINIMUM_NUMBER_OF_NAMESERVERS,
nsname_list => join( q{;}, sort @del_ns_ipv4 ),
ns_ip_list => join( q{;}, sort @del_ns_ipv4_addrs ),
ns_list => join( q{;}, sort map { $_->string } @del_ns_ipv4 ),
};
my $del_ns_ipv6_args = {
count => scalar( @del_ns_ipv6 ),
count => scalar( uniq map { $_->name->string } @del_ns_ipv6 ),
minimum => $MINIMUM_NUMBER_OF_NAMESERVERS,
nsname_list => join( q{;}, sort @del_ns_ipv6 ),
ns_ip_list => join( q{;}, sort @del_ns_ipv6_addrs ),
ns_list => join( q{;}, sort map { $_->string } @del_ns_ipv6 ),
};

if ( scalar( @del_ns_ipv4 ) >= $MINIMUM_NUMBER_OF_NAMESERVERS ) {
if ( scalar( uniq map { $_->name->string } @del_ns_ipv4 ) >= $MINIMUM_NUMBER_OF_NAMESERVERS ) {
push @results, info( ENOUGH_IPV4_NS_DEL => $del_ns_ipv4_args );
}
elsif ( scalar( @del_ns_ipv4 ) > 0 ) {
elsif ( scalar( uniq map { $_->name->string } @del_ns_ipv4 ) > 0 ) {
push @results, info( NOT_ENOUGH_IPV4_NS_DEL => $del_ns_ipv4_args );
}
else {
push @results, info( NO_IPV4_NS_DEL => $del_ns_ipv4_args );
}

if ( scalar( @del_ns_ipv6 ) >= $MINIMUM_NUMBER_OF_NAMESERVERS ) {
if ( scalar( uniq map { $_->name->string } @del_ns_ipv6 ) >= $MINIMUM_NUMBER_OF_NAMESERVERS ) {
push @results, info( ENOUGH_IPV6_NS_DEL => $del_ns_ipv6_args );
}
elsif ( scalar( @del_ns_ipv6 ) > 0 ) {
elsif ( scalar( uniq map { $_->name->string } @del_ns_ipv6 ) > 0 ) {
push @results, info( NOT_ENOUGH_IPV6_NS_DEL => $del_ns_ipv6_args );
}
else {
Expand Down

0 comments on commit b9f58a0

Please sign in to comment.