Skip to content
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

redact passwords in output when using --find-links #6489

Merged
merged 6 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/6489.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hide passwords in output when using ``--find-links``.
3 changes: 2 additions & 1 deletion src/pip/_internal/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,8 @@ def get_formatted_locations(self):
)
if self.find_links:
lines.append(
"Looking in links: {}".format(", ".join(self.find_links))
"Looking in links: {}".format(", ".join(
redact_password_from_url(url) for url in self.find_links))
)
return "\n".join(lines)

Expand Down
14 changes: 9 additions & 5 deletions tests/unit/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,18 @@ def test_get_formatted_locations_basic_auth():
"""
index_urls = [
'https://pypi.org/simple',
'https://user:pass@repo.domain.com',
'https://repo-user:repo-pass@repo.domain.com',
]
finder = PackageFinder.create([], index_urls, session=[])
find_links = [
'https://links-user:links-pass@page.domain.com'
]
finder = PackageFinder.create(find_links, index_urls, session=[])

result = finder.get_formatted_locations()
assert 'user' in result
assert '****' in result
assert 'pass' not in result
anlutro marked this conversation as resolved.
Show resolved Hide resolved
assert 'repo-user:****@repo.domain.com' in result
assert 'repo-pass' not in result
assert 'links-user:****@page.domain.com' in result
assert 'links-pass' not in result


@pytest.mark.parametrize(
Expand Down