Rulepath is a security-adjacent analyzer, so dependency resolution must be deterministic.
- Commit
Cargo.lockand treat it as security-relevant source. - Direct Rust dependencies in
Cargo.tomlmust use exact version requirements with=. - Registry crate content is pinned by the SHA-256
checksumentries inCargo.lock. - CI must use
cargo ... --lockedfor commands that resolve dependencies. - The Rust toolchain must be pinned in
rust-toolchain.tomlto an exact release, notstable. - GitHub Actions must use full commit SHAs, not tags or branches.
- Git dependencies are discouraged. If one is unavoidable, it must use
rev = "<40-char commit SHA>", never a branch or tag. - Versioned runner labels must be used in CI instead of moving
*-latestlabels.
CI runs bjcorder/deterministic-deps immediately after checkout and pins that action to the full commit SHA 6076e4b0edc592d8f09b8984bf504b8709eb6b4f. The action runs in enforce mode with severity-threshold: medium and remote validation enabled, so mutable GitHub Action refs, missing pinned commits, and Cargo git dependencies fail before normal Rust checks without failing on transient low-severity validation errors.
Rulepath also runs scripts/check-dependency-pinning.ps1 before cargo metadata, formatting, clippy, tests, and builds. This small repo-local contract check covers project-specific requirements that are not fully enforced by the action: exact registry dependency requirements from Cargo metadata, the committed root lockfile, exact rust-toolchain.toml channel, full-SHA workflow uses: entries, and versioned runner labels.
Dependency updates must be explicit PRs.
- Change the direct dependency version in
Cargo.tomlusing an exact=requirement. - Run
cargo update -p <crate> --precise <version>when updating an existing crate. - Run
cargo test --locked --workspace. - Include the
Cargo.lockchecksum changes in the PR. - Explain why the update is needed.
For GitHub Actions, resolve the desired tag to a commit SHA and pin the uses: entry to that SHA. Keep a comment naming the human-readable tag or branch snapshot for maintainability.
Use these commands before merging:
pwsh -NoProfile -ExecutionPolicy Bypass -File ./scripts/check-dependency-pinning.ps1
# On Windows PowerShell:
powershell -NoProfile -ExecutionPolicy Bypass -File ./scripts/check-dependency-pinning.ps1
cargo fmt --all -- --check
cargo clippy --locked --workspace --all-targets
cargo test --locked --workspace
cargo build --locked --workspaceAny command that would modify Cargo.lock during CI should fail.