From 62d54ce385d887f471b4183c82476b7184c63395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonasz=20Ma=C5=82ecki?= Date: Mon, 30 Nov 2026 09:16:40 +0100 Subject: [PATCH] ci: add cargo-deny dependency gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check advisories, bans, licenses and sources on every pull request, with deny.toml as the policy. The license allowlist is Apache-2.0 plus a subset of the CNCF allowlist license policy; unicode-ident's Unicode-3.0 is a named exception. RUSTSEC-2026-0543 (chrono, via pbjson-types) is ignored with a reason. Signed-off-by: Jonasz MaƂecki --- .github/workflows/ci.yml | 13 +++++++++ AGENTS.md | 1 + CONTRIBUTING.md | 3 +++ deny.toml | 57 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 deny.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ea365d..15479ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,3 +52,16 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - run: cargo run -p codegen - run: git diff --exit-code -- 'sdk/src/generated/*.rs' 'sdk/tests/generated/*.rs' + + # cargo-deny over Cargo.lock, with deny.toml as the policy: an advisory + # against a pinned crate, a license outside the allowlist or a crate from + # an unknown source fails the pull request. + deny: + runs-on: ubuntu-26.04 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + - uses: EmbarkStudios/cargo-deny-action@81891abc19297b21343b15ef67dc61e4aea74fda # v2.1.4 + with: + command: check advisories bans licenses sources diff --git a/AGENTS.md b/AGENTS.md index c1a9b9b..f9857b5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,6 +18,7 @@ Run all of these before you call a change done. CI requires them. cargo fmt --all --check cargo clippy --workspace --tests -- -D warnings cargo test --workspace +cargo deny check advisories bans licenses sources # needs cargo-deny cargo run -p codegen # needs protoc; must leave the generated files unchanged ``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 25fa89a..3d58839 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,6 +27,9 @@ cargo clippy --workspace --tests -- -D warnings # Run tests. cargo test --workspace +# Check advisories, licenses, bans and sources (needs cargo-deny). +cargo deny check advisories bans licenses sources + # Regenerate sdk/src/generated from the vendored proto. cargo run -p codegen ``` diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..7f31fe4 --- /dev/null +++ b/deny.toml @@ -0,0 +1,57 @@ +# cargo-deny: the dependency gate CI runs on every pull request (ci.yml, the +# deny job). An advisory against a crate in Cargo.lock fails the run; the fix +# is a bump, or an entry in `ignore` naming the advisory id with a comment +# saying why it does not apply here. + +[graph] +all-features = true + +[advisories] +version = 2 +db-path = "~/.cargo/advisory-db" +db-urls = ["https://github.com/rustsec/advisory-db"] +# A yanked crate is a warning: Renovate moves the pin, and the advisory, if +# there is one, fails on its own. +yanked = "warn" +# Each entry: { id = "RUSTSEC-YYYY-NNNN", reason = "why it does not apply" }. +ignore = [ + # chrono is unmaintained, with no patched release to move to. Nothing in + # the workspace names it: it comes in through pbjson-types, whose + # Timestamp and Duration are the SDK's well-known types, built without + # default features so chrono's clock and local time zone code isn't + # compiled. Remove the entry once pbjson-types is on a release without + # chrono (influxdata/pbjson#162). + { id = "RUSTSEC-2026-0543", reason = "transitive through pbjson-types, no patched release; the path doesn't compile chrono's clock" }, +] + +[licenses] +version = 2 +# Every license here is Apache-2.0 or on the CNCF allowlist license policy +# (cncf/foundation, policies-guidance/allowed-third-party-license-policy.md), +# a subset of it that the dependency graph uses today. A crate under another +# license fails the run until it is added deliberately. +allow = [ + "Apache-2.0", + "BSD-3-Clause", + "ISC", + "MIT", + "Zlib", +] +# Unicode-3.0 is not on the CNCF allowlist. unicode-ident (license +# "(MIT OR Apache-2.0) AND Unicode-3.0") carries it for its identifier +# tables; the crate is only a build-time dependency of proc-macro2, so +# nothing under it ships in a binary. Needs a CNCF license exception; the +# same request is open for wasmCloud (cncf/foundation#1581). +exceptions = [ + { crate = "unicode-ident", allow = ["Unicode-3.0"] }, +] +confidence-threshold = 0.8 + +[bans] +multiple-versions = "warn" +wildcards = "allow" + +[sources] +unknown-registry = "deny" +unknown-git = "deny" +allow-registry = ["https://github.com/rust-lang/crates.io-index"]