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 parse
pull/520/head
chrisr3d 2021-08-26 15:02:32 +02:00
parent 7645b97bf7
commit 1d7f0ee1f0
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 3 additions and 4 deletions

View File

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