zonemaster-cli icon indicating copy to clipboard operation
zonemaster-cli copied to clipboard

Add option to CLI to check validity of profile files (without having to run a test)

Open andreasschulze opened this issue 1 year ago • 2 comments

I'm building zonemaster and distribute some customized profile files.

For some reasons, these files got broken. This was detected very late in production.
So I would test at build time, if a given file is a valid profile. Something like --profile /path/to/file --test-profile would be helpful.

Or are there other options available today?

andreasschulze avatar Dec 18 '24 13:12 andreasschulze

@andreasschulze, it is a valid point. Today we do not have any direct validation tool, but the other day I created a customized profile, and made some error. When I tried to use it with zonemaster-cli with option --profile /path/to/profile-file it "crashed" and output a fairly helpful error message.

Maybe trying it with zonemaster-cli could be a work-around, or even a way to test. If you test some non-existing TLD such as xa or a domain with option --test basic01 it will be fairly quick. Maybe you can script this and read the exit code from zonemaster-cli.

If you have kept the faulty profile file, then please test it and report back if zonemaster-cli could catch the error.

matsduf avatar Dec 18 '24 14:12 matsduf

Thanks for the hint.

The following produce a determenistic result whether a profile is valid or not:

$ zonemaster-cli --no-progress --dump-profile > /default.profile
$ zonemaster-cli --no-progress --profile /default.profile --test basic01 xa.; echo $?
Loading profile from /default.profile.

Seconds Level    Message
======= ======== =======
   7.00 ERROR    "xa" does not exist as a DNS zone. Try to test "." instead.
0

with an 'invalid' profile:

# zonemaster-cli --no-progress --profile /etc/issue --test basic01 xa.; echo $?
Loading profile from /etc/issue.
malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "Debian GNU/Linux 12 ...") at /usr/local/share/perl/5.36.0/Zonemaster/Engine/Profile.pm line 400.
1

This looks like a valid detection for broken profile files. For now, I'm fine with that.

andreasschulze avatar Dec 19 '24 10:12 andreasschulze