Skip to content

Commit

Permalink
Show asterisks for password
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrutledge committed Sep 25, 2021
1 parent 28d8571 commit f60db37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ def test_package_is_uploaded_incorrect_repo_url():
[
(None, None, ["username: <empty>", "password: <empty>"]),
("", "", ["username: <empty>", "password: <empty>"]),
("username", "password", ["username: username", "password: <hidden>"]),
("username", "password", ["username: username", "password: ********"]),
# Ctrl-V in Windows Command Prompt; see https://bugs.python.org/issue37426
("username", "\x16", ["username: username", "password: *"]),
],
)
def test_logs_username_and_password(username, password, messages, caplog):
Expand Down
2 changes: 1 addition & 1 deletion twine/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
(username or "", password or "") if username or password else None
)
logger.info(f"username: {username if username else '<empty>'}")
logger.info(f"password: <{'hidden' if password else 'empty'}>")
logger.info(f"password: {'*' * len(password) if password else '<empty>'}")

self.session.headers["User-Agent"] = self._make_user_agent_string()
for scheme in ("http://", "https://"):
Expand Down

0 comments on commit f60db37

Please sign in to comment.