Skip to content

Commit 9eccfae

Browse files
anlutroxavfernandez
authored andcommitted
redact passwords in output when using --find-links (#6489)
1 parent c34191f commit 9eccfae

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

news/6489.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hide passwords in output when using ``--find-links``.

src/pip/_internal/index.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,8 @@ def get_formatted_locations(self):
660660
)
661661
if self.find_links:
662662
lines.append(
663-
"Looking in links: {}".format(", ".join(self.find_links))
663+
"Looking in links: {}".format(", ".join(
664+
redact_password_from_url(url) for url in self.find_links))
664665
)
665666
return "\n".join(lines)
666667

tests/unit/test_index.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,18 @@ def test_get_formatted_locations_basic_auth():
183183
"""
184184
index_urls = [
185185
'https://pypi.org/simple',
186-
'https://user:[email protected]',
186+
'https://repo-user:repo-[email protected]',
187187
]
188-
finder = PackageFinder.create([], index_urls, session=[])
188+
find_links = [
189+
'https://links-user:[email protected]'
190+
]
191+
finder = PackageFinder.create(find_links, index_urls, session=[])
189192

190193
result = finder.get_formatted_locations()
191-
assert 'user' in result
192-
assert '****' in result
193-
assert 'pass' not in result
194+
assert 'repo-user:****@repo.domain.com' in result
195+
assert 'repo-pass' not in result
196+
assert 'links-user:****@page.domain.com' in result
197+
assert 'links-pass' not in result
194198

195199

196200
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)