Commit graph

7074 commits

Author SHA1 Message Date
Ondřej Surý
46f15f4f9d
Add test for mixed unsupported DS records
Add a system test that has one invalid DS record with supported
algorithm and one unsupported DS record.  Both DNSKEY and A queries must
fail with SERVFAIL.
2026-02-23 19:53:48 +01:00
Ondřej Surý
f983a64152
Fail DNSKEY validation when supported but invalid DS is found
A regression was introduced when adding the EDE code for unsupported
DNSKEY and DS algorithms.  When the parent has both supported and
unsupported algorithm in the DS record, the validator would treat the
supported DS algorithm as insecure when validating DNSKEY records
instead of BOGUS.  This has not security impact as the rest of the child
zone correctly ends with BOGUS status, but it is incorrect and thus the
regression has been fixed.
2026-02-23 11:34:43 +01:00
Matthijs Mekking
c32de7df95 Test serve-stale with upstream zones and CNAMEs
Three variants of YWH-PGM40640-56: Stale/Wrong DNS Data Served via
CNAME Flag Leak (DNS_DBFIND_STALEOK persistence) are presented in
GitLab issue #5751. All these variants have been converted to system
tests.

Variant 1 forwards source.stale to another server, that provides a
CNAME record, while the resolver is authoritative for target.stale.
The CNAME points to a non-existing name. A stale CNAME record should
result in a stale NXDOMAIN (instead of SERVFAIL).

Variant 2 forwards both source.stale and target.stale to other servers.
This time the CNAME points to an A RRset. If the source.stale server
is not available (and stale-answer-client-timeout is off), the cached
CNAME should be followed and pick up the fresh RRset (instead of the
stale A RRset).

Variant 3 is similar to variant 2, but this time the CNAME points to
a non-existing name again. After flushing the target, BIND should
return a stale NXDOMAIN (instead of SERVFAIL).
2026-02-23 08:07:12 +01:00
Štěpán Balážik
ced002c4ab Replace deprecated typing imports
More specific modules (like collections.abc) can now be used.

Generated with: ruff check --extend-select UP035 --fix
2026-02-20 15:17:32 +01:00
Štěpán Balážik
d3186c7038 Clean up imports of dnspython modules
Add a pylint plugin that enforces:
  - There is no bare `import dns` statement.
  - All `dns.<module>` used are explicitly imported.
  - There are no unused `dns.<module>` imports.

Fix all the imports to conform with this check.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
1d5924c82f Replace Optional["T"] with "T | None"
In Python 3.10 strings don't support the | operator, so ruff doesn't
attempt to fix these. Quote the entire type specification to avoid the
typing.Optional import.

Alternatives I considered:
- leaving it as is (only use of Optional in the code base)
- using `from future import __annotations__` (replacing one import with
  another one)
2026-02-20 15:17:32 +01:00
Štěpán Balážik
fe38515ad0 Replace Optional[T] with T | None
Generated with: ruff check --extend-select UP045 --fix && black .
2026-02-20 15:17:32 +01:00
Štěpán Balážik
cdb7428431 Remove the rest of Union usages by hand
These require some manual changes.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
ce9c9a1a9c Replace Union[S, T] with S | T
Generated with: ruff check --extend-select UP007 --fix && black .
2026-02-20 15:17:32 +01:00
Štěpán Balážik
790745da18 Built-in types are now subscriptable
Generated with: ruff check --extend-select UP006 --fix
2026-02-20 15:17:32 +01:00
Štěpán Balážik
08f5e5ebd1 Remove superfluous 'pylint: disable' directives
Some of these have been fixed already, fix the rest.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
b00f16f026 Remove unused imports
Generated with: ruff check --extend-select F401 --fix
2026-02-20 15:17:32 +01:00
Štěpán Balážik
7178c97e5c Set pytestmark explicitly in rollover* and nsec3* tests
Importing pytestmark confuses static analysis tools as they flag it as
unused.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
ef21b77912 Make default_algorithm accessible through a fixture and method
Importing pytest fixture trips up static analysis tools, so move
default_algorithm to conftest.py and use it instead of os.environ
accesses in various system tests.

For use outside test function, use Algorithm.default().
2026-02-20 15:17:32 +01:00
Štěpán Balážik
2b9c5ccd77 Define __all__ in __init__.py files
Fix ruff's F401 unused-import errors in these files.

Also sort them with: ruff check --extend-select RUF022 --fix.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
ffd5b6ac26 Automatically sort imports in Python code
Generated with: ruff check --extend-select I --fix (with the changes to
pyproject.toml applied).
2026-02-20 15:17:32 +01:00
Štěpán Balážik
57ecaee95d Fix vulture warnings and tweak ignore lists
Run vulture on the whole repository, fix most errors in previously
unchecked code, adjust ignore lists.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
19076c0d4d Fix 'Too many return statements' pylint error
Refactor `Key.match_properties` into multiple functions.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
50ed74197c Fix pylint's 'invalid-name' errors
Where possible comply with the naming rules. Add exceptions for the
function names used in KASP tests.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
c47b076494 Set dist=loadscope for pytest in pytest.ini
Previously there was some handling of old pytest-xdist versions which is
no longer needed.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
a384283497 Fix the rest of 'Formatting a regular string which could be an f-string'
Some fixes have to be done manually.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
df0be6b4bd Fix some 'Formatting a regular string which could be an f-string' errors
Generated with:
ruff check --select UP031,UP032 --fix --unsafe-fixes && black .
2026-02-20 15:17:31 +01:00
Štěpán Balážik
4253d7298c Fix 'Import should be placed at the top of the module'
In preparation for running pylint on more Python code.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
38a47d9f7c Fix 'Using open without explicitly specifying an encoding'
In preparation for running pylint on more code.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
d0079b5722 Use relative imports and __init__.py in the statschannel test
This is in preparation for automatic import sorting.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
4684c9c091 Issue errors on re.compile only when isctest is imported
This is in preparation of running pylint on more parts of the codebase.
2026-02-20 15:17:31 +01:00
Štěpán Balážik
407df9599c Run custom servers as Python modules
Use `python -m` for running the custom servers.

This allows the use of relative imports in the server modules and in
turn linting the modules.
2026-02-20 15:17:31 +01:00
Mark Andrews
f99d7f4217
Check notify with bad notify source address and tsig
named was asserting when the notify source address was not available
and TSIG was being used.  Check this scenario by adding a nameserver
to the zone which is configured to uses a non-existent source address
and a blackholed destination address and a TSIG using a server clause
for that destination address.
2026-02-19 13:44:33 +01:00
Mark Andrews
757e503536 Return FORMERR for ECS family 0
RFC 7871 only defines family 1 (IPv4) and 2 (IPv6). Additionally
it requires FORMERR to be returned for all unknown families.
2026-02-19 13:17:19 +11:00
Mark Andrews
ea32141e48 Use shell function 'check_count' to check counts 2026-02-17 13:17:43 +11:00
Mark Andrews
591096f131 Test forward query/response counts 2026-02-17 13:17:43 +11:00
Mark Andrews
77278beaf3 Add missed ret!=0 checks 2026-02-17 13:17:38 +11:00
Michał Kępień
3954025218
Use isctest.asyncserver in the "pipelined" test
Replace the custom DNS server used in the "pipelined" system test with
new code based on the isctest.asyncserver module.
2026-02-13 14:27:10 +01:00
Michał Kępień
10a2fc7f1f
Implement a response handler that forwards queries
Add a new response handler, ForwarderHandler, which enables forwarding
all queries to another DNS server.  To simplify implementation, always
forward queries to the target server via UDP, even if they are
originally received using a different transport protocol.
2026-02-13 14:27:10 +01:00
Michał Kępień
d3d9d166ed
Log the server socket receiving each query
Extend AsyncDnsServer._log_query() and AsyncDnsServer._log_response() so
that they also log the <address, port> tuple for the socket on which a
given query was received on.  Minimize the signatures of those methods
by taking advantage of all the information contained in the QueryContext
instances passed to them.
2026-02-13 14:27:10 +01:00
Michał Kępień
94a4793596
Store server socket information in QueryContext
Extend the QueryContext class with a field holding the <address, port>
tuple for the socket on which a given query was received.  This will
enable query handlers to act upon that information in arbitrary ways.
2026-02-13 14:27:10 +01:00
Colin Vidal
4f8788310b system test for the ADB fetch loop detection
Add a system test which implement the scenario described in the previous
commit "relaxes fetch loop detection".
2026-02-11 14:33:22 +01:00
Matthijs Mekking
a5f934b7a1 Minor logging improvements for key lifetime 2026-02-06 15:06:47 +00:00
Michal Nowak
bf0df8b7f4
Rewrite xfer system test to pytest 2026-02-06 14:34:53 +01:00
Nicki Křížek
e4abb5bd07 Allow re-run of kasp test case on all FreeBSDs
Previously, the issue when the kasp.test_kasp_case[secondary.kasp] fails
due to a timeout has been only ocassionally observed on FreeBSD 13
in our CI. It seems to have come back on FreeBSD 15.
2026-02-06 13:22:11 +01:00
Nicki Křížek
d237048de2 Improve logging for isctest.run.retry_with_timeout
Add more debug messages around the retry function to facilitate
debugging in case of issues.
2026-02-06 13:22:11 +01:00
Mark Andrews
8f413fd589 Fix timing in tests_nsec3_change.py
The zone file is updated too soon causing the reload to fail.
Add a 1 second sleep to ensure the modification time has changed.
2026-02-06 09:39:15 +11:00
Matthijs Mekking
ce1d68cbc5
Add a regression test for the BRID/HHIT crash
Add two short records to example.com.db that cause assertion failures
when converted to wire form.

The checks added to tests.sh are technically not required: the relevant
assertion failures are already hit when the zone is transferred out of
ns1.

Update the relevant unit tests with 1-byte records.

Co-authored-by: Mark Andrews <marka@isc.org>
2026-02-05 18:21:52 +01:00
Ondřej Surý
0bebf8ee9d
Enable minimal ANY answers by default
ANY queries are widely abused by attackers doing reflection attacks as
they return the largest answers.  Enable minimal ANY answers by default
to reduce the attack surface of the DNS servers.
2026-01-28 15:38:18 +01:00
Aram Sargsyan
d81a2457d6 Add a new check in the RPZ system test
Check that reloading a response policy zone which has an '$INCLUDE'
directive defined is working as expected.
2026-01-27 11:31:15 +00:00
Nicki Křížek
b1e3469059 Resolve the system_test_dir in pytest
If the system_test_dir contains a symlink, then it might cause issues
further down when using relative_to(), unless it is resolved first. This
has been observed on FreeBSD13 in CI where /home is a symlink to
/usr/home.
2026-01-27 11:05:18 +01:00
Nicki Křížek
6eb2088320 Fix a race condition in dnssec test
When dumpdb command is executed, it might take a while until the file is
written. Rather than checking the file once, use the WatchLog mechanism
to allow the desired line to appear before a timeout happens.

This affected test_validation_recovery and test_cache tests which have
been intermittently failing on EL8 in our CI.
2026-01-26 10:45:34 +01:00
Štěpán Balážik
c336c1feab Fix bugs in 'resolver/ans2' and 'resolver/ans3'
There were multiple typos and omissions regarding query minimization.
2026-01-24 13:04:09 +01:00
Štěpán Balážik
cef851740b Reimplement 'resolver/ans10' server using AsyncDnsServer
Ensure packet-for-packet compatibility with the old server.
2026-01-24 13:04:09 +01:00
Štěpán Balážik
8f2526a27d Reimplement 'resolver/ans8' server using AsyncDnsServer
Ensure packet-for-packet compatibility with the old server.
2026-01-24 13:04:09 +01:00