-
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
scan without resolving/downloading dependencies #168
Comments
Thanks for the issue @wbolster! One quick question: do you pin hashes in this file as well as use |
currently not, but ideally yes. the reason we don't is because it doesn't work so well with some non-pypi index software (artifactory, devpi, ...), forcing hash calculation to turn into a slow ‘download everything, hash everything, compare’ operation during what should be a cheap ‘any updates available?’ check, which is literally a ci job that runs (yes, there are auto-upgrade bots that open pull requests, but they don't work well for self-hosted vpn-only repos, and hosting it adds ops overhead that's not currently worth it) |
without ‘solutionizing’ (terrible word, sorry) too much for a problem i may not fully understand, i can imagine something like this
…and it would be totally fine if it gives warnings for every non-exact dependency, e.g. if the requirements file contains
… it could print a warning that |
Unfortunately without hashes, a requirements file with only pins is not guaranteed to be exhaustive, and generally I think we want That said, I think it would be reasonable to automatically disable resolution if hashes are present. We could possibly give an option to disable resolution, but I think this would be somewhat confusing as it would have the effect of ignoring version ranges, and because |
i'm interested to learn why that is? exhaustiveness and pinning seem orthogonal?
pip can be told to not access index servers and not install dependencies: $ pip --no-index --no-deps … which works fine when installing from a directory full of pre-built wheels, for instance: $ pip --no-index --no-deps wheels/*.whl |
glancing at
…which seems really close to the information of a requirements file with only pinned versions in it, which this issue is about. |
Because source distributions. E.g., https://pypi.org/project/paradox/ only provides a source distribution with non-deterministic dependencies. Even if you pinned
Ah, good call. It seems like adding a |
Using |
thanks for the pointer about undeterministic dependencies,
…unless explicitly opting in to this behaviour of course 🙃 a |
Ah, I see what you're saying: we still install the requirements into a virtualenv, we just pass You mentioned two issues: the time it takes to resolve dependencies, and not failing on packages in private indexes, which we fixed in #162 and released in https://pypi.org/project/pip-audit/1.0.1/. Given that the latter should be resolved, how much of an issue is the former for you? I'm inclined to leave this open for a bit to get some additional perspectives here. |
no, that is not what i meant. i would actually like to not download any packages at all, let alone install them (somewhere). what i would like to do is is: ‘take my requirement file(s), and just tell me which ones have known security problems’, preferably by listing them and a non-zero exit code. my remark about the |
Just to make sure I understand: what would you like
There are four options that I see:
|
my original thinking was 2, with warnings for the packages that cannot be audited. but 3 or a variant thereof would be fine as well: e.g. find the ‘best’ (without dependency resolution) version that matches the version spec, and audit that. |
@alex came up with another use case for this: sometimes our dependency source can be something like a third-party package manager, which has already done the hard work of fully resolving the dependency tree for us. Performing the resolution step in that case would be pointless, since we already have all of the information available to us. What I'm thinking is a That will effectively address (2)/(3) above, since it assumes that the input is "flat" in the sense that no additional resolutions are necessary. |
Maybe |
I'm going to take a stab at this today! |
Initial thoughts here: since hash pinning has the effect of disabling dependency resolution, users that want to disable dependency resolution could do this now by hashing & pinning all dependencies. (This would also have the effect of getting more users to hash & pin dependencies). |
IMO we should include this, but with a nudge telling users to use My reasoning: There's no built-in way to hash all dependencies with just
|
@woodruffw SGTM |
maybe i'm misunderstanding, but it seems that
pip-audit
cannot scan the contents of a requirements file in the simplest way imaginable: for each entry, check if the specified version has known vulnerabilities.currently, running against a requirements file with exclusively exact version matches (
foo==x.y
), like this… downloads and (temporarily) installs various packages, which not only takes forever, but also eventually fails because some packages cannot be found – they come from a private index server, which is a different issue.
as a work-around, installing everything (also downloads and installs) and then using
pip-audit --local
seems to work, but this is not a convenient solution.i understand that in the general case, requirements files may not be exhaustive and may not have exact versions, in which case running a resolver etc makes total sense, but that's not always the case.
some background: the use case is that my requirements files are produced by
pip-tools
and hence constitute the exact list of pinned versions used by my application, and i would like to integratepip-audit
into a continuous integration job. i also runpip-compile
(frompip-tools
) in that job to warn about potential package upgrades, some of which come from private index servers, and it would be great ifpip-audit
can be added to it.The text was updated successfully, but these errors were encountered: