plugin/file: reject SOA owners that do not match the zone (#8555)

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
This commit is contained in:
houyuwushang
2026-09-17 08:49:58 +08:00
committed by GitHub
parent 73198897ef
commit 84a93a0b89
10 changed files with 302 additions and 29 deletions

View File

@@ -13,9 +13,7 @@ func setupProxyTargetCoreDNS(t *testing.T, fn func(string)) {
tmpdir := t.TempDir()
content := `
example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 1 3600 3600 3600 3600
google.com. IN SOA ns1.google.com. dns-admin.google.com. 1 3600 3600 3600 3600
. IN SOA sns.dns.icann.org. noc.dns.icann.org. 1 3600 3600 3600 3600
google.com. IN A 172.217.25.110
`

View File

@@ -11,13 +11,13 @@ import (
)
func TestZoneReload(t *testing.T) {
name, rm, err := test.TempFile(".", exampleOrg)
name, rm, err := test.TempFile(".", relativeReloadZone)
if err != nil {
t.Fatalf("Failed to create zone: %s", err)
}
defer rm()
// Corefile with two stanzas
// Both stanzas load the same relative zone file with their own origin.
corefile := `
example.org:0 {
file ` + name + ` {
@@ -45,7 +45,9 @@ func TestZoneReload(t *testing.T) {
}
// Remove RR from the Apex
os.WriteFile(name, []byte(exampleOrgUpdated), 0644)
if err := os.WriteFile(name, []byte(relativeReloadZoneUpdated), 0644); err != nil {
t.Fatal(err)
}
time.Sleep(20 * time.Millisecond) // reload time, with some race insurance
@@ -59,9 +61,17 @@ func TestZoneReload(t *testing.T) {
}
}
const exampleOrgUpdated = `; example.org test file
example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082541 7200 3600 1209600 3600
example.org. IN NS b.iana-servers.net.
example.org. IN NS a.iana-servers.net.
example.org. IN A 127.0.0.2
const relativeReloadZone = `
@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082540 7200 3600 1209600 3600
@ IN NS b.iana-servers.net.
@ IN NS a.iana-servers.net.
@ IN A 127.0.0.1
@ IN A 127.0.0.2
`
const relativeReloadZoneUpdated = `
@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082541 7200 3600 1209600 3600
@ IN NS b.iana-servers.net.
@ IN NS a.iana-servers.net.
@ IN A 127.0.0.2
`