repo/lockfile-committed/rust
Dependency lockfile is committed
Implements repo/lockfile-committed for rust.
| Severity | error |
| Tiers | 1, 2 |
| Stacks | rust |
| Scope | each |
| Kind | expr |
| Source | library v0.8.0 |
| Selected by | fleetlint-recommended@v0.8.0 |
Requirement
Cargo.lock is tracked when Cargo.toml declares dependencies or a workspace; a workspace member uses the Cargo.lock of the workspace root above it.
Why
Builds are reproducible only when dependency versions are pinned in git.
Check
"Cargo.lock" in tracked() || ["../", "../../", "../../../"].exists(d, file(d + "Cargo.lock") && file(d + "Cargo.toml") && text(d + "Cargo.toml").matches(r'(?m)^\[workspace\]')) || !text("Cargo.toml").matches(r'\[((workspace\.)?(dev-|build-)?dependencies|workspace)\]')Fix
Run cargo generate-lockfile and commit Cargo.lock.
Agent instruction (from repo/lockfile-committed): Run the package manager to produce the lockfile, remove any .gitignore entry for it, and commit it.
A finding that names no file points at Cargo.lock.
Sources
- https://github.com/ossf/package-manager-best-practices/blob/main/published/npm.md (guidance)
- https://fleetlint.org/baseline/#dependencies (convention)
- https://doc.rust-lang.org/cargo/faq.html (spec, Why have Cargo.lock in version control?)
- https://fleetlint.org/stacks/#rust
Generated by fleetlint docs from catalog v0.8.0.