Skip to content

zone_record: compare packed fields as the RR class reads them - #97

Merged
msimerson merged 4 commits into
mainfrom
zr-rrsig-normalized-check
Nov 17, 2026
Merged

msimerson merged 4 commits into
mainfrom
zr-rrsig-normalized-check

Conversation

@msimerson

Copy link
Copy Markdown
Contributor

checkRecord packs a record's fields into their shared column, unpacks them, and requires each back byte for byte:

const garbled = packed.find((f) => String(copy[f] ?? '') !== String(record[f] ?? ''))

NicTool/dns-resource-record#72 maps RRSIG into address as BIND text, the way NicTool 2 stores it. Packing rewrites three things the api schema accepts:

Sent Stored
'type covered': 1 A
'signature expiration': 1045053120 20030212123200
a signature with spaces the signature without them

Each fails the byte comparison, so the RRSIG returns 400 RRSIG: type covered can't be stored as given. That includes the library's own RRSIG.getCanonical(). Before #72 RRSIG had no map, so it skipped this check.

#95 runs checkRecord on any PUT that changes rdata, on json and toml as well as mysql, and the UI's zone-record save sends every rdata field. Once a dns-resource-record release carries #72, which ^2.0.0 picks up, every UI edit of an RRSIG holding a type number or times in seconds would fail.

checkRecord now builds the RR class from both the record and its packed round trip, and compares their fields. If the round trip doesn't build, the field whose text changed is named, as before. A NAPTR field holding the column delimiter is still refused.

Tested on json and toml (650/650). Not run on mysql locally.

checkRecord required each packed field back from its shared column byte
for byte. dns-resource-record #72 packs RRSIG as BIND text the way
NicTool 2 stores it, which rewrites a type number as its mnemonic, times
in seconds as YYYYMMDDHHmmSS stamps, and drops spaces from the
signature. The api schema accepts all three, so such an RRSIG was
refused as "can't be stored as given". Since #95, any PUT that changes
rdata runs this check, and the UI sends every rdata field.

Both the record and its packed round trip now go through the RR class,
and their fields are compared. A value that splits differently, such as
a NAPTR field holding the column delimiter, is still refused.

Cross-package: needed before the dns-resource-record release with #72,
which ^2.0.0 picks up.
The previous commit compared the RR class's values strictly, so a NAPTR
created without a regexp, which unpacks as '', was refused on mysql. The
byte comparison it replaced treated the two alike.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues require changes to the zone-record validation update.

No open issues 🎉

What changed in this PR

Updates zone-record validation to compare packed fields as interpreted by the DNS record classes, allowing equivalent RRSIG representations while still rejecting data altered by packing.

Changes:

  • Compares normalized field values after packing and unpacking, preserving field-specific errors.
  • Adds tests for accepted RRSIG representations, omitted NAPTR fields, and rejected delimiter corruption.
  • Documents the RRSIG validation fix in the changelog.
File Description
lib/​zone_record/​store/​base.test.js Adds regression coverage for normalized packed fields and corruption detection.
lib/​zone_record/​store/​base.js Validates packed round trips using DNS record class field values.
CHANGELOG.md Records support for RRSIG type numbers and timestamps in seconds.

Review effort: Balanced

@msimerson
msimerson merged commit 0f67938 into main Nov 17, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants