GitHub user user1500177 added a comment to the discussion: How to Mask
Passwords in Superset Action Log (DatabaseRestApi.import_)
@dosu
SO will the following code also capture the mutiple records that may be
generated as result of an event like you said ??? (1)
2.Will any logs be skipped due to this change ?
PROPOSED CODE :
class MaskPasswordsEventLogger(DBEventLogger):
def _mask_sensitive(self, data):
try:
if isinstance(data, dict):
return {
k: (
"***MASKED***" if k.lower() in {"password",
"passwords", "db_password", "access_token", "secret"}
else self._mask_sensitive(v)
)
for k, v in data.items()
}
elif isinstance(data, list):
return [self._mask_sensitive(item) for item in data]
else:
return data
except Exception as e:
import logging
logging.warning(f"Error masking sensitive data: {e}")
return data
def log(self, user_id, action, *args, **kwargs):
try:
# Mask sensitive fields in kwargs before passing to DBEventLogger
masked_kwargs = self._mask_sensitive(kwargs)
super().log(user_id, action, *args, **masked_kwargs)
except Exception as e:
import logging
logging.warning(f"Error in custom event logger: {e}")
GitHub link:
https://github.com/apache/superset/discussions/35415#discussioncomment-14580631
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]