Skip to content

Commit d0ddfb3

Browse files
committedOct 30, 2019
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
1 parent dc7463a commit d0ddfb3

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed
 

‎misp_modules/modules/expansion/farsight_passivedns.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ def handler(q=False):
1616
if q is False:
1717
return False
1818
request = json.loads(q)
19-
if (request.get('config')):
20-
if (request['config'].get('apikey') is None):
21-
misperrors['error'] = 'Farsight DNSDB apikey is missing'
22-
return misperrors
19+
if not request.get('config') or not request['config'].get('apikey'):
20+
misperrors['error'] = 'Farsight DNSDB apikey is missing'
21+
return misperrors
2322
client = DnsdbClient(server, request['config']['apikey'])
2423
if request.get('hostname'):
2524
res = lookup_name(client, request['hostname'])

‎misp_modules/modules/expansion/macaddress_io.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ def handler(q=False):
3131
else:
3232
return False
3333

34-
if request['config'].get('api_key'):
34+
if request.get('config') and request['config'].get('api_key'):
3535
api_key = request['config'].get('api_key')
36-
3736
else:
3837
misperrors['error'] = 'Authorization required'
3938
return misperrors

‎misp_modules/modules/expansion/onyphe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def handler(q=False):
2424

2525
request = json.loads(q)
2626

27-
if not request.get('config') and not (request['config'].get('apikey')):
27+
if not request.get('config') or not request['config'].get('apikey'):
2828
misperrors['error'] = 'Onyphe authentication is missing'
2929
return misperrors
3030

‎misp_modules/modules/expansion/onyphe_full.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def handler(q=False):
2525

2626
request = json.loads(q)
2727

28-
if not request.get('config') and not (request['config'].get('apikey')):
28+
if not request.get('config') or not request['config'].get('apikey'):
2929
misperrors['error'] = 'Onyphe authentication is missing'
3030
return misperrors
3131

0 commit comments

Comments
 (0)
Please sign in to comment.