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:
|
||||
return False
|
||||
request = json.loads(q)
|
||||
if (request.get('config')):
|
||||
if (request['config'].get('apikey') is None):
|
||||
misperrors['error'] = 'Farsight DNSDB apikey is missing'
|
||||
return misperrors
|
||||
if not request.get('config') or not request['config'].get('apikey'):
|
||||
misperrors['error'] = 'Farsight DNSDB apikey is missing'
|
||||
return misperrors
|
||||
client = DnsdbClient(server, request['config']['apikey'])
|
||||
if request.get('hostname'):
|
||||
res = lookup_name(client, request['hostname'])
|
||||
|
|
|
@ -31,9 +31,8 @@ def handler(q=False):
|
|||
else:
|
||||
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')
|
||||
|
||||
else:
|
||||
misperrors['error'] = 'Authorization required'
|
||||
return misperrors
|
||||
|
|
|
@ -24,7 +24,7 @@ def handler(q=False):
|
|||
|
||||
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'
|
||||
return misperrors
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ def handler(q=False):
|
|||
|
||||
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'
|
||||
return misperrors
|
||||
|
||||
|
|
Loading…
Reference in New Issue