From 2cc68f57f4a9f5133254994d18070aba3d3ae29c Mon Sep 17 00:00:00 2001 From: piquel Date: Sun, 22 Nov 2026 21:16:32 +0100 Subject: [PATCH] chore(deps): crypto and SQL crates are reachable only through their owners --- deny.toml | 11 +++++++++++ docs/dev/rust-conventions.md | 5 ++++- docs/dev/testing.md | 2 +- just/rust.just | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/deny.toml b/deny.toml index 891b5f13e..ca3beed73 100644 --- a/deny.toml +++ b/deny.toml @@ -33,6 +33,17 @@ wildcards = "deny" # Duplicates come from dependencies' own requirements, which this workspace # can't change; warning about them would only bury real failures. multiple-versions = "allow" +# Each crypto and database primitive has one owner, so a dependency cannot quietly +# add a second one. `wrappers` lists the only crates that may depend on it; any +# other path to it fails. Names are checked against `cargo tree -i`. +deny = [ + { crate = "ring", reason = "aws-lc-rs is the cryptography provider" }, + { crate = "sha2", wrappers = ["sqlx-core", "sqlx-macros-core", "sqlx-postgres"], reason = "digests come from `sourceorigin-crypto`; only SQLx's own SCRAM sign-in uses it" }, + { crate = "rand", wrappers = ["opentelemetry_sdk", "sqlx-postgres", "webauthn-rs-core"], reason = "randomness comes from `sourceorigin-crypto`; only these dependencies draw their own" }, + { crate = "openssl", wrappers = ["auth-service", "webauthn-attestation-ca", "webauthn-authenticator-rs", "webauthn-rs-core"], reason = "only webauthn-rs links it; auth-service names it for its `vendored` feature alone and never calls it" }, + { crate = "aws-lc-rs", wrappers = ["rcgen", "rustls", "rustls-webpki", "sourceorigin-crypto"], reason = "SourceOrigin's cryptography is `sourceorigin-crypto`; the TLS stack, and the test certificates' generator, bring their own" }, + { crate = "sqlx", wrappers = ["sourceorigin-common", "sourceorigin-repository"], reason = "SQL lives in `sourceorigin-repository`; `sourceorigin-common` only decodes identifiers from columns" }, +] # Crates come from crates.io only: never another registry or a Git repository. [sources] diff --git a/docs/dev/rust-conventions.md b/docs/dev/rust-conventions.md index 0bd456d47..f46fedb99 100644 --- a/docs/dev/rust-conventions.md +++ b/docs/dev/rust-conventions.md @@ -72,7 +72,10 @@ The workspace has one cryptographic library, `aws-lc-rs`: the crypto crate builds on it, and it is rustls's provider for every TLS client (reqwest, SQLx and lettre). Don't add another, such as `ring`, `openssl`, `sha2` or `rand`. OpenSSL is in the tree only because webauthn-rs needs it, and auth-service names -it only to build it vendored. `cargo tree -i ring` should print nothing. +it only to build it vendored. `deny.toml` bans these crates and lists the only +dependencies that may bring `sha2`, `rand`, `openssl` and `aws-lc-rs`, and the only +crates that may use `sqlx`; `just audit` fails on any other path to them, and on +`ring` entirely. Hold a secret in a type that zeroizes it when dropped: the crypto crate's `Secret` and `ClientSecret`, `SecretBytes` for configured secrets, `secrecy`'s diff --git a/docs/dev/testing.md b/docs/dev/testing.md index 630ab7c8e..9139326fc 100644 --- a/docs/dev/testing.md +++ b/docs/dev/testing.md @@ -186,7 +186,7 @@ expressions included. | Any command against a scratch cluster | `just db scratch -- psql` | | Browser tests, against a running deployment | `just web test-browser` | | Register the browser tests' clients with auth on `localhost` | `just web browser-client` | -| Dependency audits: cargo-deny's advisories, licenses, `*` requirements and sources other than crates.io, and pnpm's | `just audit` (`just rust audit` / `just web audit`) | +| Dependency audits: cargo-deny's advisories, licenses, `*` requirements, banned crates and sources other than crates.io, and pnpm's | `just audit` (`just rust audit` / `just web audit`) | | Validate the piqueld manifests with piquelctl, and the telemetry configs with the images that run them (needs Docker) | `just infra check` | | Regenerate the query cache, the SDK vectors, the TypeScript SDK's wire types and shared constants, or the generated documentation | `just db prepare` / `just sdk-vectors` / `just sdk-types` / `just docs reference` | | Build the book and check its links | `just docs` | diff --git a/just/rust.just b/just/rust.just index 4c062c4fd..f9855aeb8 100644 --- a/just/rust.just +++ b/just/rust.just @@ -42,7 +42,7 @@ unused: # Advisories, licenses, wildcard requirements and sources other than crates.io, # as deny.toml configures them. Every feature is on, so the audit covers what # the SDKs' features pull in even when no workspace crate enables them. -[doc("Advisories, licenses, wildcards and sources other than crates.io, by cargo-deny.")] +[doc("Advisories, licenses, wildcards, banned crates and sources other than crates.io, by cargo-deny.")] audit: @cargo deny --all-features check