mozilla / cargo-vet

supply-chain security for Rust
Apache License 2.0
654 stars 44 forks source link

Add --cargo-arg option for arguments to pass through to cargo #581

Closed danakj closed 10 months ago

danakj commented 10 months ago

Some projects may require additional arguments in the cargo metadata command in order to parse their Cargo.toml. For example Chromium requires -Zbindeps as it uses the feature for a dependency on cxxbridge-cmd. This allows such projects to use cargo vet --cargo-arg=<STUFF> in order to add one or more arguments to the cargo metadata command line.

danakj commented 10 months ago

Not sure if there's an expectation for tests here, but locally I did the following:

% cargo run -- vet --cargo-arg=-Zbindeps --verbose info
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/cargo-vet vet --cargo-arg=-Zbindeps --verbose info`
 INFO Running: Command {
    program: "/home/danakj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo",
    args: [
        "/home/danakj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo",
        "metadata",
        "--format-version",
        "1",
        "--all-features",
        "--locked",
        "--color=always",
        "-Zbindeps",            <---------------- added here
    ],
    create_pidfd: false,
}
 INFO Final Metadata Config: 
...
bholley commented 10 months ago

Thanks for the patch! @mystor can you review?

danakj commented 10 months ago

Oh I see there are tests for the help markdown, I will update those.

mystor commented 10 months ago

While it'd be nice to have tests for this, it's a fairly niche feature, and is useful for something somewhat niche, so I think we can get away without functionality tests for this change.

danakj commented 10 months ago

Thanks for the quick review!