Skip to content

feat: scan the Rust crates of Cargo.lock - #3

Merged
robertodr merged 1 commit into
mainfrom
feat/cargo-lock
Nov 21, 2026
Merged

robertodr merged 1 commit into
mainfrom
feat/cargo-lock

Conversation

@robertodr

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

The dependency scan only read uv.lock, so the crates that a Rust extension compiles into a wheel were never checked. It now reads every tracked Cargo.lock too, with the same rules as for Python.

Changes

  • The scan finds the tracked uv.lock and Cargo.lock files (in the root and in subdirectories). A repository with only one kind scans that kind, and one with neither passes with the notice, whose text now names both.
  • The crates go to OSV (ecosystem crates.io) from the same script, not to cargo-audit: OSV imports the RustSec database and GitHub's advisories for crates.io, so the severity (GitHub's, from the GHSA record), the exceptions, the job summary and the annotations are shared, and the job needs no Rust toolchain and no extra binary.
  • Only crates from crates.io are queried (registry+https://github.com/rust-lang/crates.io-index, or the sparse index form as the source). The packages of the workspace and the crates from git, a path or another registry are left out, so their names never leave the runner. Lock versions 3 and 4 have the same [[package]] tables and both are read.
  • Every crate counts as a runtime dependency: Cargo.lock has no dependency kinds or features, so the dev-dependencies and build-dependencies can't be told apart without cargo. The README and the summary say so ("Needed at": run time).
  • RustSec's informational advisories (unmaintained, unsound, notice) have no GHSA record. They are reported with the kind as the severity (informational: unmaintained) and never block. If GitHub has an advisory for the same issue, GitHub's severity applies. A RustSec vulnerability that GitHub doesn't know still has an unknown severity and blocks, as for Python: RustSec's CVSS is not used.
  • Crate names are compared exactly (cargo tells foo-bar and foo_bar apart), and the fix versions only come from the affected entries of the right ecosystem. Python names are still compared as PEP 503 does.
  • The summary header names the lock kinds that were checked, and each row and error annotation names the lock (rust/Cargo.lock). Yanked crates are not reported: OSV doesn't list them (documented).
  • The workflow comment, the step name and the README (what leaves the repository, which crates are queried, what blocks, exceptions with RUSTSEC- ids, development) cover both lock kinds. The step's run, permissions and checkouts are unchanged.

Validation

  • 54 tests pass (47 with OFFLINE=1, which skips the 7 end-to-end ones): unit tests with a fake OSV for the crates.io filter, lock versions 3 and 4, informational notices, an unknown-severity RustSec vulnerability, a repository with uv.lock and rust/Cargo.lock, a Cargo.lock only, and exceptions by RUSTSEC- and by GHSA id; end-to-end tests with a hand-written Cargo.lock (instant 0.1.12, rsa 0.9.6, pyo3 0.19.0), no cargo needed.
  • ruff (check and format --check), actionlint and zizmor report nothing.
  • Checked the live OSV records: RUSTSEC-2024-0384 (instant, informational), RUSTSEC-2023-0071 (rsa, with GHSA aliases, one finding with the GHSA severity) and RUSTSEC-2025-0020 (pyo3); GHSA records for crates.io have database_specific.severity.
  • Ran the script on a project with a real Cargo.lock (110 crates, generated by cargo 1.99, lock version 4): 7 informational notices, nothing blocking, exit 0. A Cargo.lock with pyo3 0.19.0 blocks with an error annotation on rust/Cargo.lock.

The dependency scan only read uv.lock, so the crates that a Rust
extension compiles into a wheel were never checked. It now reads every
tracked Cargo.lock too, from the same script.

The crates go to OSV, like the Python packages, rather than to
cargo-audit: OSV imports the RustSec database and GitHub's advisories
for crates.io, so the severity (GitHub's), the exceptions, the job
summary and the annotations are shared, and the job needs no Rust
toolchain. Only crates from crates.io are queried, so the names of
crates from git, a path or another registry never leave the runner.

Cargo.lock doesn't record dependency kinds, so every crate counts as a
runtime dependency. RustSec's informational advisories (unmaintained,
unsound, notice) have no GHSA record: they are reported with their kind
as the severity and don't block. A RustSec vulnerability without a
GHSA record still has an unknown severity and blocks. Crate names are
compared exactly, as cargo does.

The summary and the annotations name the lock they come from, a
repository with only one kind of lock scans that kind, and one with
neither still passes with a notice.

Assisted-by: Pi:claude-sonnet-5-5
@robertodr
robertodr merged commit e573542 into main Nov 21, 2026
3 checks passed
@robertodr
robertodr deleted the feat/cargo-lock branch November 21, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant