-
Notifications
You must be signed in to change notification settings - Fork 64
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
pip-audit not auditing the same package versions as pip installs. #248
Comments
Thanks for the report! Looks like there's a spurious sub-dependency here that we're not parsing correctly. When evaluating this for We get:
Where that first one is:
|
Yep, this looks specifically like a failure to handle "implicit post releases" as specified by PEP 440:
|
Did a bit of digging, and this looks like a bug in >>> from packaging.utils import parse_sdist_filename
>>> parse_sdist_filename("cffi-1.0.2-2.tar.gz")
('cffi-1-0-2', <Version('2')>) |
Confirmed that it's the latest release of
Specifically, the comment about "PEP 440 versions [not containing] dashes" is incorrect, since pre-normalized versions can. If I pass the version string directly into
|
Upstream: pypa/packaging#527 |
Given the age of the |
Yeah, that seems like a reasonable workaround. I can have a fix PR ready with that in a moment. |
) * pip_audit/dependency_source: match candidate names against project See: pypa/packaging#527. Fixes #248. * pip_audit/dependency_source: remove redundant `is_satisfied_by` test * test: add tests for vexing sdist parses * test: update comment * CHANGELOG: record fixes * setup: pin `click` Works around psf/black#2964 * setup: add note about pinned click
@skilleter I can confirm locally that #249 fixes this for me: (env) work:pip-audit william$ pip-audit --format=json -r ~/tmp/r3.txt
No known vulnerabilities found
{"dependencies": [{"name": "cryptography", "version": "36.0.2", "vulns": []}, {"name": "cffi", "version": "1.15.0", "vulns": []}, {"name": "pycparser", "version": "2.21", "vulns": []}], "fixes": []} whre
Can you also confirm? Once we do so, I'll push out a patch release 🙂 |
(Reopening for independent confirmation.) |
I can confirm that this now works for me, thanks very much. |
No problem, thank you for confirming! I’ll cut a point release shortly.
Sent from mobile. Please excuse my brevity.
… On Mar 29, 2022, at 5:54 AM, John Skilleter ***@***.***> wrote:
I can confirm that this now works for me, thanks very much.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.
|
Cut with 2.1.1; should be available on PyPI shortly. Thanks again for reporting! |
Bug description
My understanding of pip-audit is that, when given a
requirements.txt
file, it would audit the same versions of the same packages thatpip
would install. This doesn't seem to be the case.I have a
requirements.txt
file containing just the cryptography module with no version constraint specified.If I create a venv and install the package then it installs:
If I run
pip-audit -r requirement.txt
then it tries to install cffi version 1.0.2-2 rather than 1.15.0 and fails with:pip_audit._virtual_env.VirtualEnvError: Failed to install packages: ['/tmp/tmpffo5omkp/bin/python3', '-m', 'pip', 'install', '/tmp/tmp4dbeewpp/cffi-1.0.2-2.tar.gz']
If I change the
requirements.txt
file to containcryptography==36.0.2
, the same thing happens.Likewise, if I append
cffi==1.15.0
to therequirements.txt
file pip-audit still tries, and fails, to use cffi 1.0.2-2Reproduction steps
Running in Ubuntu 22.04 Docker container with just python3, venv, git installed.
Running as a non-root user in the container I install pip-audit, either via pip, or directly from the git repo
Create requirements.txt containing just
cryptography
Create a venv, install cryptography package from requirements.txt using pip
Run pip list to confirm package versions installed as listed above (specifically cffi 1.15.0)
Run pip-audit -r requirements.txt
pip-audit tries to install cffi 1.0.2.2 and fails, as above
Expected behavior
pip-audit should audit the same packages and the same versions of the packages as pip install installs
pip-audit should not fail
Screenshots and logs
Dockerfile used:
Contents of requirements.txt file:
Output from
pip list
in venv after installing cryptography package:Output from
pip-audit -v -r requirements.txt
:Platform information
pip-audit
version (pip-audit -V
): pip-audit 2.1.0python -V
orpython3 -V
): Python 3.10.3pip
version (pip -V
orpip3 -V
): pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)The text was updated successfully, but these errors were encountered: