Skip to content
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

Feature request: Evaluate Cargo.toml #153

Closed
joshlf opened this issue Oct 12, 2019 · 3 comments
Closed

Feature request: Evaluate Cargo.toml #153

joshlf opened this issue Oct 12, 2019 · 3 comments

Comments

@joshlf
Copy link

joshlf commented Oct 12, 2019

While reading Cargo.lock is straightforward, one could easily have a Cargo.toml file that would allow semver resolution to pick a vulnerable version of a crate even if cargo didn't happen to pick that version in practice. It'd be cool if cargo audit could consume Cargo.toml and enumerate the set of every possibly valid choice of crate versions and emit a warning if any of them have known vulnerabilities. In response to this, the author could tighten the specification of which crate version is required.

@tarcieri
Copy link
Member

The main way I think we'll end up interacting with Cargo.toml files is via cargo-edit (see #151)

Otherwise the scenarios where what you're describing can happen seem... pretty unusual. Here are a few I can think of:

  • A new dependency is added which forces a SemVer-compatible downgrade to a vulnerable crate. But if they weren't SemVer compatible, it'd still pull in the vulnerable dependency anyway
  • The user runs cargo update and is upgraded to a vulnerable version of a crate from an unaffected one
  • The unaffected/patched version of a crate is yanked, the user runs cargo update, and is downgraded to a vulnerable non-yanked version

Have you actually encountered any of these (or something similar) in practice?

Otherwise I feel like trying to calculate all of the potential outcomes where you might end up with a vulnerable crate can't be done without duplicating Cargo's resolution logic or linking Cargo in as a library, the latter of which would significantly increase build times.

@joshlf
Copy link
Author

joshlf commented Oct 12, 2019

I haven't encountered any of them, but they don't all seem so unlikely as to be not worth worrying about. I think that cargo updateing to a vulnerable version is probably the most likely.

I would say that this is probably worth leaving on the back burner until such a library exists (maybe the Cargo folks would be willing to factor it out into a crate?). Once that happens, it's probably a small enough amount of work that it's worth it. Before that, I agree that the work is probably not worth it. I also agree that linking Cargo as a library isn't worth it.

@tarcieri
Copy link
Member

One way we could potentially consume Cargo.toml is via cargo metadata. The guppy library provides a parser for it which constructs dependency graphs using petgraph (the same library the cargo-lock crate uses for modeling the dependency graph today):

https://github.com/calibra/cargo-guppy

tarcieri added a commit that referenced this issue May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants