-
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
The --fix
flag doesn't work for dependencies of top-level requirements
#291
Comments
@woodruffw @di I think 1) probably isn't practical to implement but 2) or 3) seem possible. I'm leaning towards 2) personally. Of course, I'm open to suggestions if there's an idea I've missed. |
Yeah, this is an interesting problem. IMO, (1) is both impractical and slightly wrong: a vulnerability in a subdependency might be completely transient and fixed on the next installation (by I'm also not keen on (3) personally, since it drastically limits the usefulness of So yeah, I think (2) is reasonable. Some thoughts:
Finally, another fourth option: we could do nothing. There's an argument to be made that, in the absence of a fixed dependency tree, Under this last option, IMO we should simply warn (perhaps with big red text) that a subdependency is vulnerable, and not attempt to fix it by patching it into the requirements input. |
I'm still trying to digest this part. Is the scenario you're talking about where we have a requirement with a conditional dependency (or even just a requirement with a marker)? If we patch a sub dependency, it gets explicitly listed in the requirements file and therefore, starts getting installed in situations where it normally wouldn't? |
Sort of — I’m imagining a situation where the user specifies version N of a package, which has a sub dependency with version Q. Q has a vulnerability, so we upgrade it to Q’. The user then later manually (or automatically) upgrades N to N’, which happens to remove Q from its dependency set. With that, the user would be left with an “orphaned” dependency on Q’ in their requirements, since it’s no longer a subdependency.
Sent from mobile. Please excuse my brevity.
… On Jun 12, 2022, at 8:49 AM, Alex Cameron ***@***.***> wrote:
Finally, another fourth option: we could do nothing. There's an argument to be made that, in the absence of a fixed dependency tree, pip-audit shouldn't assert that dependencies will continue to exist across multiple runs. (2) does that -- it assumes that a subdependency should be saved to the requirements file, which might break the file across multiple platforms (or simply cease to be required, if the subdependency was a sub-sub-dependency that was only needed by a specific point release of a subdependency).
I'm still trying to digest this part. Is the scenario you're talking about where we have a requirement with a conditional dependency (or even just a requirement with a marker)? If we patch a sub dependency, it gets explicitly listed in the requirements file and therefore, gets installed in situations where it normally wouldn't?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Forgot to mention: if we end up in a state like #291 (comment) where We could possibly do that by tracking our own comments (added during |
I'm still working on a repro for this but just from reading the code, I'm pretty sure that this isn't correct. When running
--fix
on the current environment it works like this:I think this is reasonable for an automated fix.
However, for requirements files our approach doesn't work well. We're currently doing:
However, transitive dependencies won't necessarily appear in the requirements file unless the requirements have pinned hashes. So in this case, the fix won't be applied to the requirements file. I think we have a few options here:
--fix
logic to work differently for requirements files. We'll need something that identifies which top-level requirement a dependency belongs to and then upgrade the top-level requirement, check whether it fixed the vulnerability, rinse, repeat.--fix
write a new line to the requirements file explicitly listing the fixed dependency if it isn't already there.--fix
in combination with--require-hashes
or--no-deps
since we know we'll have the full set of dependencies in the requirements file.At the moment, I'm trying to find a package that has a vulnerability in its dependency so I can actually test this out.
The text was updated successfully, but these errors were encountered: