supply_chain is a test helper for snapshotting the output of
cargo-supply-chain. It makes changes to the publishers in a Rust project's
dependency graph visible during testing and code review.
Install cargo-supply-chain:
cargo install cargo-supply-chainAdd supply_chain as a development dependency:
cargo add --dev supply_chainAdd a test that specifies where the snapshot should be stored:
#[test]
fn supply_chain() {
supply_chain::check("tests/supply_chain.json");
}Create or update the snapshot by running the test with BLESS set:
BLESS=1 cargo test supply_chainCommit the generated snapshot. Subsequent test runs compare the current report with the committed snapshot:
cargo test supply_chainIf the report changes, inspect the diff. If the change is expected, rerun the test with BLESS=1
and commit the updated snapshot.
For each check, supply_chain:
- Runs
cargo supply-chain update --cache-max-age=0s. - Runs
cargo supply-chain json --no-dev. - Removes all
avatarfields from the JSON report and pretty-prints it. - Compares the report with the stored snapshot, or updates the snapshot when
BLESSis set to a value other than0.
The exit status of the update command is ignored, but the report command must succeed.
This crate provides a reviewable signal when a dependency's supply-chain metadata changes. It does not determine whether a dependency or publisher is trustworthy.
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT License