Avoid exposing secrets on requirements.txt for --[extra-]index-url with credentials
See original GitHub issueWhen running
pip-compile requirements.in --extra-index-url https://${PYPI_USERNAME}:${PYPI_PASSWORD}@gitlab.com/api/v4/projects/.../packages/pypi/simple
the resulting requirements is
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --extra-index-url='https://[USERNAME]:****@gitlab.com/api/v4/projects/.../packages/pypi/simple' requirements_test.in
#
--extra-index-url https://[USERNAME]:[PASSWORD]@gitlab.com/api/v4/projects/.../packages/pypi/simple
...==0.2.7 # via -r requirements.in
numpy==1.19.1 # via ...
scipy==1.5.2 # via ...
where both [USERNAME]
and [PASSWORD]
are shown in plain text. Since the requirements.txt
shall end in version control, specially with post-commit hooks, this exfiltrates secrets to the git repository.
Environment Versions
- OS Type: Mac
- Python version:
Python 3.7.3
- pip version:
pip 20.2.1
- pip-tools version:
pip-compile, version 5.3.1
Steps to replicate
See above.
Expected result
The secrets should not be outputted to the compiled requirements.txt
. Instead, they should keep their original names, as pip accepts.
In the example above, IMO we should only output
--extra-index-url https://${PYPI_USERNAME}:${PYPI_PASSWORD}@gitlab.com/api/v4/projects/.../packages/pypi/simple
both on the header and on the actual requirements. It is the responsibility of the deployment team to ensure that they have the credentials to download dependencies from a pypi server.
Actual result
The secrets are outputted to requirements.txt
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Credentials in pip.conf for private PyPI - python - Stack Overflow
But here I see two problems: For each url you'll need each time to specify the same username and password. Username and password...
Read more >pipenv Documentation - Read the Docs
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the. Python...
Read more >extra-index-url` to install private packages from GitLab CI
I have the following use case: My client develops a closed-source Python library, with dependencies specified in setup.py through setuptools ...
Read more >Install custom Python Libraries from private PyPI on Databricks
In this blog post I'm going to explain how to integrate your private PyPI repositories on Databricks clusters step by step.
Read more >Documentation for the Command-Line Interface (CLI) and ...
--extra-index-url=https://packagecloud.io/user/publicRepo/pypi/simple. private repos: Append the repository to requirements.txt using a read token.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
closing in favor of #966 .
The issue here is that the shell is expanding the environment variables, so pip-compile will get the
--extra-index-url
parameter value with the environment variables already expanded. A solution is to use single quotes, to prevent the shell from expanding them, like:But that only works partially. See #1367.