Browse Source

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 else
pull/352/head
chrisr3d 2 years ago
parent
commit
d0ddfb3355
No known key found for this signature in database GPG Key ID: 6BBED1B63A6D639F
  1. 7
      misp_modules/modules/expansion/farsight_passivedns.py
  2. 3
      misp_modules/modules/expansion/macaddress_io.py
  3. 2
      misp_modules/modules/expansion/onyphe.py
  4. 2
      misp_modules/modules/expansion/onyphe_full.py

7
misp_modules/modules/expansion/farsight_passivedns.py

@ -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'])

3
misp_modules/modules/expansion/macaddress_io.py

@ -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

2
misp_modules/modules/expansion/onyphe.py

@ -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

2
misp_modules/modules/expansion/onyphe_full.py

@ -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…
Cancel
Save