Skip to content

Commit

Permalink
chg: [rbl] Added a timeout parameter to change the resolver timeout &…
Browse files Browse the repository at this point in the history
… lifetime if needed
  • Loading branch information
chrisr3d committed Apr 16, 2021
1 parent 4a20045 commit dbff9b3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions misp_modules/modules/expansion/rbl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

try:
import dns.resolver
resolver = dns.resolver.Resolver()
resolver.timeout = 0.2
resolver.lifetime = 0.2
except ImportError:
print("dnspython3 is missing, use 'pip install dnspython3' to install it.")
sys.exit(0)
Expand All @@ -15,7 +12,7 @@
moduleinfo = {'version': '0.2', 'author': 'Christian Studer',
'description': 'Check an IPv4 address against known RBLs.',
'module-type': ['expansion', 'hover']}
moduleconfig = []
moduleconfig = ['timeout']

rbls = (
"spam.spamrats.com",
Expand Down Expand Up @@ -88,6 +85,13 @@ def handler(q=False):
else:
misperrors['error'] = "Unsupported attributes type"
return misperrors
resolver = dns.resolver.Resolver()
try:
timeout = float(request['config']['timeout'])
except (KeyError, ValueError):
timeout = 0.4
resolver.timeout = timeout
resolver.lifetime = timeout
infos = {}
ipRev = '.'.join(ip.split('.')[::-1])
for rbl in rbls:
Expand Down

0 comments on commit dbff9b3

Please sign in to comment.