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

Cargo Resolver V2 (different feature sets for build and runtime dependencies) is not supported #38

Open
Shnatsel opened this issue Jul 29, 2022 · 3 comments
Labels
bug Something isn't working third party Work item for a third-party dependency

Comments

@Shnatsel
Copy link
Member

Shnatsel commented Jul 29, 2022

Cargo has made it possible to depend on the same version of a given crate with different feature sets, provided that one version is a runtime dependency and another is a build dependency.

The dependency resolution in rust-audit was written prior to that change, and it's possible that auditable-serde collates these two packages.

The deduplication is done on the package ID from cargo-metadata, and we'll need to double-check that this is in fact correct even in the presence of the new Cargo feature resolver:

https://github.com/Shnatsel/rust-audit/blob/d7fa6fff1861799adab41638267e0457b7ba4698/auditable-serde/src/lib.rs#L219

@Shnatsel Shnatsel changed the title Double-check dependency resolution against latest Cargo Double-check dependency resolution against latest Cargo (Resolver V2) Aug 8, 2022
@Shnatsel Shnatsel changed the title Double-check dependency resolution against latest Cargo (Resolver V2) Cargo Resolver V2 (different feature sets for dev and runtime dependencies) is not supported Oct 11, 2022
@Shnatsel Shnatsel added the third party Work item for a third-party dependency label Oct 11, 2022
@Shnatsel
Copy link
Member Author

cargo metadata doesn't support Resolver V2: rust-lang/cargo#10718

So unfortunately we're stuck with potentially reporting more dependencies than what actually went into the build if all of the below are true:

  1. The same package is used as both build/runtime and development dependency
  2. The package has more features enabled when used as a development dependency than when used as a runtime dependency
  3. The package's features enabled only when used as a dev dependency pull in additional dependencies not present in the runtime dependency tree

@Shnatsel Shnatsel added the bug Something isn't working label Oct 11, 2022
@Shnatsel Shnatsel changed the title Cargo Resolver V2 (different feature sets for dev and runtime dependencies) is not supported Cargo Resolver V2 (different feature sets for build and runtime dependencies) is not supported Nov 22, 2022
@Shnatsel
Copy link
Member Author

A reproducing test case can be found in this branch: https://github.com/rust-secure-code/cargo-auditable/tree/fix-resolver-v2

rust-lang/rfcs#3553 is required to fix this.

@Shnatsel
Copy link
Member Author

Shnatsel commented Aug 5, 2024

It might be possible to support using the krates crate and using code along these lines:
https://github.com/Shnatsel/krates/blob/9b813f753393dc46053b2852a751f0777918dc57/examples/resolver_v2.rs

Although the status of resolver v2 support in krates is not entirely clear: EmbarkStudios/krates#91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working third party Work item for a third-party dependency
Projects
None yet
Development

No branches or pull requests

1 participant