feat: manage TLSA records
Test / test (push) Successful in 28m4s
Build and publish image / image (push) Successful in 28m43s

This commit is contained in:
bryanpedini committed 2026-11-22 11:31:59 +01:00
1 parent 9c2fb9d15b
commit a67183b646
14 files changed
+141 -15

No files matched your search

+18 -1
View File
@@ -47,6 +47,8 @@ func TestRecordCanonicalEncodingAndPluginRR(t *testing.T) {
{"SRV", "_https._tcp.dev", `{"port":443,"weight":0,"priority":65535,"target":"@"}`, `{"priority":65535,"weight":0,"port":443,"target":"example.org."}`, "65535 0 443 example.org."},
{"SRV", "_https._tcp", `{"port":0,"weight":65535,"priority":0,"target":"."}`, `{"priority":0,"weight":65535,"port":0,"target":"."}`, "0 65535 0 ."},
{"CAA", "", `{"value":"ca.example.net","tag":"issue","flag":0}`, `{"flag":0,"tag":"issue","value":"ca.example.net"}`, `0 issue "ca.example.net"`},
{"TLSA", "_25._tcp.mail", `{"certificate":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","matching_type":1,"selector":1,"usage":3}`, `{"usage":3,"selector":1,"matching_type":1,"certificate":"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}`, "3 1 1 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"},
{"TLSA", "_443._tcp", `{"usage":255,"selector":255,"matching_type":255,"certificate":"00"}`, `{"usage":255,"selector":255,"matching_type":255,"certificate":"00"}`, "255 255 255 00"},
{"SOA", "@", `{"MBox":"First.Last@EXAMPLE.ORG","ns":"Ns.Example.Net","serial":4294967295,"minttl":0,"expire":2147483647,"retry":600,"refresh":3600}`,
`{"ns":"ns.example.net.","MBox":"first\\.last.example.org.","refresh":3600,"retry":600,"expire":2147483647,"minttl":0,"serial":4294967295}`,
`ns.example.net. first\.last.example.org. 4294967295 3600 600 2147483647 0`},
@@ -132,6 +134,21 @@ func TestRecordFieldValidation(t *testing.T) {
{"CAA", "x", `{"flag":0,"tag":"Issue","value":"ca.example"}`, "tag", 0},
{"CAA", "x", `{"flag":0,"tag":"a1234567890abcde","value":"ca.example"}`, "tag", 0},
{"CAA", "x", `{"flag":0,"tag":"issue","value":""}`, "value", 0},
{"TLSA", "_25._tcp", `{"usage":0,"selector":0,"matching_type":0,"certificate":"ab"}`, "", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":1,"certificate":"` + strings.Repeat("ab", 32) + `"}`, "", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":1,"certificate":"` + strings.Repeat("ab", 31) + `"}`, "certificate", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":2,"certificate":"` + strings.Repeat("ab", 64) + `"}`, "", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":2,"certificate":"` + strings.Repeat("ab", 32) + `"}`, "certificate", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":0,"certificate":""}`, "certificate", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":0,"certificate":"abc"}`, "certificate", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":0,"certificate":"not-hex"}`, "certificate", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":0,"certificate":"0x12"}`, "certificate", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":0,"certificate":"` + strings.Repeat("ab", 65533) + `"}`, "certificate", 0},
{"TLSA", "_25._tcp", `{"usage":256,"selector":1,"matching_type":0,"certificate":"ab"}`, "usage", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":-1,"matching_type":0,"certificate":"ab"}`, "selector", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":"1","certificate":"ab"}`, "matching_type", 0},
{"TLSA", "_25._tcp", `{"selector":1,"matching_type":0,"certificate":"ab"}`, "usage", 0},
{"TLSA", "_25._tcp", `{"usage":3,"selector":1,"matching_type":0}`, "certificate", 0},
{"SOA", "child", `{"ns":"ns.example.","MBox":"hostmaster.example.","refresh":0,"retry":0,"expire":0,"minttl":0}`, "name", 0},
{"SOA", "@", `{"ns":"ns.example.","MBox":"hostmaster.example.","refresh":2147483648,"retry":0,"expire":0,"minttl":0}`, "refresh", 0},
{"SOA", "@", `{"ns":"ns.example.","MBox":"hostmaster.example.","refresh":0,"retry":0,"expire":0,"minttl":0,"serial":4294967296}`, "serial", 0},
@@ -190,7 +207,7 @@ func TestPluginRRLegacyRows(t *testing.T) {
if rr, err := recordRR(soa, modelNow); err != nil || rr.Header().Name != soa.Zone || rr.(*dns.SOA).Serial != uint32(modelNow.Unix()) {
t.Fatalf("raw populated SOA = %v, %v", rr, err)
}
for _, typ := range []string{"A", "AAAA", "CNAME", "NS", "MX", "TXT", "SRV", "CAA"} {
for _, typ := range []string{"A", "AAAA", "CNAME", "NS", "MX", "TXT", "SRV", "CAA", "TLSA"} {
row := modelRawRow(1, "child", typ, 0, `{}`)
if rr, err := recordRR(row, modelNow); rr != nil || err != nil || recordValue(row, modelNow) != "{}" {
t.Errorf("raw empty %s = %v, %v", typ, rr, err)