Commit graph

42940 commits

Author SHA1 Message Date
Petr Špaček
26bd3f2019 Separate zone analyzer from NSEC3 test
Code to generate ENTs, detect wildcards, occlusion etc. is generic
enough to be in an utility module.

(cherry picked from commit dbba59f48b)
2025-07-29 11:31:56 +02:00
Petr Špaček
b6b6b6f45b Shorten syntax to access Name object
dns.name all over the place does not make it easier to read the code at
all, and I'm going to add lot more code here.

(cherry picked from commit 3fb6b990af)
2025-07-29 11:31:56 +02:00
Petr Špaček
fa9ca7f3ee Move multi-subdomain name generator into shared utilities
(cherry picked from commit bd8be10329)
2025-07-29 11:31:56 +02:00
Evan Hunt
6931586fad Add property based test for nsec3hash utility
Check the correctness of NSEC3 hash generation by generating random
combinations of name, salt, and iterations and comparing the outputs
of the nsec3hash tool against the dnspython nsec3_hash function
for the same inputs.

(cherry picked from commit e263df8848)
2025-07-29 11:31:56 +02:00
Petr Špaček
0472b39835 Test also with subdomains of existing names
Composite strategy makes sure we always test with a subdomain of an
existing name.

(cherry picked from commit 84ad35e7af)
2025-07-29 11:31:56 +02:00
Petr Špaček
09856ee296 Dedup NSEC3 get_next_name function
(cherry picked from commit f9e12a840d)
2025-07-29 11:31:56 +02:00
Matthijs Mekking
0b9a129990 Add a property based test for NSEC3 proofs for non-existent QNAMEs
For any given NSEC3 signed zone, when doing queries for non-existent
names, the response must contain:
- NSEC3 RR that matches the closest encloser,
- NSEC3 RR that covers the next closer name,
- NSEC3 RR that covers the wildcard.

(cherry picked from commit 955e3ccf3e)
2025-07-29 11:31:56 +02:00
Mark Andrews
4b2eeca477 Check that correct NSEC3 proofs are returned
(cherry picked from commit 132e68fddb)
2025-07-29 11:31:52 +02:00
Michal Nowak
848262808e [9.20] new: ci: Add AlmaLinux 10 FIPS
Backport of MR !10722

Merge branch 'backport-mnowak/add-almalinux-10-fips-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10781
2025-07-28 20:55:16 +02:00
Michal Nowak
b0949d960b
Add AlmaLinux 10 FIPS
(cherry picked from commit 1f45947088)
2025-07-28 19:38:24 +02:00
Michal Nowak
b35b501f8d Do not add AlmaLinux 8 FIPS unit and system test in MR pipelines
(cherry picked from commit 3b274e5993)
2025-07-28 17:30:32 +00:00
Štěpán Balážik
3c80f205ae [9.20] chg: test: Use isctest.asyncserver in the "dispatch" test
Replace the custom DNS server used in the "dispatch" system test with
new code based on the isctest.asyncserver module.

Backport of MR !10689

Merge branch 'backport-stepan/dispatch-asyncserver-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10773
2025-07-24 13:52:19 +00:00
Michał Kępień
576e41a853 Account for idle timeouts in the "dispatch" test
When the tests-connreset.py module was initially implemented in commit
5c17919019, the dispatch code did not
properly apply the idle timeout to TCP connections.  This allowed the
check in that test module to reset the TCP connection after 5 seconds as
named did not attempt to tear the connection down earlier than that.
However, as the dispatch code was improved, the idle timeout started
being enforced for TCP dispatches; the exact value it is set to in the
current code depends on a given server's SRTT, but it defaults to about
1.2 seconds for responsive servers.  This means that the code paths
triggered by the "dispatch" system test are now different than the ones
it was originally supposed to trigger because it is now named itself
that shuts the TCP connection down cleanly before the ans3 server gets a
chance to reset it.

Account for the above by lowering the amount of time after which the
ans3 server in the "dispatch" system test resets TCP connections to just
1 second, so that the test actually does what its name implies.

(cherry picked from commit 48e705d738)
2025-07-24 13:17:07 +00:00
Štěpán Balážik
c6c149f0b6 Use isctest.asyncserver in the "dispatch" test
Replace the custom DNS server used in the "dispatch" system test with
new code based on the isctest.asyncserver module.

(cherry picked from commit 316b7d5590)
2025-07-24 13:17:07 +00:00
Michał Kępień
746fc9701c Enable resetting TCP connections
Add a TCP connection handler, ConnectionReset, which enables closing TCP
connections without emptying the client socket buffer, causing the
kernel to send an RST segment to the client.  This relies on a horrible
asyncio hack that can break at any point in the future due to abusing
implementation details in the Python Standard Library.  Despite the eye
bleeding this code may cause, the approach it takes was still deemed
preferable to implementing an asyncio transport from scratch just to
enable triggering connection resets.

(cherry picked from commit e407888507)
2025-07-24 13:17:07 +00:00
Štěpán Balážik
a7be55a3f0 Add support for TCP connection handlers
Add a new abstract class, ConnectionHandler, instances of which can be
installed on AsyncDnsServer to manipulate TCP connections upon
accepting.

(cherry picked from commit b4d53e7287)
2025-07-24 13:17:07 +00:00
Michał Kępień
74805453ee Enable requesting TCP connections to be closed
In response to client queries, AsyncDnsServer users can currently only
make the server either send a reply or silently ignore the query.  In
the case of TCP queries, neither of these actions causes the client's
connection to be closed - the onus of doing that is on the client.
However, in some cases the server may be required to close the
connection on its own, so AsyncDnsServer users need to have some way of
requesting such an action.

Add a new ResponseAction subclass, ResponseDropAndCloseConnection, which
enables AsyncDnsServer users to conveniently request TCP connections to
be closed.  Instead of returning the response to send,
ResponseDropAndCloseConnection raises a custom exception that
AsyncDnsServer._handle_tcp() handles accordingly.

(cherry picked from commit 06b0800df8)
2025-07-24 13:17:07 +00:00
Matthijs Mekking
ed37c7825e [9.20] fix: usr: Stale RRsets in a CNAME chain were not always refreshed
With serve-stale enabled, a CNAME chain that contains a stale RRset, the refresh query doesn't always properly refresh the stale RRsets. This has been fixed.

Closes #5243

Backport of MR !10720

Merge branch 'backport-5243-stale-refresh-as-prefetch-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10767
2025-07-23 12:46:58 +00:00
Matthijs Mekking
c8ed25560b Add reproducer as test case
The issue provided a reproducer that can be easily converted into a
test case.

(cherry picked from commit dc649735ad)
2025-07-23 12:12:51 +00:00
Matthijs Mekking
03eb9aabe1 Special case refresh stale ncache data
When refreshing stale ncache data, the qctx->rdataset is NULL and
requires special processing.

(cherry picked from commit 7774f16ed5)
2025-07-23 12:12:51 +00:00
Matthijs Mekking
667d81b52b Make serve-stale refresh behave as prefetch
A serve-stale refresh is similar to a prefetch, the only difference
is when it triggers. Where a prefetch is done when an RRset is about
to expire, a serve-stale refresh is done when the RRset is already
stale.

This means that the check for the stale-refresh window needs to
move into query_stale_refresh(). We need to clear the
DNS_DBFIND_STALEENABLED option at the same places as where we clear
DNS_DBFIND_STALETIMEOUT.

Now that serve-stale refresh acts the same as prefetch, there is no
worry that the same rdataset is added to the message twice. This makes
some code obsolete, specifically where we need to clear rdatasets from
the message.

(cherry picked from commit a66b04c8d4)
2025-07-23 12:12:51 +00:00
Michał Kępień
9e57035eda [9.20] chg: test: Use isctest.asyncserver in the "zero" test
The original `ans.pl` server was a copy of the one in `fetchlimit`, so
there are some changes:

- The server now only responds with A replies (which is the only thing
  needed).
- The incrementing of the IP address goes beyond the least significant
  octet (so, after 192.0.2.255 it will yield 192.0.3.0).

Backport of MR !10597

Merge branch 'backport-stepan/zero-asyncserver-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10768
2025-07-23 14:06:42 +02:00
Štěpán Balážik
a208e17a8d Use isctest.asyncserver in the "zero" test
The original `ans.pl` server was based on a copy of the one in
`fetchlimit`, so there are some changes:

- The server now only responds with A replies (which is the only thing
  needed).
- The incrementing of the IP address goes beyond the least significant
  octet (so, after 192.0.2.255 it will yield 192.0.3.0).

(cherry picked from commit ec5729bee3)
2025-07-23 11:24:00 +00:00
Ondřej Surý
e016242c24 [9.20] fix: nil: Disable clang-format for Local IPv6 Unicast Addresses strings
The LSP server (using clangd) was always complaining about:

    Suspicious string literal, probably missing a comma

for the two Local IPv6 Unicast Addresses strings that spanned
across multiple lines.  Disable clang-format for these two lines.

Backport of MR !10764

Merge branch 'backport-ondrej/fix-suspicious-string-literal-probably-missing-comma-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10765
2025-07-23 09:09:29 +02:00
Ondřej Surý
63c5083039 Disable clang-format for Local IPv6 Unicast Addresses strings
The LSP server (using clangd) was always complaining about:

    Suspicious string literal, probably missing a comma

for the two Local IPv6 Unicast Addresses strings that spanned
across multiple lines.  Disable clang-format for these two lines.

(cherry picked from commit 6b7c99027d)
2025-07-23 09:09:18 +02:00
Ondřej Surý
7f25d92c5d [9.20] fix: dev: Rename variable called 'free' to prevent the clash with free()
Backport of MR !10756

Merge branch 'backport-ondrej/rename-variable-called-free-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10757
2025-07-23 07:48:08 +02:00
Ondřej Surý
485aac9213
Rename 'free' variable to 'nfree' to not clash with free()
The beauty and horrors of the C - the compiler properly detects variable
shadowing, but you can freely shadow a standard function 'free()' with
variable called 'free'.  And if you reference 'free()' just as 'free'
you get the function pointer which means you can do also pointer
arithmetics, so 'free > 0' is always valid even when you delete the
local variable.

Replace the local variables 'free' with a name that doesn't shadow the
'free()' function to prevent future hard to detect bugs.

(cherry picked from commit 855960ce46)
2025-07-22 14:28:15 +02:00
Štěpán Balážik
920874ea58 [9.20] chg: test: Use isctest.asyncserver in the "fetchlimit" test
Replace the custom DNS server used in the "fetchlimit" system test
with new code based on the isctest.asyncserver module.

Backport of MR !10614

Merge branch 'backport-stepan/fetchlimit-asyncserver-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10755
2025-07-22 10:16:17 +00:00
Štěpán Balážik
87a0dfde67 Use isctest.asyncserver in the "fetchlimit" test
Replace the custom DNS server used in the "fetchlimit" system test
with new code based on the isctest.asyncserver module.

(cherry picked from commit 9ffc833919)
2025-07-22 07:09:52 +00:00
Mark Andrews
bc54f059e0 [9.20] fix: usr: synth-from-dnssec was not working in some scenarios
Aggressive use of DNSSEC-Validated cache with NSEC was not working in scenarios when no parent NSEC was not in cache.  This has been fixed.

Closes #5422

Backport of MR !10736

Merge branch 'backport-5422-aggressive-nsec-not-working-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10754
2025-07-22 02:22:07 +10:00
Mark Andrews
15031f32e6 test synth-from-dnssec with no cached parent NSECs
Add \007.no-apex-covering as an owner name so that the cache does
not get primed with a parent NSEC RRset to test the case where
dns_qp_lookup returns ISC_R_NOTFOUND.

(cherry picked from commit df04924209)
2025-07-21 17:46:02 +02:00
Mark Andrews
e4d64a0c33 Fix find_coveringnsec in qpcache.c
dns_qp_lookup was returning ISC_R_NOTFOUND rather than DNS_R_PARTIALMATCH
when there wasn't a parent with a NSEC record in the cache.  This was
causing find_coveringnsec to fail rather than returing the covering NSEC.

(cherry picked from commit 7de4207cb6)
2025-07-21 17:46:00 +02:00
Nicki Křížek
d4fb3a060b [9.20] fix: test: Add wait_for_keymgr_done() util function to tests
The kasp test cases assume that keymgr operations on the zone under test
have been completed before the test is executed. These are typically
quite fast, but the logs need to be explicitly checked for the messages,
otherwise there's a possibility of race conditions causing the
kasp/rollover tests to become unstable.
    
Call the wait function in all the kasp/rollover tests where it is
expected (which is generally in each test, unless we're dealing with
unsigned zones).

Closes #5371

Backport of MR !10717

Merge branch 'backport-5371-wait-keymgr-done-rollover-kasp-tests-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10752
2025-07-18 16:54:58 +02:00
Nicki Křížek
3446e70b6a Add wait_for_keymgr_done() util function to tests
The kasp test cases assume that keymgr operations on the zone under test
have been completed before the test is executed. These are typically
quite fast, but the logs need to be explicitly checked for the messages,
otherwise there's a possibility of race conditions causing the
kasp/rollover tests to become unstable.

Call the wait function in all the kasp/rollover tests where it is
expected (which is generally in each test, unless we're dealing with
unsigned zones).

(cherry picked from commit 467b826162)
2025-07-18 16:20:06 +02:00
Nicki Křížek
7718baa363 Add nsX fixtures to system tests
Many of our test cases only use a single NamedInstance from the
`servers` fixture. Introduce `nsX` helper fixtures to simplify these
tests and reduce boilterplate code further.

Specifically, the test no longer has to either define its own variable
to extract a single server from the list, or use the longer
servers["nsX"] syntax. While this may seem minor, the amount of times it
is repeated across the tests justifies the change. It also promotes
using more explicit server identification, i.e. `nsX`, rather than
generic `server`. This also improves the clarity of the tests and may be
helpful in traceback during debugging as well.

(cherry picked from commit fe55342916)
2025-07-18 16:20:06 +02:00
Nicki Křížek
0e1a793416 [9.20] chg: test: Split up rollover test cases
Prior to this change, there was a single `rollover` test directory, containing 8 tests. These contained even more test scenarios, that were mostly unrelated to each other. This made debugging or even comprehending the tests difficult, as you'd often have to grasp the importance (or rather lack of it) of thousands of lines of setup, configuration and test code, and debug logs.

Now the tests were split up into 14 different test directories, containing 67 tests in total. This makes it much more comprehensible to understand what's going on in any single of these test cases, as there is no unrelated code. It also allows better parallelization and debugging of individual test cases, because of the improved granularity.

Backport of MR !10581

Merge branch 'backport-nicki/split-rollover-test-cases-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10751
2025-07-18 15:28:07 +02:00
Nicki Křížek
0b1aa69fb7 Clean up rollover test case
(cherry picked from commit 42b034460f)
2025-07-18 14:50:39 +02:00
Nicki Křížek
d898162d4a Isolate rollover-multisigner test case
(cherry picked from commit 86c3c1da77)
2025-07-18 14:50:39 +02:00
Nicki Křížek
7f6789e300 Isolate rollover-enable-dnssec test case
(cherry picked from commit e294177312)
2025-07-18 14:50:39 +02:00
Nicki Křížek
e90f93fc68 Isolate rollover-zsk-prepub test case
(cherry picked from commit 64199e062d)
2025-07-18 14:48:35 +02:00
Nicki Křížek
4cb75dead9 Isolate rollover-ksk-3crowd test case
(cherry picked from commit bc7be041e1)
2025-07-18 14:48:16 +02:00
Nicki Křížek
3d5c90aa44 Use common test functions for three-is-a-crowd test
Previously, a lot of the checking was re-implemented and duplicated from
check_rollover_step(). Use that function where possible and only
override the needed checks.

(cherry picked from commit d6dffe6603)
2025-07-18 14:48:00 +02:00
Nicki Křížek
ead775e2a9 Isolate rollover-ksk-doubleksk test case
(cherry picked from commit bd5a55c5b7)
2025-07-18 14:47:58 +02:00
Nicki Křížek
89c2afda43 Isolate rollover-csk-roll1 test case
(cherry picked from commit 296cfc8363)
2025-07-18 14:47:38 +02:00
Nicki Křížek
05d143e5f0 Isolate rollover-csk-roll2 test case
(cherry picked from commit 9d2bd1b646)
2025-07-18 14:47:22 +02:00
Nicki Křížek
a0afdbd668 Isolate rollover-algo-csk test
(cherry picked from commit fdecef5378)
2025-07-18 14:47:04 +02:00
Nicki Křížek
6dc96a18b8 Isolate rollover-algo-ksk-zsk test
(cherry picked from commit 8be9a8b52a)
2025-07-18 14:46:46 +02:00
Nicki Křížek
0e75a38201 Isolate rollover-straight2none test
(cherry picked from commit 519f9082df)
2025-07-18 14:46:27 +02:00
Nicki Křížek
a225f35b95 Isolate rollover-lifetime test
(cherry picked from commit a9c70c3e26)
2025-07-18 14:46:07 +02:00
Nicki Křížek
cd78c5ed51 Isolate rollover-going-insecure test case
(cherry picked from commit 7001056eab)
2025-07-18 14:45:45 +02:00