mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
Filter sensitive keys from log-messages (#1186)
This commit is contained in:
committed by
Raphael Michel
parent
0617abe6e3
commit
a2b075c0d7
@@ -77,6 +77,13 @@ class LoggingMixin:
|
||||
|
||||
logentry = LogEntry(content_object=self, user=user, action_type=action, event=event, **kwargs)
|
||||
if isinstance(data, dict):
|
||||
sensitivekeys = ['password', 'secret', 'api_key']
|
||||
|
||||
for sensitivekey in sensitivekeys:
|
||||
for k, v in data.items():
|
||||
if (sensitivekey in k) and v:
|
||||
data[k] = "********"
|
||||
|
||||
logentry.data = json.dumps(data, cls=CustomJSONEncoder)
|
||||
elif data:
|
||||
raise TypeError("You should only supply dictionaries as log data.")
|
||||
|
||||
Reference in New Issue
Block a user