Commit b5abafd88a for bind

commit b5abafd88a9b843311184149f35eb991bf463d11
Author: Štěpán Balážik <stepan@isc.org>
Date:   Mon Oct 26 11:10:19 2026 +0100

    Take the nsec_synthesis servers from the test fixtures

    Each module kept the resolver's and the authoritative server's
    addresses in constants of its own, one of them a literal, pending_cd
    opened ans1's log by path, and ns2's static-stubs listed the servers'
    addresses.  The tests now take the servers as their ns2, ns3, ans1 and
    ans4 fixtures, and ns2's template names them.

    Assisted-by: Claude:claude-fable-5-1

diff --git a/bin/tests/system/nsec_synthesis/ns2/named.conf.j2 b/bin/tests/system/nsec_synthesis/ns2/named.conf.j2
index b3817d4295..2e784a2cc1 100644
--- a/bin/tests/system/nsec_synthesis/ns2/named.conf.j2
+++ b/bin/tests/system/nsec_synthesis/ns2/named.conf.j2
@@ -1,5 +1,9 @@
 // validating resolver

+{% set ans1 = Nameserver("ans1") %}
+{% set ans4 = Nameserver("ans4") %}
+{% set ns3 = Nameserver("ns3") %}
+
 options {
 	{% include_indented "_common/options.conf.j2" %}
 	dnssec-validation yes;
@@ -12,22 +16,22 @@ options {

 zone "f004.test" {
 	type static-stub;
-	server-addresses { 10.53.0.1; };
+	server-addresses { @ans1.ip@; };
 };

 zone "f007.test" {
 	type static-stub;
-	server-addresses { 10.53.0.3; };
+	server-addresses { @ns3.ip@; };
 };

 zone "f023.test" {
 	type static-stub;
-	server-addresses { 10.53.0.4; };
+	server-addresses { @ans4.ip@; };
 };

 zone "evil.f023.test" {
 	type static-stub;
-	server-addresses { 10.53.0.4; };
+	server-addresses { @ans4.ip@; };
 };

 {% 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 68a7c8cec2..ff0d032247 100644
--- a/bin/tests/system/nsec_synthesis/tests_nsec_child_next.py
+++ b/bin/tests/system/nsec_synthesis/tests_nsec_child_next.py
@@ -26,8 +26,6 @@ POISON = f"0.{EVIL}"
 POISON_NEXT = f"zzz.{F023_ZONE}"
 TARGET = f"target.{F023_ZONE}"
 TARGET_A = "192.0.2.77"
-AUTH = isctest.template.ANS4.ip
-RESOLVER = isctest.template.NS2.ip

 pytestmark = SIGNED_ZONE_MARKS

@@ -40,18 +38,18 @@ def bootstrap():
     return {"trust_anchors": zone.trust_anchors()}


-def _prime_parent_for_aggressive_nsec():
-    soa = isctest.query.tcp(isctest.query.create(F023_ZONE, "SOA"), RESOLVER)
+def _prime_parent_for_aggressive_nsec(resolver):
+    soa = isctest.query.tcp(isctest.query.create(F023_ZONE, "SOA"), resolver.ip)
     isctest.check.noerror(soa)
     isctest.check.adflag(soa)

-    nsec = isctest.query.tcp(isctest.query.create(F023_ZONE, "NSEC"), RESOLVER)
+    nsec = isctest.query.tcp(isctest.query.create(F023_ZONE, "NSEC"), resolver.ip)
     isctest.check.noerror(nsec)
     isctest.check.adflag(nsec)


-def test_direct_insecure_child_nsec_next_fixture(f023_key_tags):
-    poison = isctest.query.tcp(isctest.query.create(POISON, "NSEC"), AUTH)
+def test_direct_insecure_child_nsec_next_fixture(ans4, f023_key_tags):
+    poison = isctest.query.tcp(isctest.query.create(POISON, "NSEC"), ans4.ip)
     isctest.check.noerror(poison)
     isctest.check.aaflag(poison)
     check_forged_nsec(
@@ -59,17 +57,17 @@ def test_direct_insecure_child_nsec_next_fixture(f023_key_tags):
     )


-def test_resolver_does_not_synth_from_insecure_child_nsec(f023_key_tags):
-    _prime_parent_for_aggressive_nsec()
+def test_resolver_does_not_synth_from_insecure_child_nsec(ns2, f023_key_tags):
+    _prime_parent_for_aggressive_nsec(ns2)

-    poison = isctest.query.tcp(isctest.query.create(POISON, "NSEC"), RESOLVER)
+    poison = isctest.query.tcp(isctest.query.create(POISON, "NSEC"), ns2.ip)
     isctest.check.noerror(poison)
     isctest.check.noadflag(poison)
     check_forged_nsec(
         poison, poison.answer, POISON, POISON_NEXT, F023_ZONE, f023_key_tags
     )

-    response = isctest.query.tcp(isctest.query.create(TARGET, "A"), RESOLVER)
+    response = isctest.query.tcp(isctest.query.create(TARGET, "A"), ns2.ip)
     isctest.check.noerror(response)
     assert has_a(response, TARGET, TARGET_A), response.to_text()
     isctest.check.adflag(response)
diff --git a/bin/tests/system/nsec_synthesis/tests_nsec_exact_nodata.py b/bin/tests/system/nsec_synthesis/tests_nsec_exact_nodata.py
index 40bb87cd13..8634e080da 100644
--- a/bin/tests/system/nsec_synthesis/tests_nsec_exact_nodata.py
+++ b/bin/tests/system/nsec_synthesis/tests_nsec_exact_nodata.py
@@ -21,10 +21,8 @@ from nsec_synthesis.common import (
 )

 import isctest
-import isctest.template

 POISON_NEXT = f"z.{F004_ZONE}"
-RESOLVER = isctest.template.NS2.ip

 pytestmark = SIGNED_ZONE_MARKS

@@ -33,7 +31,7 @@ def bootstrap():
     return f004_bootstrap()


-def test_pending_exact_nodata_nsec_cache_poisoning(f004_key_tags):
+def test_pending_exact_nodata_nsec_cache_poisoning(ns2, f004_key_tags):
     """
     Companion to #5872 that covers the query_coveringnsec() trust check on
     the exact-match NODATA branch (the `if (exists)` path in ns/query.c),
@@ -45,14 +43,14 @@ def test_pending_exact_nodata_nsec_cache_poisoning(f004_key_tags):
     victim's real A record.
     """
     # Prime the zone SOA (and the DNSKEY as a subquery) at secure trust.
-    soa = isctest.query.tcp(isctest.query.create(F004_ZONE, "SOA"), RESOLVER)
+    soa = isctest.query.tcp(isctest.query.create(F004_ZONE, "SOA"), ns2.ip)
     isctest.check.noerror(soa)
     isctest.check.adflag(soa)

     # Inject a forged NSEC owned by the victim name via a CD=1 query; it is
     # cached at pending trust on the victim node.
     poison = isctest.query.tcp(
-        isctest.query.create(F004_VICTIM, "NSEC", cd=True), RESOLVER
+        isctest.query.create(F004_VICTIM, "NSEC", cd=True), ns2.ip
     )
     isctest.check.noerror(poison)
     isctest.check.noadflag(poison)
@@ -62,7 +60,7 @@ def test_pending_exact_nodata_nsec_cache_poisoning(f004_key_tags):

     # Query the victim's A record. The pending NSEC must not be used to
     # synthesize a NODATA; the resolver fetches and validates the real A.
-    response = isctest.query.tcp(isctest.query.create(F004_VICTIM, "A"), RESOLVER)
+    response = isctest.query.tcp(isctest.query.create(F004_VICTIM, "A"), ns2.ip)
     isctest.check.noerror(response)
     assert has_a(response, F004_VICTIM, F004_VICTIM_A), response.to_text()
     isctest.check.adflag(response)
diff --git a/bin/tests/system/nsec_synthesis/tests_nsec_pending_cd.py b/bin/tests/system/nsec_synthesis/tests_nsec_pending_cd.py
index b0533d1263..b7b44380d8 100644
--- a/bin/tests/system/nsec_synthesis/tests_nsec_pending_cd.py
+++ b/bin/tests/system/nsec_synthesis/tests_nsec_pending_cd.py
@@ -21,11 +21,9 @@ from nsec_synthesis.common import (
 )

 import isctest
-import isctest.template

 ATTACKER = f"attacker.{F004_ZONE}"
 POISON_NEXT = f"b.{F004_VICTIM}"
-RESOLVER = isctest.template.NS2.ip

 pytestmark = SIGNED_ZONE_MARKS

@@ -34,20 +32,18 @@ def bootstrap():
     return f004_bootstrap()


-def test_pending_trust_nsec_cd_cache_poisoning(f004_key_tags):
+def test_pending_trust_nsec_cd_cache_poisoning(ns2, ans1, f004_key_tags):
     """
     Reproducer for #5872:
     F-004 Cache Poisoning via Pending-Trust NSEC in Aggressive Cache
     """
     # Step 1: Prime SOA parent (and DNSKEY as subquery)
-    soa = isctest.query.tcp(isctest.query.create(F004_ZONE, "SOA"), RESOLVER)
+    soa = isctest.query.tcp(isctest.query.create(F004_ZONE, "SOA"), ns2.ip)
     isctest.check.noerror(soa)
     isctest.check.adflag(soa)

     # Step 2: Inject Forged NSEC via CD=1 Query
-    poison = isctest.query.tcp(
-        isctest.query.create(ATTACKER, "NSEC", cd=True), RESOLVER
-    )
+    poison = isctest.query.tcp(isctest.query.create(ATTACKER, "NSEC", cd=True), ns2.ip)
     isctest.check.noerror(poison)
     isctest.check.noadflag(poison)
     check_forged_nsec(
@@ -55,7 +51,7 @@ def test_pending_trust_nsec_cd_cache_poisoning(f004_key_tags):
     )

     # Step 3: Exploit Against Victim Domain
-    response = isctest.query.tcp(isctest.query.create(F004_VICTIM, "A"), RESOLVER)
+    response = isctest.query.tcp(isctest.query.create(F004_VICTIM, "A"), ns2.ip)
     isctest.check.noerror(response)
     assert has_a(response, F004_VICTIM, F004_VICTIM_A), response.to_text()
     isctest.check.adflag(response)
@@ -63,7 +59,7 @@ def test_pending_trust_nsec_cd_cache_poisoning(f004_key_tags):

     # Step 4: Exploit Against Stub Client
     response = isctest.query.tcp(
-        isctest.query.create(F004_VICTIM, "A", dnssec=False), RESOLVER
+        isctest.query.create(F004_VICTIM, "A", dnssec=False), ns2.ip
     )
     isctest.check.noerror(response)
     assert has_a(response, F004_VICTIM, F004_VICTIM_A), response.to_text()
@@ -71,5 +67,4 @@ def test_pending_trust_nsec_cd_cache_poisoning(f004_key_tags):
     assert not get_nsec(response, response.authority, ATTACKER)

     # Step 5: Verify Upstream Queries
-    with open("ans1/ans.run", "r", encoding="utf-8") as file:
-        assert f"Received {F004_VICTIM.rstrip('.')}/IN/A" in file.read()
+    assert f"Received {F004_VICTIM.rstrip('.')}/IN/A" in ans1.log
diff --git a/bin/tests/system/nsec_synthesis/tests_nsec_selfloop.py b/bin/tests/system/nsec_synthesis/tests_nsec_selfloop.py
index 957da73dd1..d9b55476fb 100644
--- a/bin/tests/system/nsec_synthesis/tests_nsec_selfloop.py
+++ b/bin/tests/system/nsec_synthesis/tests_nsec_selfloop.py
@@ -20,8 +20,6 @@ CHILD = "!.f007.test."
 PROBE = f"probe.{CHILD}"
 VICTIM = f"victim.{PARENT}"
 VICTIM_A = "203.0.113.7"
-AUTH = "10.53.0.3"
-RESOLVER = "10.53.0.2"

 pytestmark = ARTIFACTS

@@ -38,20 +36,20 @@ def bootstrap():
     }


-def test_direct_child_self_loop_nsec_fixture():
-    response = isctest.query.tcp(isctest.query.create(PROBE, "A"), AUTH)
+def test_direct_child_self_loop_nsec_fixture(ns3):
+    response = isctest.query.tcp(isctest.query.create(PROBE, "A"), ns3.ip)
     isctest.check.nxdomain(response)
     isctest.check.aaflag(response)
     check_nsec(response, response.authority, CHILD, CHILD, CHILD)


-def test_resolver_does_not_synth_parent_nxdomain_from_child_nsec():
-    poison = isctest.query.tcp(isctest.query.create(PROBE, "A"), RESOLVER)
+def test_resolver_does_not_synth_parent_nxdomain_from_child_nsec(ns2):
+    poison = isctest.query.tcp(isctest.query.create(PROBE, "A"), ns2.ip)
     isctest.check.nxdomain(poison)
     isctest.check.adflag(poison)
     check_nsec(poison, poison.authority, CHILD, CHILD, CHILD)

-    response = isctest.query.tcp(isctest.query.create(VICTIM, "A"), RESOLVER)
+    response = isctest.query.tcp(isctest.query.create(VICTIM, "A"), ns2.ip)
     isctest.check.noerror(response)
     assert has_a(response, VICTIM, VICTIM_A), response.to_text()
     isctest.check.adflag(response)