-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Hide security-sensitive strings in VCS command log messages #6890
Conversation
a93a8f7
to
b9d70a6
Compare
b9d70a6
to
03eedab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a nice idea, good job. :)
9d7f6e3
to
5ffc930
Compare
PR updated. Thanks again for the thorough review, @chrahunt. 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment, otherwise LGTM.
PR updated. I also implemented |
Thanks again for the thoughtful reviews, @chrahunt and @pradyunsg! |
# Also, we don't apply str() to arguments that aren't HiddenText since | ||
# this can trigger a UnicodeDecodeError in Python 2 if the argument | ||
# has type unicode and includes a non-ascii character. (The type | ||
# checker doesn't ensure the annotations are correct in all cases.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reg the type-checker: I think we're supposed to use mypy.Text
for things that would be unicode on Python 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to always be str
(if everything is working correctly), but because our type-checking isn't 100%, it's possible something of unicode
type can slip through the cracks (e.g. because of # type: ignore
comments at some of our annotations). One example is the _get_win_folder_with_ctypes()
function in appdirs.py
that is annotated with str
but returns unicode
in Python 2. In cases that slip through the cracks, the point was not to force a crash if we don't need to..
This PR looks great @cjerdonek! ^>^ |
This PR adds a new
HiddenText
class to wrap sensitive strings and starts using them in the VCS modules to protect (1) URL's containing potential auth info, and (2) passwords that can be included in VCS command-line arguments. This finishes the work started in PR #6862.