Skip to content

Commit d5c439c

Browse files
committed
fix(skills): audit every Rust dependency change
1 parent 0b5996c commit d5c439c

2 files changed

Lines changed: 48 additions & 42 deletions

File tree

  • .agents/skills
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: secure-rust-dependency-changes
3+
description: Use whenever a Rust dependency is added or updated, including direct, transitive, build, development, target-specific, and optional dependencies.
4+
---
5+
6+
# Secure Rust Dependency Changes
7+
8+
## Preconditions
9+
10+
1. Resolve the repository root, requested base, worktree, branch, and dependency change. Classify it as an addition or an update. Inspect repository instructions, release/versioning rules, and contribution guidance before changing files.
11+
2. Require a clean target worktree unless the user explicitly authorizes mixing changes. If a fresh worktree was requested, fetch the base and create it first.
12+
3. Locate every relevant manifest and lockfile entry. For updates, use `cargo tree -i <crate>@<version>` to identify direct and transitive users, exact pins, upper bounds, and active features.
13+
14+
## Security audit — every addition and update
15+
16+
4. Audit before accepting the dependency change. Keep the real manifest and lockfile unchanged during the audit when practical.
17+
5. For every crate release that the change newly selects:
18+
- Check registry owners, publisher identity and history, yanked status, repository, license, maintenance activity, and MSRV. For updates, compare these with the locked release and inspect intermediate releases when versions are skipped.
19+
- Download the published archive and verify its SHA-256 value against registry metadata. For updates, verify the locked archive against the lockfile checksum too.
20+
- Match `.cargo_vcs_info.json` to the declared upstream commit or tag and compare packaged source with that revision. Record missing, lightweight, or unsigned tags and sole-owner packages as residual risks.
21+
- Inspect `Cargo.toml.orig`, dependencies, default and optional features, target-specific dependencies, build dependencies, and crate target types.
22+
- Inspect `build.rs`, proc macros, binaries, executable files, symlinks, unsafe code, process spawning, network/download behavior, generated-code paths, and opaque payloads.
23+
6. Resolve the proposed change in a temporary snapshot and enumerate the complete lockfile package/version delta. Audit every newly introduced or upgraded transitive package to the same standard; packages already present at the same version do not need a new audit.
24+
7. Never treat unchanged ownership or a matching checksum as sufficient by itself. Hold the change when provenance is inconsistent, source cannot be reconciled, executable behavior is unexplained, maintenance or licensing is unacceptable, or the transitive audit is incomplete.
25+
26+
## Update validation — updates only
27+
28+
8. Review changelogs and source diffs for API, validation, protocol, resource-limit, error-handling, feature-default, and compatibility changes that can affect the repository.
29+
9. Simulate manifest edits in the temporary snapshot. Resolve with targeted `cargo update -p <crate>@<old> --precise <new>` commands and confirm the full lockfile delta is understood.
30+
10. For transitive candidates, run an exact dry-run update. If an upstream dependency imposes an exact pin or upper bound, mark the update blocked and name the constraining package. Do not patch crates or broaden into unrelated upstream upgrades without explicit approval.
31+
11. Produce an approve/hold decision for each requested update before modifying the real worktree. Include material behavior changes, required feature changes, resolution blockers, and residual provenance risks.
32+
33+
A newly added dependency does not need a separate functional-validation phase in this skill. Its API fit and behavior are validated by implementing and testing the feature that requires it. The security audit remains mandatory.
34+
35+
## Implement
36+
37+
12. For additions, add the audited version with only the features the feature implementation needs. For updates, apply only versions that passed both the security audit and update validation.
38+
13. Preserve required behavior explicitly when defaults or optional features change; do not accept a silent validation or protocol regression.
39+
14. Update the lockfile with the narrowest targeted Cargo command. Reject unrelated compatible upgrades introduced by an unscoped `cargo update` unless they were separately audited and requested.
40+
15. Apply the repository's required release/version bump.
41+
42+
## Verify and report
43+
44+
16. Inspect the final manifest and lockfile diff, run `git diff --check`, and confirm that the changed package set matches the audited temporary resolution.
45+
17. For updates, use `cargo tree -e features` for behavior-critical feature changes and run the smallest useful compatibility checks. For additions, rely on the feature's normal build and test work rather than creating redundant dependency-only validation.
46+
18. Run `cargo audit` when available. Separate pre-existing or explicitly allowed warnings from findings introduced by the change; do not silently expand scope to fix unrelated advisories.
47+
19. Report added and updated crates, blocked updates with exact constraints, transitive changes, audit decisions, residual provenance risks, version bump, and the feature or update checks that were run.
48+
20. If publishing was requested, commit and push the cohesive change, then open or update a pull request. Keep the description reviewer-focused: summarize dependency scope, behavior impact, provenance conclusion, explicit feature decisions, and intentionally blocked pins. Read the pull request back to verify its title and body.

.agents/skills/secure-rust-dependency-updates/SKILL.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)