2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00
Commit Graph

43561 Commits

Author SHA1 Message Date
Petr Špaček
548632b18a Test proof of nonexistance of DS in insecure referrals
Currently this test is limited only to auth because currently BIND
resolver does not send DS proof of nonexistence for RD=0 queries.
2025-07-29 10:00:46 +02:00
Petr Špaček
73e4201331 Test dangling DNAME answers come with NXDOMAIN proofs
Simplistic test. Ignores the possibility of DNAME chain going through
multiple zones and/or wildcard expansions.
2025-07-29 10:00:46 +02:00
Petr Špaček
d0e413dd57 Test dangling CNAMEs come with NXDOMAIN proofs
Simplistic test. Ignores the possibility of CNAME chain going through
multiple zones and/or wildcard expansions.
2025-07-29 10:00:46 +02:00
Petr Špaček
cc6544b417 Move query outside of check_() functions
This allows better check() code reuse.
2025-07-29 10:00:46 +02:00
Petr Špaček
ac58b58002 Separate test into a new directory
The test actually needs just two servers - auth and resolver. The rest
was not needed and made test setup only slower and harder to debug.
2025-07-29 10:00:46 +02:00
Petr Špaček
a92391f60f Test simple NODATA answers with NSEC3 2025-07-29 10:00:46 +02:00
Petr Špaček
b854d5a3f5 Detect extraneous NSEC3 RRs in responses
We expect minimal possible answers which prove what they have to
according to DNSSEC protocol.
2025-07-29 10:00:46 +02:00
Petr Špaček
c45ad51860 Move proof checking into a NSEC3Checker class 2025-07-29 10:00:46 +02:00
Petr Špaček
cfaf5c997f Add consistency checks to responses with NSEC3
Basic sanity checks - limited to responses from a single zone:
- NSEC3 type cannot be present in type bitmap:
  By definition, the type bitmap describes state of the unhashed name
  but NSEC3 RR is present at a different owner name. RFC 7129 section 5
- NSEC3 owner names cannot be duplicated:
  Unless the response crosses zone boundary, parent zone has insecure
  delegation for child, but child is signed ... don't do that.
- All parameters are consistent across all RRs present in answer:
  RFC 5155 section 7.2, last paragraph - at least when we don't cross
  zone boundary.
2025-07-29 10:00:46 +02:00
Petr Špaček
9ca2077274 Split NXDOMAIN/NOERROR/NODATA test cases
Untangling individual cases allows for clearer documentation and makes
it easier to build similar but slightly different test cases.  Wildcard
NODATA answer was added.
2025-07-29 10:00:45 +02:00
Petr Špaček
f0592de608 Extract closest encloser and source of synthesis logic into ZoneAnalyzer
As a side-effect, we now have set of all existing names in a zone with a
test, too. These parts should be shared with new NSEC tests.
2025-07-29 10:00:45 +02:00
Petr Špaček
9cea2af25c Use isctest library to check hypothesis version
Side-effect of importing from isctest.hypothesis first is a version
check and clean Pytest skip if version is too old.
2025-07-29 10:00:45 +02:00
Petr Špaček
42b60a3819 Generate comprehensive tests for ZoneAnalyzer utility class
Test all combinations of wildcard, ENT, DNAME, NS, and ordinary
TXT records.

Test zone and expected outputs are generated by another script which
encodes node content into node name. This encoding removes 'node
content' level of indirection and thus enables simpler implementation of
same logic which needs to be in ZoneAnalyzer itself.

For humans the generated zone file also lists expected 'categories' a
name belongs to as dot-separated list on right hand side of a generated
RR.
2025-07-29 10:00:45 +02:00
Petr Špaček
cad48e56ab Test ZoneAnalyzer utility class
I've considered writing hypothesis test for this but I would have to
reimplement the same thing, which would probably have the same logic
bugs, so I will leave it as an exercise for someone else.
2025-07-29 10:00:37 +02:00
Petr Špaček
dbba59f48b Separate zone analyzer from NSEC3 test
Code to generate ENTs, detect wildcards, occlusion etc. is generic
enough to be in an utility module.
2025-07-29 10:00:37 +02:00
Petr Špaček
3fb6b990af 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.
2025-07-29 10:00:36 +02:00
Petr Špaček
bd8be10329 Move multi-subdomain name generator into shared utilities 2025-07-29 10:00:36 +02:00
Evan Hunt
e263df8848 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.
2025-07-29 10:00:36 +02:00
Petr Špaček
84ad35e7af Test also with subdomains of existing names
Composite strategy makes sure we always test with a subdomain of an
existing name.
2025-07-29 10:00:36 +02:00
Petr Špaček
f9e12a840d Dedup NSEC3 get_next_name function 2025-07-29 10:00:36 +02:00
Matthijs Mekking
955e3ccf3e 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.
2025-07-29 10:00:36 +02:00
Mark Andrews
132e68fddb Check that correct NSEC3 proofs are returned 2025-07-29 10:00:36 +02:00
Colin Vidal
13807cf853 chg: usr: plugin extension in plugin path is now optional
Plugin configuration no longer requires the library file extension, so it is now possible to invoke a plugin using the syntax `plugin query "library"` instead of `plugin query "libary.so"`.

Closes #5377

Merge branch '5377-implicit-plugin-ext' into 'main'

See merge request isc-projects/bind9!10753
2025-07-28 23:43:11 +02:00
Colin Vidal
284806029a update ARM plugin documentation
Update the ARM documentation of plugin usage as the extension in the
plugin library path is now optional.
2025-07-28 23:08:04 +02:00
Colin Vidal
b0061843b7 update test_hooks system tests
Add the case where the plugin name is provided without the extension in
the test_hooks system tests.
2025-07-28 23:08:04 +02:00
Colin Vidal
cdbaddb524 ns_plugin_expandpath() auto-extension unit-tests
Update existing ns_plugin_expandpath() unit test to cover the logic
appending the plugin extension if missing.

Because ns_plugin_expandpath() now relies on isc_file_exists() API, a
mocked version has been added in tests/ns/plugin_test.c and relies on the
linker --wrap mechanism.
2025-07-28 23:08:04 +02:00
Colin Vidal
7747ac8aed plugin expand path automatically adds extension
If a plugin is configured without the extension,
`ns_plugin_expandpath()` automatically take cares of appending the
suffix to the path. The way it works is by checking if a file exists at
the expanded path. If it doesn't, it assumes the plugin path (or name)
doesn't have the extension and append the extension (which is
platform-specific) to the actual path.
2025-07-28 23:08:04 +02:00
Colin Vidal
be03ed6520 Export plugin extension in config.h
Dynamically loadable libraries all use the `.so` extension on
BIND9-supported platforms, except for macOS. Export the dynamic library
extension of the current build platform in the generated `config.h`
file, in order to let the plugin code building plugin path based on a
simple plugin name. (which then would be platform-independent)
2025-07-28 23:08:04 +02:00
Michal Nowak
e6b4af9357 new: ci: Add AlmaLinux 10 FIPS
Merge branch 'mnowak/add-almalinux-10-fips' into 'main'

See merge request isc-projects/bind9!10722
2025-07-28 19:29:55 +02:00
Michal Nowak
1f45947088 Add AlmaLinux 10 FIPS 2025-07-28 18:55:34 +02:00
Michal Nowak
3b274e5993 Do not add AlmaLinux 8 FIPS unit and system test in MR pipelines 2025-07-28 18:55:15 +02:00
Ondřej Surý
b48040e788 fix: dev: Fix one-definition-rule violation in the loop unit test
Rename isc__loopmgr when including the loop.c into loop_test.c to prevent odr-violation over isc__loopmgr.

Merge branch 'ondrej/prevent-odr-violation-in-loop-unit-test' into 'main'

See merge request isc-projects/bind9!10772
2025-07-24 17:34:23 +02:00
Ondřej Surý
2092f8895f Fix one-definition-rule violation in the loop unit test
Locally, clang reported following odr-violation:

    =================================================================
    ==1132009==ERROR: AddressSanitizer: odr-violation (0x555555589280):
      [1] size=8 'isc__loopmgr' ../lib/isc/loop.c:52:16 in /home/ondrej/Projects/bind9/build/tests/isc/loop
      [2] size=8 'isc__loopmgr' ../lib/isc/loop.c:52:16 in /home/ondrej/Projects/bind9/build/tests/isc/../../libisc.so
    These globals were registered at these points:
      [1]:
	#0 0x7ffff785306f in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:350
	#1 0x55555556abce in _sub_I_00099_1 (/home/ondrej/Projects/bind9/build/tests/isc/loop+0x16bce) (BuildId: e7c586e966e6986532a3da40df41223ae16e55c9)
	#2 0x7ffff702a303 in call_init ../csu/libc-start.c:145
	#3 0x7ffff702a303 in __libc_start_main_impl ../csu/libc-start.c:347
	#4 0x5555555622e4 in _start (/home/ondrej/Projects/bind9/build/tests/isc/loop+0xe2e4) (BuildId: e7c586e966e6986532a3da40df41223ae16e55c9)

      [2]:
	#0 0x7ffff785306f in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:350
	#1 0x7ffff75335b9 in _sub_I_00099_1 (/home/ondrej/Projects/bind9/build/tests/isc/../../libisc.so+0x1335b9) (BuildId: 33ab72bc676e9ef9111b3db1fc4347595069cd29)
	#2 0x7ffff7fca71e in call_init elf/dl-init.c:74
	#3 0x7ffff7fca823 in call_init elf/dl-init.c:120
	#4 0x7ffff7fca823 in _dl_init elf/dl-init.c:121
	#5 0x7ffff7fe459f  (/lib64/ld-linux-x86-64.so.2+0x1f59f) (BuildId: 281ac1521b4102509b1c7ac7004db7c1efb81796)

    ==1132009==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
    SUMMARY: AddressSanitizer: odr-violation: global 'isc__loopmgr' at ../lib/isc/loop.c:52:16 in /home/ondrej/Projects/bind9/build/tests/isc/loop
    ==1132009==ABORTING
    Aborted (core dumped)

Rename isc__loopmgr when including the loop.c into loop_test.c to
prevent odr-violation over isc__loopmgr.
2025-07-24 17:34:11 +02:00
Štěpán Balážik
2a3e0ca81d 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.

Merge branch 'stepan/dispatch-asyncserver' into 'main'

See merge request isc-projects/bind9!10689
2025-07-24 13:15:44 +00:00
Michał Kępień
48e705d738 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.
2025-07-24 13:09:49 +02:00
Štěpán Balážik
316b7d5590 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.
2025-07-24 13:09:49 +02:00
Michał Kępień
e407888507 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.
2025-07-24 13:09:49 +02:00
Štěpán Balážik
b4d53e7287 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.
2025-07-24 13:09:49 +02:00
Michał Kępień
06b0800df8 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.
2025-07-24 13:09:49 +02:00
Ondřej Surý
30753f7723 fix: dev: Fix one-definition-rule violation in the tests/ns
Move the client_addrs and client_refs to libtest to prevent this.

Merge branch 'ondrej/fix-odr-violation' into 'main'

See merge request isc-projects/bind9!10771
2025-07-24 11:29:20 +02:00
Ondřej Surý
815c47f800 Fix one-definition-rule violation in the tests/ns
Locally, clang reported odr-violation:

    =================================================================
    ==588371==ERROR: AddressSanitizer: odr-violation (0x55555556a060):
      [1] size=256 'client_addrs' ../tests/ns/netmgr_wrap.c:36:18 in /home/ondrej/Projects/bind9/build/tests/ns/query
      [2] size=256 'client_addrs' ../tests/ns/netmgr_wrap.c:36:18 in /home/ondrej/Projects/bind9/build/tests/ns/../libbindtest.so
    These globals were registered at these points:
      [1]:
	#0 0x7ffff785306f in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:350
	#1 0x7ffff6a2a303 in call_init ../csu/libc-start.c:145
	#2 0x7ffff6a2a303 in __libc_start_main_impl ../csu/libc-start.c:347
	#3 0x55555555a084 in _start (/home/ondrej/Projects/bind9/build/tests/ns/query+0x6084) (BuildId: fbe4a3fcf1a249c7d7da69ee8b255a1dbb610c7a)

      [2]:
	#0 0x7ffff785306f in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:350
	#1 0x7ffff7fca71e in call_init elf/dl-init.c:74
	#2 0x7ffff7fca823 in call_init elf/dl-init.c:120
	#3 0x7ffff7fca823 in _dl_init elf/dl-init.c:121
	#4 0x7ffff7fe459f  (/lib64/ld-linux-x86-64.so.2+0x1f59f) (BuildId: 281ac1521b4102509b1c7ac7004db7c1efb81796)

    ==588371==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
    SUMMARY: AddressSanitizer: odr-violation: global 'client_addrs' at ../tests/ns/netmgr_wrap.c:36:18 in /home/ondrej/Projects/bind9/build/tests/ns/query
    ==588371==ABORTING

Move the client_addrs and client_refs to libtest to prevent this.
2025-07-24 08:46:11 +02:00
Ondřej Surý
bdf7a44442 chg: dev: Refactor the network manager to be a singleton
Refactor the network manager to be a single object which is not exposed to the caller.

Merge branch 'ondrej/refactor-isc_netmgr-to-be-singleton' into 'main'

See merge request isc-projects/bind9!10735
2025-07-23 22:45:59 +02:00
Ondřej Surý
f6aed602f0 Refactor the network manager to be a singleton
There is only a single network manager running on top of the loop
manager (except for tests).  Refactor the network manager to be a
singleton (a single instance) and change the unit tests, so that the
shorter read timeouts apply only to a specific handle, not the whole
extra 'connect_nm' network manager instance.
2025-07-23 22:45:38 +02:00
Ondřej Surý
a1b8fe45b0 chg: dev: Change the loopmgr to be singleton
All the applications built on top of the loop manager were required to
create a single instance of the loop manager.  Refactor the loop
manager not to expose this instance to the callers, and keep the loop
manager object internal to the `isc_loop` compilation unit.

This significantly simplifies a number of data structures and calls to
the `isc_loop` API.

Merge branch 'ondrej/refactor-isc_loopmgr-to-be-singleton' into 'main'

See merge request isc-projects/bind9!10733
2025-07-23 22:44:50 +02:00
Ondřej Surý
b8d00e2e18 Change the loopmgr to be singleton
All the applications built on top of the loop manager were required to
create just a single instance of the loop manager.  Refactor the loop
manager to not expose this instance to the callers and keep the loop
manager object internal to the isc_loop compilation unit.

This significantly simplifies a number of data structures and calls to
the isc_loop API.
2025-07-23 22:44:16 +02:00
Ondřej Surý
93431eb839 chg: usr: Reword the 'shut down hung fetch while resolving' message
The log message 'shut down hung fetch while resolving' may be confusing
because no detection of hung fetches actually takes place, but rather
the timer on the fetch context expires and the resolver gives up.

Change the log message to actually say that instead of the original
cryptic message about hung fetch.

Closes #3148

Merge branch '3148-rename-shut-down-hung-fetch' into 'main'

See merge request isc-projects/bind9!10759
2025-07-23 22:38:22 +02:00
Ondřej Surý
933dcc18ee Reword the 'shut down hung fetch while resolving' message
The log message 'shut down hung fetch while resolving' may be confusing
because no detection of hung fetches actually takes place, but rather
the timer on the fetch context expires and the resolver gives up.

Change the log message to actually say that instead of the original
cryptic message about hung fetch.
2025-07-23 22:37:56 +02:00
Štěpán Balážik
472459e171 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).

Merge branch 'stepan/zero-asyncserver' into 'main'

See merge request isc-projects/bind9!10597
2025-07-23 11:23:38 +00:00
Štěpán Balážik
ec5729bee3 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).
2025-07-23 09:45:50 +00:00
Matthijs Mekking
315e234f20 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

Merge branch '5243-stale-refresh-as-prefetch' into 'main'

See merge request isc-projects/bind9!10720
2025-07-23 07:19:20 +00:00