Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --hints option #284

Merged
merged 4 commits into from
Oct 28, 2022
Merged

Add --hints option #284

merged 4 commits into from
Oct 28, 2022

Conversation

mattias-p
Copy link
Member

Purpose

Allow the user to override the built in root hints.

Context

This change depends on zonemaster/zonemaster-engine#1134.

Changes

A new --hints=FILENAME option is added.

How to test this PR

  1. Set up a custom root zone.
  2. Create a root hints file (named.custom-root) for the custom root zone.
  3. Run some zonemaster-cli tests with --hints named.custom-root and make sure it works as expected.

@mattias-p
Copy link
Member Author

This PR fails in CI because it depends on zonemaster/zonemaster-engine#1134 and that one hasn't been merged yet. When I run the test locally against that version of Engine the tests pass just fine.

@mattias-p mattias-p added the T-Feature Type: New feature in software or test case description label Oct 19, 2022
matsduf
matsduf previously approved these changes Oct 24, 2022
Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

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

It works as it should when using a legal file after installing the correct version of Engine too.

When I make the local name.root file break some of the rules, it stops, but the error message is hard to understand because the context is missing. I accept as-is, and it could be improved later.

Examples:

$ zonemaster-cli --show-testcase --level INFO xa --hint /usr/local/etc/zonemaster/named.root--xa 
Seconds Level     Testcase       Message
======= ========= ============== =======
Forbidden directive $TTL
$ zonemaster-cli --show-testcase --level INFO xa --hint /usr/local/etc/zonemaster/named.root--xa 
Seconds Level     Testcase       Message
======= ========= ============== =======
Owner name for NS record must be "."

@mattias-p
Copy link
Member Author

I made an update to add some context to the error message. I also postponed the printing of column headers until just before we start running the actual test.

Error loading hints file: Owner name for NS record must be "."

Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

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

Looks fine with the updated error messages.

@matsduf
Copy link
Contributor

matsduf commented Oct 28, 2022

@marc-vanderwal, could you review this too? It is related to zonemaster/zonemaster-engine#1134 that you reviewed.

Copy link
Contributor

@marc-vanderwal marc-vanderwal left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@matsduf
Copy link
Contributor

matsduf commented Oct 28, 2022

@mattias-p, could you merge?

@mattias-p mattias-p merged commit 3a4dbff into zonemaster:develop Oct 28, 2022
@matsduf matsduf added the V-Minor Versioning: The change gives an update of minor in version. label Oct 28, 2022
@tgreenx tgreenx added the S-ReleaseTested Status: The PR has been successfully tested in release testing label Dec 7, 2022
Copy link
Contributor

@tgreenx tgreenx left a comment

Choose a reason for hiding this comment

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

I found one potential issue (not linked to this PR) during release testing (2022-2). See first snipet below. Test will start without any error, and considers the option to be turned off when set to 0. This is also the case for other options in CLI that take a file (string) as input (e.g., --restore). Can this be considered intended behavior? If not then an issue should be opened in CLI. I think it has to do with Moose.

$ ls -l
total 4
-rw-r--r-- 1 tgreen tgreen 53 Dec  8 14:26 named.custom-root

$ zonemaster-cli --hints 0 zonemaster.net
Seconds Level     Message
======= ========= =======
[...] // NO ERROR

$ zonemaster-cli --restore 0 zonemaster.fr
Seconds Level     Message
======= ========= =======
[...] // NO ERROR

If I create file '0' and pass it as hint to CLI:

$ ls -l
total 8
-rw-r--r-- 1 tgreen tgreen 44 Dec  8 14:59 0
-rw-r--r-- 1 tgreen tgreen 53 Dec  8 14:26 named.custom-root

$ cat 0
.		IN	NS	ns.fake.
ns.fake.	IN	A	192.168.1.1

$ zonemaster-cli --hints 0 zonemaster.fr
Seconds Level     Message
======= ========= =======
[ ... ] // NO ERROR

$ zonemaster-cli --hints '0' zonemaster.fr
Seconds Level     Message
======= ========= =======
[ ... ] // NO ERROR

Other use cases appear to be handled correctly:

$ cat named.custom-root 
.	        IN 	NS 	ns.fake.
ns.fake.	IN	A	192.168.1.1

$ zonemaster-cli --hints 5 zonemaster.fr
Error loading hints file: read_file '5' - open: No such file or directory at /usr/local/share/perl/5.32.1/Zonemaster/CLI.pm line 496.

$ zonemaster-cli --hints @123! zonemaster.fr
Error loading hints file: read_file '@123!' - open: No such file or directory at /usr/local/share/perl/5.32.1/Zonemaster/CLI.pm line 496.

$ zonemaster-cli --hints -1 zonemaster.fr
Error loading hints file: read_file '-1' - open: No such file or directory at /usr/local/share/perl/5.32.1/Zonemaster/CLI.pm line 496.

$ zonemaster-cli --hints named.custom-root zonemaster.fr
Seconds Level     Message
======= ========= =======
[...] // EXPECTED ERROR

$ zonemaster-cli --hints 'named.custom-root' zonemaster.fr
Seconds Level     Message
======= ========= =======
[...] // EXPECTED ERROR

$ zonemaster-cli --restore 1 zonemaster.fr
Failed to open restore data file: No such file or directory

@matsduf
Copy link
Contributor

matsduf commented Dec 8, 2022

I file with name "0" cannot be true in the world of Perl. But file "00" is a true file.

@marc-vanderwal
Copy link
Contributor

For now a possible workaround is to use --hints ./0 instead of --hints 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-ReleaseTested Status: The PR has been successfully tested in release testing T-Feature Type: New feature in software or test case description V-Minor Versioning: The change gives an update of minor in version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants