-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an ability to mask/exclude certain keys when printing show_locals=True
#2408
Comments
show_locals=True
show_locals=True
Agree in principal. Another (possibly complimentary) option might be to have a specially crafted local attribute with a set of keys to exclude from locals. Something like: def get_password(self):
_rich_exclude_locals = {"password"} This would be more granular than a global black list. If we were to add a blacklist, perhaps it should accept a list of regexes? |
Matching regexes sounds like a good suggestion to me. If possible it would be useful to somehow mask/remove subkeys also. For example if I have a local variable If this isn't possible then on the kedro side we will need to exclude |
That would be possible with atomic data structures. For other objects you can't really know what attributes will be displayed in the It would be possible for Rich to omit arbitrary |
+1, this seems like a big security issue for production |
I'd still accept a PR if anyone proposes an elegant solution, but frankly showing locals is a debug aid, and should always be disabled in production. |
I hope we solved your problem. If you like using Rich, you might also enjoy Textual |
Hello! We've just started our journey of adopting rich on kedro, the first part of this journey introduced the rich logging handler + pretty tracebacks.
We've just had a user, quite rightly, highlight that
show_locals
has printed out some credentials in plain text. The immediate fix for this is to setshow_locals=False
, which we will fix quickly.My question is as follows, would you accept a PR where we allow the user to exclude certain keys when printing out the stack trace? I think it would go somewhere in this dictionary comprehension:
rich/rich/traceback.py
Line 376 in aea574a
Thanks!
The text was updated successfully, but these errors were encountered: