Skip to content

zone_record: PUT checks the rdata it changes - #95

Merged
msimerson merged 4 commits into
NicTool:mainfrom
aberoham:zr-put-rdata
Nov 16, 2026
Merged

msimerson merged 4 commits into
NicTool:mainfrom
aberoham:zr-put-rdata

Conversation

@aberoham

@aberoham aberoham commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

PUT /zone_record checked the merged record only when the type changed, or a field packed into a shared column (#77). Any other rdata edit went straight to the store, so an A record took 1.2.3:

PUT /zone_record/{id} {"address":"1.2.3"}  → 200, stored

A PUT that changes any rdata field now runs the same check as create() on the merged record. That PUT answers 400. A field sent back as stored is not a change, so a TTL edit from the web UI isn't checked.

The wider check met two older faults in checkRecord. It required an address of types that have none, such as RRSIG and SIG. json and toml store those types. The wider check would refuse every rdata edit to them. A main field is now required only of a type that has one. mysql has no columns for those types, and now refuses them by name rather than for a missing address.

It also checked a placeholder owner in place of the record's own. An RRSIG signed by its owner therefore failed. An absolute owner is now checked as given, as create() on mysql already does. A relative owner is checked under its zone.

The mysql store also dropped an SRV priority of 0 on read. A valid SRV then read back invalid. The wider check would refuse its rdata edits. It now keeps the 0, as json and toml do. GET of such a record on mysql now includes priority: 0.

Concurrent PUTs to different rdata columns of one record are each checked against the record as read, on mysql.

@aberoham

Copy link
Copy Markdown
Contributor Author

The ubuntu test and coverage jobs fail at sudo /etc/init.d/mysql start, before any test runs. ubuntu-latest moved to 26.04. It has no init.d script. api#96 and NicTool/.github#9 fix the workflows.

@msimerson

msimerson commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor
  1. The "TTL edit isn't checked" carve-out never applies to the web UI. The save handler (server/web/src/app.js:1147) sends every rdata field on every PUT, and checkPut tests f in changes, not whether the value changed. So every UI edit gets the full check. A record already stored invalid can't take a TTL-only fix from the UI until its rdata is fixed too. The PR body and CHANGELOG describe the API behaviour accurately, but that's not what UI users will see.
  2. The CHANGELOG entries for the first and third fixes are not succinct.
  3. The "has no address field" test is written twice, in base.js checkRecord and in mysql.js checkStorable.
  4. The RRSIG test in lib/zone_record/test/index.js changes what it asserts depending on storeType(). Mysql then never exercises the owner-check path.

PUT only checked the merged record when the type or a packed field changed, so
an A record took address 1.2.3. A PUT carrying any rdata field now runs the
same check as create() on the merged record. A PUT without one, such as a ttl
edit, is not checked.

A record that fails the check, such as one from v2 or an earlier PUT, still
takes a ttl-only edit. Any PUT carrying its rdata, a whole record sent back
included, is refused unless it leaves the record valid. json and toml create()
skip the check, and PUT writes an owner without it, so both can still store
such a record.

checkRecord required an address of every type without a column map, such as
RRSIG and SIG. json and toml store those types, so the wider check would have
refused every rdata edit to them. It now requires a main field only of a type
that has one. mysql has no columns for those types, and refuses them by name.

The check replaced the owner with a placeholder, so an RRSIG signed by its own
owner failed. An absolute owner is now checked as given, as create() does.

The mysql store dropped an SRV priority of 0 when reading, so a valid SRV read
back invalid and every rdata edit to it would be refused. It now keeps that 0,
as json and toml do.
The schema takes the covered type as text, so the test sends 'A' and the times as stamps. The test then passes before and after dns-resource-record maps RRSIG into mysql's columns.
The web UI sends every rdata field on every save, so a TTL edit to a
record stored invalid was refused. A field sent back as stored is no
longer a change.

One helper names a type's main field for checkRecord and mysql. The
RRSIG and NAPTR checks are now unit tests of checkPut, so every store
runs them.
@aberoham

Copy link
Copy Markdown
Contributor Author

Rebased onto main. That drops your merge commit.

  1. Fixed in a2b3b9f.
  2. Shortened in 5a68e65.
  3. Fixed in a2b3b9f.
  4. Fixed in a2b3b9f. mysql can't store an RRSIG until dns-resource-record#72 is released.

json and toml store a relative owner as given, and v2 rows on mysql
hold one too. The PUT check put the placeholder in its place. An RRSIG
owned by www in example.com then failed its labels and signer checks
on any signature edit.
@msimerson
msimerson merged commit 181a9fa into NicTool:main Nov 16, 2026
10 of 11 checks passed
@aberoham
aberoham deleted the zr-put-rdata branch November 16, 2026 18:35
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