forked from CGM_Public/pretix_original
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)
|
logentry = LogEntry(content_object=self, user=user, action_type=action, event=event, **kwargs)
|
||||||
if isinstance(data, dict):
|
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)
|
logentry.data = json.dumps(data, cls=CustomJSONEncoder)
|
||||||
elif data:
|
elif data:
|
||||||
raise TypeError("You should only supply dictionaries as log data.")
|
raise TypeError("You should only supply dictionaries as log data.")
|
||||||
|
|||||||
Reference in New Issue
Block a user