mirror of https://github.com/MISP/misp-modules
chg: [rbl] Added a timeout parameter to change the resolver timeout & lifetime if needed
parent
4a20045787
commit
dbff9b3aa8
|
@ -3,9 +3,6 @@ import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
resolver = dns.resolver.Resolver()
|
|
||||||
resolver.timeout = 0.2
|
|
||||||
resolver.lifetime = 0.2
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("dnspython3 is missing, use 'pip install dnspython3' to install it.")
|
print("dnspython3 is missing, use 'pip install dnspython3' to install it.")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -15,7 +12,7 @@ mispattributes = {'input': ['ip-src', 'ip-dst'], 'output': ['text']}
|
||||||
moduleinfo = {'version': '0.2', 'author': 'Christian Studer',
|
moduleinfo = {'version': '0.2', 'author': 'Christian Studer',
|
||||||
'description': 'Check an IPv4 address against known RBLs.',
|
'description': 'Check an IPv4 address against known RBLs.',
|
||||||
'module-type': ['expansion', 'hover']}
|
'module-type': ['expansion', 'hover']}
|
||||||
moduleconfig = []
|
moduleconfig = ['timeout']
|
||||||
|
|
||||||
rbls = (
|
rbls = (
|
||||||
"spam.spamrats.com",
|
"spam.spamrats.com",
|
||||||
|
@ -88,6 +85,13 @@ def handler(q=False):
|
||||||
else:
|
else:
|
||||||
misperrors['error'] = "Unsupported attributes type"
|
misperrors['error'] = "Unsupported attributes type"
|
||||||
return misperrors
|
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 = {}
|
infos = {}
|
||||||
ipRev = '.'.join(ip.split('.')[::-1])
|
ipRev = '.'.join(ip.split('.')[::-1])
|
||||||
for rbl in rbls:
|
for rbl in rbls:
|
||||||
|
|
Loading…
Reference in New Issue