checker: add dname_coexistence rule and refactor sibling probing
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:
parent
1493ef4d3f
commit
c5c13960d5
5 changed files with 112 additions and 12 deletions
|
|
@ -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" }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue