Skip to content

be: carry the validator's reason in a refused key's message, so a red key check says why - #88

Merged
landsman merged 7 commits into
mainfrom
ci/keys-runner-dns
Nov 26, 2026
Merged

landsman merged 7 commits into
mainfrom
ci/keys-runner-dns

Conversation

@landsman

Copy link
Copy Markdown
Owner

Refs #77. The key check went red on 2026-11-25 and printed only

org.apache.james.jdkim.exceptions.PermFailException at KeyCheckLiveTest.java:49

which cannot tell a new bank key from a broken chain or a failing resolver. It no longer reproduces: seven runs on 2026-11-26 passed the check, three on a cold resolver cache and two on unmodified main. The runner's resolver (systemd-resolved forwarding to 168.63.129.16) hands the validator every signature it needs:

DIAG raw /127.0.0.53:53 20160512._domainkey.fio.cz. TXT: NOERROR flags=[qr rd ra cd ] answer=1 rrsig=1 ...
DIAG validating via system ab._domainkey.airbank.cz. in 1464 ms: NOERROR AD=true

Every RRSIG on the three chains was valid on the 25th, and the red tests failed within half a second of each other, so the refusals were fast, not timeouts. What the resolver answered then was never logged, so the cause stays unknown, and this does not guess at it.

So the next failure says why. The lookup appends the validator's own reason (a TXT record of class 65280 it adds to the answer) to its refusal, and checkKeys prints the full exception instead of only its class. The same message already reaches Unverified for a caller of withDns(), as .docs/usage.md describes; no API changes.

The refusal tests now pin how each zone is refused. A broken resolver fails every validation, so the two unsigned zones used to pass for the wrong reason; now they go red. Without the reason in the message all three fail, checked locally.

Green on the branch head: https://github.com/landsman/bank-java/actions/runs/45732483886. Diagnostic runs: https://github.com/landsman/bank-java/actions/runs/45731153988 and the cold-cache https://github.com/landsman/bank-java/actions/runs/45731553400 (red only from resolvectl statistics in a diagnostic step, the check passed). Unmodified main: https://github.com/landsman/bank-java/actions/runs/45731958946.

@landsman

Copy link
Copy Markdown
Owner Author

@claude review it

@claude

claude Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Claude finished @landsman's task in 20s —— View job


Review of #88

  • Read the diff and the surrounding code

Verdict: looks good. I have no blocking issues. I only read the code. I did not run the build or the live tests, so the "all three fail without the reason" claim and the green run are as you reported them.

What I checked

  • DnssecKeyLookup.reason(): The imports it needs (Section, TXTRecord, Record, ValidatingResolver) are all present. The instanceof pattern match is safe, and the method returns "" when no reason record exists. That means the two refusal messages stay as before when the validator gives no reason, and the extra text is purely additive.
  • Message format: The messages now end in : <reason>. This matches the prefixes asserted in KeyCheckLiveTest. The names there (x._domainkey.dnssec-failed.org) match how name is built, without the trailing dot.
  • build.gradle.kts: exceptionFormat = FULL is scoped to checkKeys, so normal test output is unchanged. The import is used.
  • Tests: assertRefusedAs is a sensible way to tell the two refusal kinds apart. It requires a non-empty reason after the prefix, so a bare message fails. This also covers the case you describe, where a broken resolver used to let the unsigned-zone tests pass for the wrong reason.

Nits and things to consider

  1. Live-test brittleness: refusesAnUnsignedZone and stillRefusesCsobSlovakia now require the validator to attach a reason to the not-secure branch, and not only to SERVFAIL. If a jdnssec-java upgrade changes when it adds the class-65280 TXT record, the daily check goes red for a reason unrelated to the banks. You verified this locally, so it is a maintenance note. The test comment could say that the reason record is the validator's behaviour that the test depends on.
  2. Workflow comment length: In .github/workflows/keys.yml, the rewrapped comment line ("compares them with what DNS publishes, validated through DNSSEC from the root, and opens an issue when they differ: …") is now noticeably longer than its neighbours. This is cosmetic.
  3. Reason in an exception message: The reason text comes from the validator, and in the case of a bogus answer it can include names from the answer. It reaches Unverified for withDns() callers, as .docs/usage.md says. The text is only a message string, so I see no injection risk. Just make sure nothing downstream renders it as markup.
  4. Root cause still open: This PR does not explain the 2026-11-25 failure. It makes the next one diagnosable, and the description says so. After merge, I'd keep DKIM key check failed #77 open until a red run shows a reason.

I can't edit files under .github/workflows, so I haven't touched nit 2.

@landsman

Copy link
Copy Markdown
Owner Author

Thanks. Point by point:

  1. Fixed in 21bf399: the comment above the refusal tests now says the reason is a record dnsjava's ValidatingResolver adds, so an upgrade that drops it turns them red. make check-keys passes.
  2. Fixed in 4d3c6ba: the header comment in keys.yml is rewrapped to the neighbours' width.
  3. No change. The reason is plain text in an exception message, same as the zone name already in it; rendering it is the caller's concern, as for any message.
  4. Kept as proposed: close DKIM key check failed #77 after the next green scheduled run. The failure step opens an issue only when none is open, so a DKIM key check failed #77 left open would swallow the next red run instead of raising a new issue with the reason in its log.

@landsman
landsman merged commit 0fa0280 into main Nov 26, 2026
5 checks passed
@landsman
landsman deleted the ci/keys-runner-dns branch November 26, 2026 15:18
@landsman landsman mentioned this pull request Nov 27, 2026
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.

1 participant