Commit graph

6898 commits

Author SHA1 Message Date
Michal Nowak
005aa31fd8 Bump xfer timeout to 30 seconds
Enabling ans6 responses and xfr-and-reconfig zone reload sometimes takes
more time on FreeBSD than the default timeout allows; bump it to 30
seconds.

(cherry picked from commit 77a7430a5f)
2026-03-10 13:25:05 +00:00
Nicki Křížek
1f6b58fa60 Log dnspython queries after .to_wire() is called
Some dns message modifications like TSIG happen only after .to_wire() is
called on the message. To ensure there isn't a discrepancy between what
has been logged and what has been sent, log the query after
dns.query.udp() is executed (which calls .to_wire() on the message).

Co-Authored-By: Štěpán Balážik <stepan@isc.org>
(cherry picked from commit a22e03f71b)
2026-03-09 12:12:41 +00:00
Colin Vidal
6d75e03971 add checkconf test with key defined inside a view
A configuration where a key was defined inside a view, then used in a
`primary` statement wasn't covered. This is now fixed.

(cherry picked from commit d8f46b09a7)
2026-03-01 13:41:53 +01:00
Colin Vidal
d85889710b
Add test coverage for nameserver processing limits
Introduce a new system test (nsprocessinglimit) to verify that the
resolver strictly respects outgoing network fetch quotas when presented
with heavily delegated, unresponsive zones.

This test acts as a regression check for the recent Fisher-Yates nameserver
selection refactor.  It sets up an authoritative server delegating a zone
to 23 distinct nameservers (all pointing to unresponsive loopback IPs).

Using dnstap, the test forces a resolution failure and verifies that:
1. The resolver successfully traverses the zone delegation path.
2. The resolver caps the outgoing network queries to the delegated
   nameservers exactly at the processing limit (20 fetches), ensuring
   array boundaries and dynamic fetch quotas are strictly enforced without
   crashing or hanging.

(cherry picked from commit 5274e764c4)
2026-02-26 08:17:23 +01:00
Štěpán Balážik
6e91738efe Replace deprecated typing imports
More specific modules (like collections.abc) can now be used.

Generated with: ruff check --extend-select UP035 --fix

(cherry picked from commit ced002c4ab)
2026-02-25 13:33:46 +01:00
Štěpán Balážik
c04b9251aa 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.

(cherry picked from commit d3186c7038)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
963ef9cb8e 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)

(cherry picked from commit 1d5924c82f)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
17cf986396 Replace Optional[T] with T | None
Generated with: ruff check --extend-select UP045 --fix && black .

(cherry picked from commit fe38515ad0)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
89ce3b5e74 Remove the rest of Union usages by hand
These require some manual changes.

(cherry picked from commit cdb7428431)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
95f49d58b9 Replace Union[S, T] with S | T
Generated with: ruff check --extend-select UP007 --fix && black .

(cherry picked from commit ce9c9a1a9c)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
a7ef013f6d Built-in types are now subscriptable
Generated with: ruff check --extend-select UP006 --fix

(cherry picked from commit 790745da18)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
5fc2b9b2f3 Remove superfluous 'pylint: disable' directives
Some of these have been fixed already, fix the rest.

(cherry picked from commit 08f5e5ebd1)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
e5d5a6433c Remove unused imports
Generated with: ruff check --extend-select F401 --fix

(cherry picked from commit b00f16f026)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
af85bc2592 Set pytestmark explicitly in rollover* and nsec3* tests
Importing pytestmark confuses static analysis tools as they flag it as
unused.

(cherry picked from commit 7178c97e5c)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
99658ad4a1 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().

(cherry picked from commit ef21b77912)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
6e9e3b7208 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.

(cherry picked from commit 2b9c5ccd77)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
746ca1d481 Automatically sort imports in Python code
Generated with: ruff check --extend-select I --fix (with the changes to
pyproject.toml applied).

(cherry picked from commit ffd5b6ac26)
2026-02-25 13:33:20 +01:00
Štěpán Balážik
d079305ba3 Remove unneeded pylint: disable=import-error
Paths are now correctly set up for pylint.
2026-02-25 13:15:05 +01:00
Štěpán Balážik
68b9928f0f Fix vulture warnings and tweak ignore lists
Run vulture on the whole repository, fix most errors in previously
unchecked code, adjust ignore lists.

(cherry picked from commit 57ecaee95d)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
5e6399411a Fix 'Too many return statements' pylint error
Refactor `Key.match_properties` into multiple functions.

(cherry picked from commit 19076c0d4d)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
50f6dcdc75 Fix pylint's 'invalid-name' errors
Where possible comply with the naming rules. Add exceptions for the
function names used in KASP tests.

(cherry picked from commit 50ed74197c)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
4f8d253d7a Set dist=loadscope for pytest in pytest.ini
Previously there was some handling of old pytest-xdist versions which is
no longer needed.

(cherry picked from commit c47b076494)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
a8911683d7 Fix the rest of 'Formatting a regular string which could be an f-string'
Some fixes have to be done manually.

(cherry picked from commit a384283497)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
eb9a93ebd5 Fix some 'Formatting a regular string which could be an f-string' errors
Generated with:
ruff check --select UP031,UP032 --fix --unsafe-fixes && black .

(cherry picked from commit df0be6b4bd)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
d6247cad75 Fix 'Using deprecated class FileType of module argparse'
In preparation for running pylint on more Python code.
2026-02-25 13:15:05 +01:00
Štěpán Balážik
7dd6b4dc5b Fix 'Import should be placed at the top of the module'
In preparation for running pylint on more Python code.

(cherry picked from commit 4253d7298c)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
cffa775a90 Fix 'Using open without explicitly specifying an encoding'
In preparation for running pylint on more code.

(cherry picked from commit 38a47d9f7c)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
bfc561f224 Use relative imports and __init__.py in the statschannel test
This is in preparation for automatic import sorting.

(cherry picked from commit d0079b5722)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
814aeda71f Issue errors on re.compile only when isctest is imported
This is in preparation of running pylint on more parts of the codebase.

(cherry picked from commit 4684c9c091)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
d7f6f258f7 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.

(cherry picked from commit 407df9599c)
2026-02-25 13:15:05 +01:00
Matthijs Mekking
c3b320f12a 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).

(cherry picked from commit c32de7df95)
2026-02-25 11:30:34 +01:00
Colin Vidal
f64828981d system test covering NS randomization
Add randomizens system test which ensures that NS are randomly selected.
The test relies of the fact that `getaddresses_allowed()` logic won't
allow to query more than 3 NS at the top-level. The `example.` zone has
4 NS and the 3 formers are lame. As a result, if the resolved doesn't
randomize the NS selection, it will only quiery the 3 formers, which
won't give an answer, and fails. With randomization enabled, there is a
chance that the resolver queries the fourth NS, and gets the result.

(cherry picked from commit c67b52684f)
2026-02-25 10:18:47 +01:00
Ondřej Surý
50c39b6766 Add system tests that imports invalid SKR file
Try to import invalid SKR file and observe whether the named is still
alive.  This test only triggers under ASAN.

(cherry picked from commit a82773ea89)
2026-02-24 18:45:41 +00:00
Ondřej Surý
6fb01d751d Add tests for NSEC3 invalid length
Adds a static system test that fails to load an NSEC3 record with an
invalid next part length.  Additionally, introduces a dynamic test using
a crafted authoritative DNS proxy to inject invalid NSEC3 records on the
fly to test runtime behavior.

(cherry picked from commit 7b737bc1c4)
2026-02-24 17:10:52 +01:00
Mark Andrews
c88aa8a380 Enforce NSEC3 record consistency
NSEC3 hashes are required to fit within a single DNS label.  Since there
are 5 bits per label byte without pad characters, the maximum hash size
is floor(63*5/8) (39 bytes).

This patch enforces this maximum length for unknown algorithms, while
strictly enforcing the exact expected digest length for known algorithms
like SHA-1.

(cherry picked from commit 3801d0ebbf)
2026-02-24 17:10:52 +01:00
Alessio Podda
0041c5756e Add reproducer for #5759
Adds a test case that runs IXFR while leaving an rdataset unchanged.
2026-02-24 13:04:19 +01:00
Ondřej Surý
b23d8b48ee
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.

(cherry picked from commit 46f15f4f9d)
2026-02-24 11:56:45 +01:00
Colin Vidal
7d69ceb9e3 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".

(cherry picked from commit 4f8788310b)
2026-02-20 18:11:29 +01:00
Mark Andrews
a6ca8407ee
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.

(cherry picked from commit f99d7f4217)
2026-02-20 10:50:19 +01:00
Mark Andrews
32f802f4ed 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.

(cherry picked from commit 757e503536)
2026-02-19 22:42:26 +11:00
Mark Andrews
38ca02c7a0 Use shell function 'check_count' to check counts
(cherry picked from commit ea32141e48)
2026-02-17 03:32:47 +00:00
Mark Andrews
b9ba70f9c1 Test forward query/response counts
(cherry picked from commit 591096f131)
2026-02-17 03:32:47 +00:00
Mark Andrews
e8828fb2b1 Add missed ret!=0 checks
(cherry picked from commit 77278beaf3)
2026-02-17 03:32:47 +00:00
Michał Kępień
43eec494dd 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.

(cherry picked from commit 3954025218)
2026-02-13 14:03:58 +00:00
Michał Kępień
5a0e1de2e5 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.

(cherry picked from commit 10a2fc7f1f)
2026-02-13 14:03:58 +00:00
Michał Kępień
f773a18f40 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.

(cherry picked from commit d3d9d166ed)
2026-02-13 14:03:58 +00:00
Michał Kępień
442285dce3 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.

(cherry picked from commit 94a4793596)
2026-02-13 14:03:58 +00:00
Michal Nowak
94a3861776 Rewrite xfer system test to pytest
(cherry picked from commit bf0df8b7f4)
2026-02-06 21:03:52 +01:00
Nicki Křížek
aeb0518239 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.

(cherry picked from commit e4abb5bd07)
2026-02-06 13:20:03 +00:00
Nicki Křížek
f76fa8ad35 Improve logging for isctest.run.retry_with_timeout
Add more debug messages around the retry function to facilitate
debugging in case of issues.

(cherry picked from commit d237048de2)
2026-02-06 13:20:03 +00:00