Skip to content

Fix other methods in Zonemaster::LDNS::RR::NSEC3 and NSEC3PARAM#178

Merged
marc-vanderwal merged 3 commits into
zonemaster:developfrom
marc-vanderwal:bugfix/fix-other-nsec3-methods
Dec 4, 2023
Merged

Fix other methods in Zonemaster::LDNS::RR::NSEC3 and NSEC3PARAM#178
marc-vanderwal merged 3 commits into
zonemaster:developfrom
marc-vanderwal:bugfix/fix-other-nsec3-methods

Conversation

@marc-vanderwal

Copy link
Copy Markdown
Contributor

Purpose

I discovered problems in other accessor methods in Zonemaster::LDNS::RR::NSEC3 and NSEC3PARAM.

The methods in question returned data in the wrong format: instead of the expected binary string, they returned the string prepended with a length byte, which is not very useful and can be misleading. This behavior is not described in the methods’ documentation either.

Context

Preparation of PR #177.

Changes

  • Add MIME::Base32 as a test-time dependency, to improve the legibility of the .t files;
  • Fix Zonemaster::LDNS::RR::NSEC3::next_owner() so that the returned data does not contain a leading length byte;
  • Apply the same change to Zonemaster::LDNS::RR::NSEC3PARAM::salt().

Note: although this PR is to be considered a breaking change, none of the methods were used by Zonemaster::Engine when this PR was originally created (with the develop branch checked out).

How to test this PR

Unit tests should pass.

@marc-vanderwal marc-vanderwal added T-Bug Type: Bug in software or error in test case description V-Major Versioning: The change gives an update of major in version. labels Nov 20, 2023
@marc-vanderwal

Copy link
Copy Markdown
Contributor Author

For the time being, I’m marking this PR as a draft because I’d like #177 merged first.

@matsduf matsduf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

Comment thread Makefile.PL
Some pieces of data in NSEC3 resource records are encoded using the
base32-hex encoding as specified in RFC 4648 § 7.

Yet the unit tests covering NSEC3 resource record objects do not compare
the binary representations of these pieces of data using the base32-hex
encoding, relying instead on base64. This impairs the legibility of
those unit tests.

This commit adds the MIME::Base32 library as a test-time dependency. It
isn’t needed at compile-time or run-time.
The next_owner() method in Zonemaster::LDNS::RR::NSEC3 did not work as
documented.

Its return value was not the value of the next hashed owner name field,
but the same value with the length byte prepended. This choice does not
make the function as useful as one may hope.

This commit ensures that the next_owner() method returns the next hashed
owner name field, and only that.

The unit test for this function compares base64-encoded strings. This
hampers legibility because conversions between base32 and base64 are not
trivial and only a very astute reader would notice that the next_owner()
method had this kind of catch.

As a bonus, add a useful tip in the method’s documentation.
The salt() method in Zonemaster::LDNS::RR::NSEC3PARAM did not work as
documented.

Like two of those accessor methods in NSEC3 I’ve fixed previously, its
return value is a byte string that starts with an extraneous length
byte, which isn’t necessary.

The unit test for this function compares base64-encoded strings. This
hampers legibility because conversions between hexadecimal strings and
base64 strings are not trivial and only a very astute reader would
notice that the salt() method also had a similar problem.

Also improve the documentation and the unit test coverage for that
method.
@marc-vanderwal marc-vanderwal force-pushed the bugfix/fix-other-nsec3-methods branch from f37a23e to 7dfef87 Compare November 21, 2023 14:57
@marc-vanderwal marc-vanderwal marked this pull request as ready for review November 21, 2023 15:02
marc-vanderwal added a commit to marc-vanderwal/zonemaster that referenced this pull request Nov 22, 2023
Pull request zonemaster/zonemaster-ldns#178 adds a test-time dependency
on MIME::Base32. This commit documents the change.

This package should be installed manually in build environments.

The module does not seem to be packaged in Red Hat-based Linux
distributions. On those OSes, the MIME::Base32 has to be installed
through CPAN.
@matsduf

matsduf commented Nov 22, 2023

Copy link
Copy Markdown
Contributor

Conclusion from meeting today that installation instructions are to be updated to include the new dependency.

@marc-vanderwal

Copy link
Copy Markdown
Contributor Author

Conclusion from meeting today that installation instructions are to be updated to include the new dependency.

Yes, I opened a PR to that effect: zonemaster/zonemaster#1223

@tgreenx tgreenx added this to the v2023.2 milestone Nov 23, 2023
@marc-vanderwal marc-vanderwal merged commit 56d96c5 into zonemaster:develop Dec 4, 2023
@marc-vanderwal marc-vanderwal deleted the bugfix/fix-other-nsec3-methods branch August 29, 2024 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Bug Type: Bug in software or error in test case description V-Major Versioning: The change gives an update of major in version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants