Skip to content

Commit c219ce4

Browse files
authored
Merge pull request from GHSA-m87f-39q9-6f55
1 parent 1212e0f commit c219ce4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

notebook/log.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ def log_request(handler, log=access_log, log_json=False):
4444
ns['referer'] = request.headers.get('Referer', 'None')
4545
msg = msg + ' referer={referer}'
4646
if status >= 500 and status != 502:
47-
# log all headers if it caused an error
47+
# Log a subset of the headers if it caused an error.
48+
headers = {}
49+
for header in ['Host', 'Accept', 'Referer', 'User-Agent']:
50+
if header in request.headers:
51+
headers[header] = request.headers[header]
4852
if log_json:
49-
log_method("", extra=dict(props=dict(request.headers)))
53+
log_method("", extra=dict(props=headers))
5054
else:
51-
log_method(json.dumps(dict(request.headers), indent=2))
55+
log_method(json.dumps(dict(headers), indent=2))
5256
if log_json:
5357
log_method("", extra=dict(props=ns))
5458
else:

0 commit comments

Comments
 (0)