Merge pull request #850 from Derekt2/patch-1

Update 500 errors to exclude logging authorization header
pull/858/head
Raphaël Vinot 2022-07-25 16:33:21 +02:00 committed by GitHub
commit 06ca1abfe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -3525,7 +3525,8 @@ class PyMISP:
def _check_response(self, response: requests.Response, lenient_response_type: bool = False, expect_json: bool = False) -> Union[Dict, str]:
"""Check if the response from the server is not an unexpected error"""
if response.status_code >= 500:
logger.critical(everything_broken.format(response.request.headers, response.request.body, response.text))
headers_without_auth = {i:response.request.headers[i] for i in response.request.headers if i!='Authorization'}
logger.critical(everything_broken.format(headers_without_auth, response.request.body, response.text))
raise MISPServerError(f'Error code 500:\n{response.text}')
if 400 <= response.status_code < 500: