Skip to content

Commit a099136

Browse files
committed
Redact index password from logs
Closes #6124
1 parent 2a6d282 commit a099136

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

news/6124.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Redact the password from index urls in a debug message (using --no-index & --verbose options together)

src/pip/_internal/cli/base_command.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
)
2828
from pip._internal.req.req_file import parse_requirements
2929
from pip._internal.utils.logging import setup_logging
30-
from pip._internal.utils.misc import get_prog, normalize_path
30+
from pip._internal.utils.misc import (
31+
get_prog, normalize_path, redact_password_from_url,
32+
)
3133
from pip._internal.utils.outdated import pip_version_check
3234
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
3335

@@ -287,7 +289,10 @@ def _build_package_finder(
287289
"""
288290
index_urls = [options.index_url] + options.extra_index_urls
289291
if options.no_index:
290-
logger.debug('Ignoring indexes: %s', ','.join(index_urls))
292+
logger.debug(
293+
'Ignoring indexes: %s',
294+
','.join(redact_password_from_url(url) for url in index_urls),
295+
)
291296
index_urls = []
292297

293298
return PackageFinder(

0 commit comments

Comments
 (0)