checker: add dname_coexistence rule and refactor sibling probing
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

Extract querySiblings from observeCoexistence so both CNAME and DNAME
coexistence checks share the same parallel RRset scan. Add
observeDNAMECoexistence (called from Collect) that populates
AliasData.DNAMECoexistence for each DNAME node in DNAMESubstitutions.
Add the dname_coexistence rule (RFC 6672 §2.3) that flags any sibling
RRsets at a DNAME owner as CRIT, with matching tests.
This commit is contained in:
nemunaire 2026-05-16 21:35:53 +08:00
commit c5c13960d5
5 changed files with 112 additions and 12 deletions

View file

@ -7,6 +7,41 @@ import (
sdk "git.happydns.org/checker-sdk-go/checker"
)
type dnameCoexistenceRule struct{}
func (dnameCoexistenceRule) Name() string { return "dname_coexistence" }
func (dnameCoexistenceRule) Description() string {
return "Flags RRsets that sit at the same owner as a DNAME (RFC 6672 §2.3)."
}
func (dnameCoexistenceRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
data, errState := loadAlias(ctx, obs)
if errState != nil {
return errState
}
if !apexKnown(data) {
return skipped("apex lookup failed")
}
if len(data.DNAMESubstitutions) == 0 {
return skipped("no DNAME in chain")
}
if len(data.DNAMECoexistence) == 0 {
return okState(data.Owner, "all DNAME nodes have no sibling records")
}
var out []sdk.CheckState
for owner, coexisting := range data.DNAMECoexistence {
for _, rr := range coexisting {
out = append(out, withHint(sdk.CheckState{
Status: sdk.StatusCrit,
Subject: owner,
Message: fmt.Sprintf("%s and DNAME both exist at %s (RFC 6672 §2.3)", rr.Type, owner),
Code: rr.Type,
}, "Remove the sibling record or move it under a different label; a DNAME owner must not carry other data."))
}
}
return out
}
type cnameCoexistenceRule struct{}
func (cnameCoexistenceRule) Name() string { return "cname_coexistence" }