fix: [hibp] Fixed config handling to avoir KeyError exceptions

pull/496/head
chrisr3d 2021-04-14 16:52:55 +02:00
parent d522b25b20
commit 729feaa3f2
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ def handler(q=False):
misperrors['error'] = "Unsupported attributes type"
return misperrors
if (request['config'].get('api_key') is None):
if request.get('config') is None or request['config'].get('api_key') is None:
misperrors['error'] = 'Have I Been Pwned authentication is incomplete (no API key)'
return misperrors
else:
@ -37,7 +37,7 @@ def handler(q=False):
elif r.status_code == 404:
return {'results': [{'types': mispattributes['output'], 'values': 'OK (Not Found)'}]}
else:
misperrors['error'] = 'haveibeenpwned.com API not accessible (HTTP ' + str(r.status_code) + ')'
misperrors['error'] = f'haveibeenpwned.com API not accessible (HTTP {str(r.status_code)})'
return misperrors['error']