skip to content

For a payments team's Rust CI, which of cargo-audit, cargo-deny, cargo-nextest, cargo-outdated and cargo-machete should block a merge, and which only report?

level: principalimportance: should knowfreq 25%

answer

  1. caused by this change or by the world
  2. deterministic checks gate, time-varying ones report
  3. advisories arrive overnight
  4. exceptions with owners and reasons
  5. pinned tool versions

basics

~20 s

Block on checks a pull request can cause and fix: tests (nextest plus cargo test --doc), cargo-deny licenses, bans and sources, and machete. Gate advisories on lockfile changes and run them on a schedule; keep cargo-outdated a report.

solid answer

~40 s

I sort checks by whether the result depends only on the change. Tests via `cargo nextest run` plus `cargo test --doc`, and `cargo deny check licenses bans sources`, are deterministic for a given `Cargo.lock` and `deny.toml`, so they block. Advisory checks (`cargo audit`, `cargo deny check advisories`) fetch a database that changes daily, so a new advisory can fail every open pull request regardless of its content. I make them required on pull requests that touch `Cargo.lock` and run them on a daily schedule that alerts an owner, rather than blocking unrelated work. cargo-machete blocks if the team keeps its `ignored` list honest. cargo-outdated exits 0 by default and feeds a planned update routine. Tool versions are pinned with `cargo install --locked --version`, and every ignore or exception carries a reason and an owner.

go deeper

for a junior

Recall what each tool checks: security advisories, license and source policy, tests, unused dependencies and outdated releases, and that each runs as a cargo subcommand.

for a middle

Explain which tools fail by default and which only report, such as cargo outdated exiting 0 and cargo audit warning on unmaintained crates.

for a senior

Show that advisory results change without a code change and design the job: lockfile-triggered gates, a scheduled audit, pinned tools and doctests kept.

for a principal

Own the policy: which signals block, who approves exceptions and with what expiry, and how to keep the gate trusted rather than routinely overridden.

## The decision a lead owns The tools are easy to install; the hard part is deciding **what may stop a merge**. A gate that fails for reasons the author did not cause teaches the team to rerun or override it, and then it protects nothing. A gate that never fails is only a report. For a payments service the stakes are higher on both sides: a vulnerable or badly licensed dependency is a real incident, and a CI pipeline that blocks every pull request whenever an advisory lands stops urgent fixes too. There is no single right policy, but there is a useful test. ## The test: can this pull request cause and fix the result? Sort each check by what its result depends on: | Check | Depends on | Suggested role | |---|---|---| | `cargo nextest run` + `cargo test --doc` | the code | block | | `cargo deny check licenses` | `Cargo.lock`, `deny.toml` | block | | `cargo deny check bans`, `sources` | `Cargo.lock`, `deny.toml` | block | | `cargo audit` / `cargo deny check advisories` | `Cargo.lock` **and a database fetched each run** | block when `Cargo.lock` changes; scheduled run otherwise | | `cargo machete` | `Cargo.toml` and source | block, with a maintained `ignored` list | | `cargo outdated` | the registry today | report only | **Deterministic checks** give the same answer for the same commit. If one fails, the author caused it and can fix it: a new dependency with an unapproved license, a banned crate, a git source outside `allow-git`, a newly unused dependency. These make good blocking gates. **Time-varying checks** read the outside world. cargo-audit fetches the RustSec database before every run, and cargo-deny's advisories check reads the same data, so a lockfile that was clean yesterday fails today. Common answers, each with a cost: 1. **Block on every pull request.** Maximum pressure to patch, but an advisory with no fix available blocks unrelated work until someone writes an ignore. 2. **Block only when `Cargo.lock` changes, plus a daily scheduled audit** that pages or tickets an owner. New dependencies cannot bring a known vulnerability in, and existing ones are tracked without stopping the team. This is my default for a payments service. 3. **Report only.** Cheap, and usually ignored. ## Tuning the defaults to the policy The tools' defaults differ, and the policy should be written down rather than inherited: - cargo-audit fails only on vulnerabilities; unmaintained, unsound and yanked findings are warnings unless `--deny` is passed. - cargo-deny raises non-ignored advisories within their scope as errors and defaults `unmaintained` to scope `"all"`; many teams set `"workspace"` so only crates their own crates choose directly can block. - cargo-deny's `multiple-versions` defaults to `"warn"`; denying duplicates is worthwhile for binary size and type-mismatch confusion but needs a `skip` list. - cargo-outdated exits 0 unless `--exit-code` is set, which is the right default: being behind is a backlog item, not a defect in the change. - cargo-machete exits 1 on findings; it is a text search, so its `ignored` entries need comments, or it turns into noise. Running cargo-deny and cargo-audit together is mostly redundant on advisories; teams commonly keep cargo-deny for the policy checks and choose one advisory runner so a single exception list exists. ## Making exceptions accountable - Every `ignore`, `exceptions`, `skip` and machete `ignored` entry has a **reason**, and ideally an issue link and a review date; cargo-deny accepts `reason` fields and reports ignores that no longer match. - Exceptions change through pull requests, reviewed by whoever owns dependency risk (security for advisories, legal for licenses). - The scheduled advisory job's failures go to a named owner, not to whoever merges next. ## Keeping the gate itself trustworthy - **Pin tool versions.** Install with `cargo install --locked --version X` or pinned prebuilt binaries, so a new release with new checks or defaults arrives as a reviewed change, not a red build. - **Cache** the binaries and the advisory database to keep the job fast. - **Check the graph you ship:** set cargo-deny's `[graph] targets` and features to match the release build. - **Run tests in the same job layout as release builds**, and keep `cargo test --doc`, since nextest skips doctests. - Optional tools such as `cargo msrv verify` (which checks that the declared `rust-version` still builds) or `cargo expand` (which prints macro-expanded code for debugging) are useful locally or on a schedule and rarely belong in the merge gate. ## How to answer State the principle (block on what the change controls; schedule what the world controls), apply it tool by tool, name the costs you accept, and say how exceptions are owned. Different teams land differently: a library maintainer may block every pull request on advisories, while a team with many services may prefer a central scheduled scan.

  • A critical advisory with no patched version lands on a crate the payments service uses; what happens under your policy?
    The scheduled audit alerts the owner, who assesses whether the vulnerable code path is reachable. If it is, the team mitigates by replacing the crate or disabling the feature; if not, they add the ID to the ignore list with a reason and a review date. Merges on unrelated pull requests continue, but any pull request changing `Cargo.lock` still has to pass the advisory check.
  • Why pin the versions of cargo-deny and cargo-audit in CI rather than always installing the latest?
    A new release can add checks or change defaults, as cargo-deny did when it introduced scopes for unsound advisories. Unpinned, that turns into a red build on unrelated work. Pinned with `cargo install --locked --version`, the upgrade is a pull request whose new findings are triaged once.

It is like a building inspection: the inspector fails your extension for wiring you installed, but a new safety recall on a part already in the walls goes to the owner as a notice with a deadline, not as a reason to halt every unrelated renovation.

  • Every supply-chain check should block every pull request, no exceptions
  • Advisory checks are deterministic for a given commit
  • cargo outdated should fail the build whenever anything is behind
  • Ignoring an advisory needs no reason if the build turns green
  • Running cargo audit makes cargo-deny's other checks redundant