-
Notifications
You must be signed in to change notification settings - Fork 62
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
Crash on package @ git+...
dependencies
#382
Comments
This doesn't crash for me:
Can you provide the traceback you're getting? |
$ pip-audit --no-deps -r requirements.txt
WARNING:pip_audit._cli:--no-deps is supported, but users are encouraged to fully hash their pinned dependencies
WARNING:pip_audit._cli:Consider using a tool like `pip-compile`: https://pip-tools.readthedocs.io/en/latest/#using-hashes
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/bin/pip-audit", line 8, in <module>
sys.exit(audit())
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/pip_audit/_cli.py", line 432, in audit
for (spec, vulns) in auditor.audit(source):
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/pip_audit/_audit.py", line 66, in audit
for dep, vulns in self._service.query_all(specs):
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/pip_audit/_service/interface.py", line 150, in query_all
for spec in specs:
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/pip_audit/_dependency_source/requirement.py", line 114, in collect
for _, dep in self._collect_cached_deps(filename, reqs):
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/pip_audit/_dependency_source/requirement.py", line 312, in _collect_cached_deps
for req, dep in self._collect_preresolved_deps(
File "/opt/homebrew/Caskroom/miniforge/base/envs/py310/lib/python3.10/site-packages/pip_audit/_dependency_source/requirement.py", line 259, in _collect_preresolved_deps
raise RequirementSourceError(
pip_audit._dependency_source.requirement.RequirementSourceError: requirement hypothesis is not pinned, URL requirements must be pinned with #egg=your_package_name==your_package_version: hypothesis@ git+https://github.com/HypothesisWorks/hypothesis.git@bb6b55ad8d#subdirectory=hypothesis-python from git+https://github.com/HypothesisWorks/hypothesis.git@bb6b55ad8d#subdirectory=hypothesis-python (from RequirementLine(line_number=8, line='hypothesis @ git+https://github.com/HypothesisWorks/hypothesis.git@bb6b55ad8d#subdirectory=hypothesis-python', filename=PosixPath('requirements.txt'))) (added newlines for clarity, otherwise unedited) I suspect it's relevant that we're using a private index, and don't have |
Thanks for the additional context @Zac-HD! I'll have time to attempt to repro this (and hopefully come up with a quick fix) in the coming days. |
One small thing to note (that I don't think is causing the bug, but might be helpful):
If you're trying to avoid all network interaction with PyPI, then you'll probably want |
Did some digging here, and it looks like this error only happens with In particular, it looks like it happens because In other words, this:
should be this:
...however, that still fails with the same error, which makes me think it might be a bug in our requirements parser. Will continue looking. |
Yep, this looks like a case of
...or us using their API wrong. I'm going to file an upstream issue to get some clarification, but this is definitely a bug on our side at the minimum! |
Going further, I'm not 100% sure our current guidance in that exception ( cc @tetsuo-cpp since you wrote this bit of the code: do you know where the |
Yep, confirmed: that syntax is definitely not official or supported: pypa/pip#5384 It seems like the only way to support "pinned" dependencies with VCS URLs is to use VCS-specific tagging (e.g. git tags or revs). So we need to update the error here to clarify that |
Could we instead skip VCS URLs in My motivation is that I want to check a requirements file produced by |
I'm of two minds on this. On one hand, we explicitly discourage On the other hand, I agree that skipping URL deps makes sense -- they're fundamentally outside of the PyPI ecosystem, so auditing them against PyPI makes very little sense. Except that they have sub-dependencies, and we do want to audit those... Here's what I'm currently thinking: we could add another option, something like cc @di for thoughts. |
Thought about this some more: we currently skip deps in every mode if they aren't available on PyPI and URL dependencies are trivially not on PyPI, so it makes sense to skip them as well (and allow users to fail with |
I just confirmed that |
Not sure whether this is relevant anymore, but I'll reply anyway. Both |
Yeah, that's interesting -- Edit: Opened pypa/pip#11567 to track that behavior. |
I'm bumping into this issue attempting to list a forked git repo as a dependency. I use pip-compile to get the dependency into requirements.txt as follows:
And when pip-audit runs through pre-commit it outputs the following:
I've always used --no-deps because pip-audit will hang on my Debian system without it. Any ideas? |
Thanks for telling us @seankfh! Would you mind opening a separate issue for that? The top-level issue here was a crash, not a behavioral consideration around how (And please include any details about that hang you're seeing!) |
Bug description
Using
package @ git+...
dependencies crashespip-audit
with a traceback, when I'd expect it to output the usual report with those packages listed by name and skip-reason if unauditable.Reproduction steps
Platform information
pip-audit
version (pip-audit -V
):pip-audit 2.4.4
python -V
orpython3 -V
):Python 3.10.6
pip
version (pip -V
orpip3 -V
):pip 22.3
The text was updated successfully, but these errors were encountered: