Commit 364d78222a for bind
commit 364d78222a5f775e90f2f219d4061b7adb8311d3
Author: Štěpán Balážik <stepan@isc.org>
Date: Mon Oct 19 17:22:57 2026 +0200
Serve the f023 reproducer from a server of its own
ans1 served two unrelated reproducers, told apart by zone. Move f023
to ans4 unchanged, with the static-stubs and the test pointing at it,
so that each server can be rewritten on its own.
Assisted-by: Claude:claude-fable-5-1
diff --git a/bin/tests/system/nsec_synthesis/ans1/ans.py b/bin/tests/system/nsec_synthesis/ans1/ans.py
index 3df33bb19c..0528197e4d 100644
--- a/bin/tests/system/nsec_synthesis/ans1/ans.py
+++ b/bin/tests/system/nsec_synthesis/ans1/ans.py
@@ -10,14 +10,13 @@
# information regarding copyright ownership.
from isctest.asyncserver import AsyncDnsServer
-from nsec_synthesis.ans1 import common, f004, f023
+from nsec_synthesis.ans1 import common, f004
def main() -> None:
keys = common.load_keys()
server = AsyncDnsServer(default_aa=True)
server.install_response_handler(f004.F004Handler(keys))
- server.install_response_handler(f023.F023Handler(keys))
server.run()
diff --git a/bin/tests/system/nsec_synthesis/ans4/ans.py b/bin/tests/system/nsec_synthesis/ans4/ans.py
new file mode 100644
index 0000000000..d30e96bc3f
--- /dev/null
+++ b/bin/tests/system/nsec_synthesis/ans4/ans.py
@@ -0,0 +1,24 @@
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+from isctest.asyncserver import AsyncDnsServer
+from nsec_synthesis.ans4 import common, f023
+
+
+def main() -> None:
+ keys = common.load_keys()
+ server = AsyncDnsServer(default_aa=True)
+ server.install_response_handler(f023.F023Handler(keys))
+ server.run()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/bin/tests/system/nsec_synthesis/ans4/common.py b/bin/tests/system/nsec_synthesis/ans4/common.py
new file mode 100644
index 0000000000..da10366591
--- /dev/null
+++ b/bin/tests/system/nsec_synthesis/ans4/common.py
@@ -0,0 +1,105 @@
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+from dataclasses import dataclass
+from pathlib import Path
+
+import json
+
+from cryptography.hazmat.primitives import serialization
+
+import dns.dnssec
+import dns.flags
+import dns.message
+import dns.name
+import dns.rcode
+import dns.rdata
+import dns.rdataclass
+import dns.rdatatype
+import dns.rrset
+
+from isctest.asyncserver import QueryContext
+
+TTL = 300
+
+
+@dataclass(frozen=True)
+class Key:
+ zone: dns.name.Name
+ private_key: object
+ dnskey: dns.rdata.Rdata
+ ds: dns.rdata.Rdata
+
+
+def name(text: str) -> dns.name.Name:
+ return dns.name.from_text(text)
+
+
+def load_keys() -> dict[str, Key]:
+ keys = {}
+
+ path = Path(".") / "keys.json"
+ if not path.exists():
+ return keys
+
+ with path.open(encoding="utf-8") as keys_file:
+ raw_keys = json.load(keys_file)
+
+ for zone, raw_key in raw_keys.items():
+ private_key = serialization.load_pem_private_key(
+ raw_key["private_pem"].encode("ascii"),
+ password=None,
+ )
+ dnskey = dns.rdata.from_text(
+ dns.rdataclass.IN, dns.rdatatype.DNSKEY, raw_key["dnskey"]
+ )
+ ds = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.DS, raw_key["ds"])
+ keys[zone] = Key(name(zone), private_key, dnskey, ds)
+
+ return keys
+
+
+def rrset(owner: str, rdtype: dns.rdatatype.RdataType, *rdatas: str) -> dns.rrset.RRset:
+ return dns.rrset.from_text(owner, TTL, dns.rdataclass.IN, rdtype, *rdatas)
+
+
+def rrset_from_rdata(owner: str, rdata: dns.rdata.Rdata) -> dns.rrset.RRset:
+ return dns.rrset.from_rdata(owner, TTL, rdata)
+
+
+def add_signed(
+ section: list[dns.rrset.RRset], covered: dns.rrset.RRset, signer: Key
+) -> None:
+ rrsig = dns.dnssec.sign(
+ covered,
+ signer.private_key,
+ signer.zone,
+ signer.dnskey,
+ lifetime=86400,
+ verify=True,
+ )
+ section.append(covered)
+ section.append(dns.rrset.from_rdata(covered.name, covered.ttl, rrsig))
+
+
+def soa_rrset(zone) -> dns.rrset.RRset:
+ return rrset(
+ zone,
+ dns.rdatatype.SOA,
+ f"ns.{zone} hostmaster.{zone} 1 3600 600 86400 300",
+ )
+
+
+def prepare_response(qctx: QueryContext) -> dns.message.Message:
+ qctx.prepare_new_response(with_zone_data=False)
+ qctx.response.flags |= dns.flags.AA
+ qctx.response.set_rcode(dns.rcode.NOERROR)
+ return qctx.response
diff --git a/bin/tests/system/nsec_synthesis/ans1/f023.py b/bin/tests/system/nsec_synthesis/ans4/f023.py
similarity index 99%
rename from bin/tests/system/nsec_synthesis/ans1/f023.py
rename to bin/tests/system/nsec_synthesis/ans4/f023.py
index fe833034af..4f7cd23f30 100644
--- a/bin/tests/system/nsec_synthesis/ans1/f023.py
+++ b/bin/tests/system/nsec_synthesis/ans4/f023.py
@@ -24,7 +24,7 @@ import dns.rrset
from isctest.asyncserver import QueryContext, ResponseHandler
from isctest.asyncserver.actions import DnsResponseSend
from isctest.asyncserver.matchers import Domain
-from nsec_synthesis.ans1.common import (
+from nsec_synthesis.ans4.common import (
Key,
add_signed,
name,
diff --git a/bin/tests/system/nsec_synthesis/ns2/named.conf.j2 b/bin/tests/system/nsec_synthesis/ns2/named.conf.j2
index d6eb8dccea..b3817d4295 100644
--- a/bin/tests/system/nsec_synthesis/ns2/named.conf.j2
+++ b/bin/tests/system/nsec_synthesis/ns2/named.conf.j2
@@ -22,12 +22,12 @@ zone "f007.test" {
zone "f023.test" {
type static-stub;
- server-addresses { 10.53.0.1; };
+ server-addresses { 10.53.0.4; };
};
zone "evil.f023.test" {
type static-stub;
- server-addresses { 10.53.0.1; };
+ server-addresses { 10.53.0.4; };
};
{% include "_common/trusted.conf.j2" %}
diff --git a/bin/tests/system/nsec_synthesis/tests_nsec_child_next.py b/bin/tests/system/nsec_synthesis/tests_nsec_child_next.py
index ddd6efa6b4..56eab9f9af 100644
--- a/bin/tests/system/nsec_synthesis/tests_nsec_child_next.py
+++ b/bin/tests/system/nsec_synthesis/tests_nsec_child_next.py
@@ -30,7 +30,7 @@ POISON = f"0.{EVIL}"
POISON_NEXT = f"zzz.{F023_ZONE}"
TARGET = f"target.{F023_ZONE}"
TARGET_A = "192.0.2.77"
-AUTH = "10.53.0.1"
+AUTH = "10.53.0.4"
RESOLVER = "10.53.0.2"
pytestmark = SIGNED_ZONE_MARKS
@@ -38,7 +38,7 @@ pytestmark = SIGNED_ZONE_MARKS
def bootstrap():
keys = {F023_ZONE: make_key(F023_ZONE)}
- Path("ans1/keys.json").write_text(json.dumps(keys, indent=2), encoding="ascii")
+ Path("ans4/keys.json").write_text(json.dumps(keys, indent=2), encoding="ascii")
dnskey = keys[F023_ZONE]["dnskey"].split()
contents = f'{" ".join(dnskey[:3])} "{"".join(dnskey[3:])}"'
return {"trust_anchors": [TrustAnchor(F023_ZONE, "static-key", contents)]}