rust-secure-code / cargo-supply-chain

Gather author, contributor and publisher data on crates in your dependency graph.
Apache License 2.0
315 stars 18 forks source link

Fixed bug with supply_args filtering for cargo arg #34

Closed Owez closed 3 years ago

Owez commented 3 years ago

Before this commit I was getting the following error:

    Finished dev [unoptimized + debuginfo] target(s) in 1m 07s
     Running `target/debug/cargo-supply-chain`
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', src/main.rs:80:8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Context is this statement:

// When invoked via `cargo supply-chain update`, Cargo passes the arguments it receives verbatim.
// So instead of "update" our binary receives "supply-chain update".
// We ignore the "supply-chain" in the beginning if it's present.
if supply_args[0] == "supply-chain" {
    supply_args.remove(0);
}

After a simple cargo run of this crate. I fixed the bounds error which may have been caused by pico-args not always returning the first argument as the caller

Shnatsel commented 3 years ago

Ah, my bad. Thanks for catching this!