mirror of https://github.com/MISP/misp-modules
fix: [expansion] Better config field handling for various modules
- Testing if config is present before trying to look whithin the config field - The config field should be there when the module is called form MISP, but it is not always the case when the module is queried from somewhere elsepull/603/head
parent
dc7463a67e
commit
d0ddfb3355
|
@ -16,10 +16,9 @@ def handler(q=False):
|
||||||
if q is False:
|
if q is False:
|
||||||
return False
|
return False
|
||||||
request = json.loads(q)
|
request = json.loads(q)
|
||||||
if (request.get('config')):
|
if not request.get('config') or not request['config'].get('apikey'):
|
||||||
if (request['config'].get('apikey') is None):
|
misperrors['error'] = 'Farsight DNSDB apikey is missing'
|
||||||
misperrors['error'] = 'Farsight DNSDB apikey is missing'
|
return misperrors
|
||||||
return misperrors
|
|
||||||
client = DnsdbClient(server, request['config']['apikey'])
|
client = DnsdbClient(server, request['config']['apikey'])
|
||||||
if request.get('hostname'):
|
if request.get('hostname'):
|
||||||
res = lookup_name(client, request['hostname'])
|
res = lookup_name(client, request['hostname'])
|
||||||
|
|
|
@ -31,9 +31,8 @@ def handler(q=False):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if request['config'].get('api_key'):
|
if request.get('config') and request['config'].get('api_key'):
|
||||||
api_key = request['config'].get('api_key')
|
api_key = request['config'].get('api_key')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
misperrors['error'] = 'Authorization required'
|
misperrors['error'] = 'Authorization required'
|
||||||
return misperrors
|
return misperrors
|
||||||
|
|
|
@ -24,7 +24,7 @@ def handler(q=False):
|
||||||
|
|
||||||
request = json.loads(q)
|
request = json.loads(q)
|
||||||
|
|
||||||
if not request.get('config') and not (request['config'].get('apikey')):
|
if not request.get('config') or not request['config'].get('apikey'):
|
||||||
misperrors['error'] = 'Onyphe authentication is missing'
|
misperrors['error'] = 'Onyphe authentication is missing'
|
||||||
return misperrors
|
return misperrors
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ def handler(q=False):
|
||||||
|
|
||||||
request = json.loads(q)
|
request = json.loads(q)
|
||||||
|
|
||||||
if not request.get('config') and not (request['config'].get('apikey')):
|
if not request.get('config') or not request['config'].get('apikey'):
|
||||||
misperrors['error'] = 'Onyphe authentication is missing'
|
misperrors['error'] = 'Onyphe authentication is missing'
|
||||||
return misperrors
|
return misperrors
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue