fix: repair malformed SOA and expand release verification

This commit is contained in:
bryanpedini committed 2026-11-19 15:46:12 +01:00
1 parent 5d7da681e7
commit 3623006f25
11 files changed
+106 -4

No files matched your search

+12 -1
View File
@@ -197,7 +197,10 @@ func validateZoneChanges(zone string, current []recordRow, changes zoneChanges)
after := summarizeZone(result)
problems, warnings = zoneRuleProblems(zone, result, after, true)
soaRepair := len(after.soa) != 0 && soaDefects(after.soa) < soaDefects(before.soa)
soaOnlyRepair := soaRepair && slices.Equal(nonSOARows(current), nonSOARows(result))
soaContentRepair := len(before.soa) == 1 && len(after.soa) == 1 &&
before.soa[0].ID == after.soa[0].ID &&
!validSOAContent(before.soa[0]) && validSOAContent(after.soa[0])
soaOnlyRepair := (soaRepair || soaContentRepair) && slices.Equal(nonSOARows(current), nonSOARows(result))
cnameRepair := soaDefects(after.soa) != 0 && changes.deletesOnly()
if len(problems) != 0 && (soaOnlyRepair || cnameRepair) {
beforeProblems, _ := zoneRuleProblems(zone, current, before, true)
@@ -260,6 +263,14 @@ func deletesOnlyConflictingCNAMEs(ids []int64, problems []zoneProblem) bool {
return true
}
func validSOAContent(row recordRow) bool {
if !row.Content.Valid {
return false
}
_, err := decodeRecord("SOA", row.Content.String)
return err == nil
}
func soaDefects(soa []recordRow) int {
defects := len(soa) - 1
for _, row := range soa {