Skip to content

Commit

Permalink
UPD: remove dnspython-1 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
monoidic committed May 16, 2023
1 parent 49e232e commit a0d3c14
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CHANGELOG
------------------

### Core
- `intelmq.lib.utils`:
- `resolve_dns`: Deprecate dnspython versions pre-2.0.0 and disable search domains (PR#2352)
- Fixed not resetting destination path statistics in the stats cache after restarting bot (Fixes [#2331](https://github.com/certtools/intelmq/issues/2331))
- Force flushing statistics if bot will sleep longer than flushing delay (Fixes [#2336](https://github.com/certtools/intelmq/issues/2336))

Expand All @@ -30,6 +32,9 @@ CHANGELOG
#### Experts
- `intelmq.bots.experts.sieve`:
- Allow empty lists in sieve rule files (PR#2341 by Mikk Margus Möll).
- `intelmq.bots.experts.cymru_whois`:
- Ignore AS names with unexpected unicode characters (PR#2352, fixes #2132)
- Avoid extraneous search domain-based queries on NXDOMAIN result (PR#2352)

#### Outputs

Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Depends: bash-completion,
cron,
jq,
python3-dateutil (>= 2.5),
python3-dnspython (>= 1.11.1),
python3-dnspython (>= 2.0.0),
python3-openssl,
python3-psutil (>= 1.2.1),
python3-redis (>= 2.10),
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later

Sphinx>=3.2.1
dnspython>=1.11.1
dnspython>=2.0.0
psutil>=1.2.1
python-dateutil>=2.5
python-termstyle>=0.1.10
Expand Down
5 changes: 1 addition & 4 deletions intelmq/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,9 +928,6 @@ def resolve_dns(*args, **kwargs) -> dns.resolver.Answer:
Parameters:
see: https://dnspython.readthedocs.io/en/stable/resolver-class.html#dns.resolver.Resolver.resolve
The `search` parameter is always set to True for compatibility with dnspython version 1.
"""
if dns.version.MAJOR < 2:
return dns.resolver.query(*args, **kwargs)
return dns.resolver.resolve(*args, **kwargs, search=True)
return dns.resolver.resolve(*args, **kwargs)
14 changes: 0 additions & 14 deletions intelmq/tests/lib/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,6 @@ def test_load_configuration_yaml_invalid(self):
with self.assertRaises(ScannerError):
utils.load_configuration(filename)

@unittest.mock.patch.object(utils.dns.version, "MAJOR", 1)
def test_resolve_dns_supports_dnspython_v1(self):
with unittest.mock.patch.object(utils.dns.resolver, "query") as query_mocks:
utils.resolve_dns("example.com", "any", other="parameter")

query_mocks.assert_called_once_with("example.com", "any", other="parameter")

@unittest.mock.patch.object(utils.dns.version, "MAJOR", 2)
def test_resolve_dns_supports_dnspython_v2(self):
with unittest.mock.patch.object(utils.dns.resolver, "resolve", create=True) as resolve_mocks:
utils.resolve_dns("example.com", "any", other="parameter")

resolve_mocks.assert_called_once_with("example.com", "any", other="parameter", search=True)

@skip_internet()
def test_resolve_dns_returns_answer(self):
answer = utils.resolve_dns("example.com")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from setuptools import find_packages, setup

REQUIRES = [
'dnspython>=1.11.1',
'dnspython>=2.0.0',
'psutil>=1.2.1',
'python-dateutil>=2.5',
'python-termstyle>=0.1.10',
Expand Down

0 comments on commit a0d3c14

Please sign in to comment.