-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1104 from ascheel/main
Sanitize URLs for logging/display purposes.
- Loading branch information
Showing
4 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This change will remove sensitive output in URLs for private repositories require a login provided in the format of http(s)://<user>:<pass>@domain.com, replacing the sensitive text with a sanitized "*****:*****" to prevent these details from showing up in log files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,31 @@ def test_get_repository_config_missing(config_file): | |
assert utils.get_repository_from_config(config_file, "pypi") == exp | ||
|
||
|
||
def test_get_repository_config_url_with_auth(config_file): | ||
repository_url = "https://user:[email protected]/pypi" | ||
exp = { | ||
"repository": "https://notexisting.python.org/pypi", | ||
"username": "user", | ||
"password": "pass", | ||
} | ||
assert utils.get_repository_from_config(config_file, "foo", repository_url) == exp | ||
assert utils.get_repository_from_config(config_file, "pypi", repository_url) == exp | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_url, expected_url", | ||
[ | ||
("https://upload.pypi.org/legacy/", "https://upload.pypi.org/legacy/"), | ||
( | ||
"https://user:[email protected]/legacy/", | ||
"https://********@upload.pypi.org/legacy/", | ||
), | ||
], | ||
) | ||
def test_sanitize_url(input_url: str, expected_url: str) -> None: | ||
assert utils.sanitize_url(input_url) == expected_url | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"repo_url, message", | ||
[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters