mirror of https://github.com/MISP/misp-modules
fix: [hashlookup] Fixed the errors handling
- Since the modules system is waiting for a dict, we return `misperrors` instead of the actual value of the 'error' key, and the module will no longer fail when there is no result to parsepull/520/head
parent
7645b97bf7
commit
1d7f0ee1f0
|
@ -70,17 +70,16 @@ def handler(q=False):
|
||||||
hashlookupresult = r.json()
|
hashlookupresult = r.json()
|
||||||
if not hashlookupresult:
|
if not hashlookupresult:
|
||||||
misperrors['error'] = 'Empty result'
|
misperrors['error'] = 'Empty result'
|
||||||
return misperrors['error']
|
return misperrors
|
||||||
elif r.status_code == 404:
|
elif r.status_code == 404:
|
||||||
misperrors['error'] = 'Non existing hash'
|
misperrors['error'] = 'Non existing hash'
|
||||||
return misperrors['error']
|
return misperrors
|
||||||
else:
|
else:
|
||||||
misperrors['error'] = 'API not accessible'
|
misperrors['error'] = 'API not accessible'
|
||||||
return misperrors['error']
|
return misperrors
|
||||||
parser = HashlookupParser(attribute, hashlookupresult, api_url)
|
parser = HashlookupParser(attribute, hashlookupresult, api_url)
|
||||||
parser.parse_hashlookup_information()
|
parser.parse_hashlookup_information()
|
||||||
result = parser.get_result()
|
result = parser.get_result()
|
||||||
print(result)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue