@m4ss/pi-skills 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +17 -2
- package/package.json +40 -3
- package/skills/commit/SKILL.md +383 -0
- package/skills/repo-maintenance/SKILL.md +251 -0
- package/skills/repo-maintenance/references/changelogs.md +164 -0
- package/skills/repo-maintenance/references/ci-audit.md +329 -0
- package/skills/repo-maintenance/references/containers.md +287 -0
- package/skills/repo-maintenance/references/forgejo.md +162 -0
- package/skills/repo-maintenance/references/node.md +376 -0
- package/skills/repo-maintenance/references/rust.md +567 -0
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
# Rust dependencies
|
|
2
|
+
|
|
3
|
+
Follow these steps in order. If `Cargo.lock` is not tracked in git, skip the
|
|
4
|
+
compatible-upgrade commit and run the remaining steps.
|
|
5
|
+
|
|
6
|
+
Create commits in this order (omit any step that has no changes). An MSRV bump
|
|
7
|
+
approved in Step 7 (not Step 4) goes right before the upgrade that needed it.
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
build(deps): check the targets CI builds in cargo-deny (Step 1, [graph])
|
|
11
|
+
build(deps): allow the <license> license (the baseline already needs it)
|
|
12
|
+
build!: bump MSRV to v1.NN (build: for binary-only and unpublished crates)
|
|
13
|
+
style(clippy): fix warnings enabled by the MSRV bump
|
|
14
|
+
refactor: ... (code that was waiting on the new MSRV)
|
|
15
|
+
build(deps): upgrade semver compatible Rust dependencies
|
|
16
|
+
build(deps): upgrade <crate> to v<version> (a security fix younger than a day)
|
|
17
|
+
build(deps): ignore RUSTSEC-YYYY-NNNN
|
|
18
|
+
build(deps): upgrade <crate> to v<major> (one per upgrade or group)
|
|
19
|
+
build(deps): ... (standing holds that became obsolete)
|
|
20
|
+
chore(ci): upgrade Rust to v1.NN.P
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 1. Take a baseline
|
|
24
|
+
|
|
25
|
+
Inspect the repository configuration:
|
|
26
|
+
|
|
27
|
+
- **MSRV**: `rust-version` in `[workspace.package]` or each `[package]` (if
|
|
28
|
+
set).
|
|
29
|
+
- **Advisory tool**: Use `cargo-deny` if `deny.toml` exists, otherwise
|
|
30
|
+
`cargo-audit`. Install if missing (`cargo install --locked cargo-deny` or
|
|
31
|
+
`cargo-audit`). Put advisory ignores only in `deny.toml`; never create or
|
|
32
|
+
edit `.cargo/audit.toml`.
|
|
33
|
+
- **Target graph (`deny.toml` `[graph]`)**:
|
|
34
|
+
- First verify `deny.toml` `[graph] targets` matches what CI builds
|
|
35
|
+
(`references/ci-audit.md`, "What the jobs run"). If it mismatches, fix
|
|
36
|
+
`deny.toml` in its own commit before recording the baseline
|
|
37
|
+
(`build(deps): check the targets CI builds in cargo-deny`).
|
|
38
|
+
- Translate `[graph]` into `<graph>` flags for `cargo tree` so it inspects
|
|
39
|
+
the exact graph `cargo-deny` checks:
|
|
40
|
+
|
|
41
|
+
| `deny.toml` `[graph]` setting | `<graph>` flags for `cargo tree` |
|
|
42
|
+
| ----------------------------- | ------------------------------------------ |
|
|
43
|
+
| `targets = [...]` | `--target <triple>` for each listed triple |
|
|
44
|
+
| No `targets` key | `--target all` |
|
|
45
|
+
| `exclude-dev = true` | `-e normal,build` |
|
|
46
|
+
|
|
47
|
+
- **CI commands**: Note the clippy, test and MSRV job commands, their feature
|
|
48
|
+
flags, whether CI pins the Rust toolchain and runs clippy on that pin
|
|
49
|
+
(`references/ci-audit.md`, "Toolchains"), and `cargo-deny-action`'s
|
|
50
|
+
`arguments` (`--all-features` in our repositories). Always pass `--workspace`
|
|
51
|
+
to `cargo tree` and `cargo deny` (a root manifest with its own `[package]`
|
|
52
|
+
otherwise checks only the root package; report if CI's `cargo-deny`
|
|
53
|
+
arguments omit `--workspace` in such a repo).
|
|
54
|
+
- **Published crates**: Check which workspace crates are published to
|
|
55
|
+
crates.io and whether unpublished ones set `publish = false`
|
|
56
|
+
(`references/ci-audit.md`, "Publishing"). Report any unpublished crate
|
|
57
|
+
missing `publish = false`.
|
|
58
|
+
|
|
59
|
+
If `Cargo.lock` is not tracked in git (`git ls-files Cargo.lock` prints
|
|
60
|
+
nothing), copy it to `<scratch>/Cargo.lock.before` before running any `cargo`
|
|
61
|
+
command, or note that it does not exist yet. Step 4 restores it from there.
|
|
62
|
+
|
|
63
|
+
Record the baseline advisories, licenses and duplicate versions (substitute
|
|
64
|
+
the `<graph>` flags from the table above when writing `dups.sh`):
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
cargo deny --workspace --all-features check advisories > <scratch>/advisories-before.txt 2>&1 # or: cargo audit
|
|
68
|
+
cargo deny --workspace --all-features check licenses > <scratch>/licenses-before.txt 2>&1 # only if deny.toml exists
|
|
69
|
+
cat > <scratch>/dups.sh <<'EOF'
|
|
70
|
+
cargo tree -q -d --workspace <graph> --all-features --depth 0 --prefix none | sort -u \
|
|
71
|
+
| awk 'NF { v[$1] = v[$1] " " $2; n[$1]++ } END { for (k in n) if (n[k] > 1) print k v[k] }' \
|
|
72
|
+
| sort
|
|
73
|
+
EOF
|
|
74
|
+
sh <scratch>/dups.sh > <scratch>/dups-before.txt
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Malicious crates:** Check the baseline for malicious crates (every advisory
|
|
78
|
+
with `categories = ["malicious"]` has one of these phrases in its title):
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
grep -i -n -E 'removed from crates.io|malicious crate' <scratch>/advisories-before.txt
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
If it prints anything, stop now, before any `cargo check`, `build` or `test`
|
|
85
|
+
(build scripts and proc-macros execute during them), and report to the user.
|
|
86
|
+
|
|
87
|
+
If the licenses check already fails, a locked dependency uses a license that
|
|
88
|
+
`deny.toml` does not allow. Stop and ask whether to allow it. If the user
|
|
89
|
+
agrees, add it to `[licenses] allow` as the first commit,
|
|
90
|
+
`build(deps): allow the <license> license`.
|
|
91
|
+
|
|
92
|
+
## 2. Upgrade within the declared ranges (working tree only)
|
|
93
|
+
|
|
94
|
+
Do **not** stage or commit `Cargo.lock` until Step 5.
|
|
95
|
+
|
|
96
|
+
**Release cooldown:** Never lock a version published less than a day ago,
|
|
97
|
+
unless it is a security fix (`SKILL.md`, "Security fixes and the release-age
|
|
98
|
+
gate"; Step 6), with or without an advisory. Cargo enforces this
|
|
99
|
+
with `CARGO_REGISTRY_GLOBAL_MIN_PUBLISH_AGE="1 day"`. Prefix **every** `cargo`
|
|
100
|
+
command that can change `Cargo.lock` with it: `update`, and after manifest
|
|
101
|
+
edits `fetch`, `check`, `build`, `clippy`, `test` and `tree`. Once a prefixed
|
|
102
|
+
`update` or `fetch` has run after the last manifest edit, the lock is
|
|
103
|
+
resolved and later commands cannot change it, so `dups.sh` and the
|
|
104
|
+
`cargo tree` calls in this file need no prefix. Never write
|
|
105
|
+
`global-min-publish-age` into `.cargo/config.toml`.
|
|
106
|
+
|
|
107
|
+
1. Check that the cooldown is active and whether the resolver respects the
|
|
108
|
+
MSRV:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
cargo --version
|
|
112
|
+
CARGO_REGISTRY_GLOBAL_MIN_PUBLISH_AGE="1 day" cargo update --dry-run 2>&1 | grep -E 'Locking|min-publish-age'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`cargo --version` reports the toolchain `rust-toolchain.toml` selects, if
|
|
116
|
+
the repository has one.
|
|
117
|
+
|
|
118
|
+
- **Cooldown:** The `Locking` line must end with `as of 24 hours ago`. If
|
|
119
|
+
it does not (with or without a warning that Cargo is ignoring
|
|
120
|
+
`registry.global-min-publish-age`), this Cargo is older than 1.100 and
|
|
121
|
+
resolves without the cooldown. Run every command listed above
|
|
122
|
+
with `cargo +stable` instead (install it with
|
|
123
|
+
`rustup toolchain install stable --profile minimal` if needed) and check
|
|
124
|
+
again.
|
|
125
|
+
- **MSRV:** If the `Locking` line says `highest Rust 1.NN compatible` (older
|
|
126
|
+
Cargo says `latest Rust 1.NN compatible`), the MSRV is respected. If it
|
|
127
|
+
says only `highest compatible` while `rust-version` is set, the resolver
|
|
128
|
+
ignores the MSRV: also prefix every command listed above with
|
|
129
|
+
`CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback`, and note in the final
|
|
130
|
+
report that setting `resolver = "3"` makes this automatic once the MSRV is
|
|
131
|
+
`>= 1.84`.
|
|
132
|
+
|
|
133
|
+
The cooldown prefix, the `+stable` toolchain and the MSRV prefix from this
|
|
134
|
+
step are called the **Step 2 environment** below. The commands in this
|
|
135
|
+
file show only the cooldown prefix. If this step added the others, add
|
|
136
|
+
them to every command that shows the cooldown prefix, for example:
|
|
137
|
+
`CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback CARGO_REGISTRY_GLOBAL_MIN_PUBLISH_AGE="1 day" cargo +stable update`.
|
|
138
|
+
|
|
139
|
+
2. Update `Cargo.lock`:
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
CARGO_REGISTRY_GLOBAL_MIN_PUBLISH_AGE="1 day" cargo update
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
If the output has a `Downgrading` line, the committed lockfile held a
|
|
146
|
+
version the Step 2 environment rejects: usually one younger than a day,
|
|
147
|
+
but possibly one above the MSRV or a yanked one. Find out which from the
|
|
148
|
+
line's suffix (`published ... ago`, `requires Rust 1.NN`) or
|
|
149
|
+
`cargo info <crate>@<version>`, and report it.
|
|
150
|
+
|
|
151
|
+
If git dependencies (`git = "..."` or `[patch]`) moved to a newer commit,
|
|
152
|
+
review `git log <old>..<new>` in their repositories like a release diff.
|
|
153
|
+
|
|
154
|
+
## 3. Read what's left
|
|
155
|
+
|
|
156
|
+
List what Step 2 could not update:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
CARGO_REGISTRY_GLOBAL_MIN_PUBLISH_AGE="1 day" cargo update --dry-run --verbose 2>&1 | grep -E 'Unchanged|requires Rust'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
In Cargo semver, versions are compatible when their leftmost non-zero
|
|
163
|
+
components match: `1.2 -> 1.9` and `0.3.1 -> 0.3.9` are compatible;
|
|
164
|
+
`1.9 -> 2.0`, `0.3 -> 0.4` and `0.0.3 -> 0.0.4` are major upgrades.
|
|
165
|
+
|
|
166
|
+
Classify each output line:
|
|
167
|
+
|
|
168
|
+
- `Unchanged zstd-sys v2.1.2 (available: v2.1.3, published 40 minutes ago)`:
|
|
169
|
+
Compatible release held back by the release cooldown. Read its changelog or
|
|
170
|
+
release notes. If it fixes an applicable advisory, or the changelog mentions
|
|
171
|
+
a security fix (even with no advisory yet), handle it in Step 6. Otherwise
|
|
172
|
+
leave it, and list it in the report.
|
|
173
|
+
- `Unchanged ctutils v0.4.2 (available: v0.4.8, requires Rust 1.87)`, where
|
|
174
|
+
`available` is compatible by the rule above:
|
|
175
|
+
Compatible release held back by the MSRV (reported for both direct and
|
|
176
|
+
transitive dependencies). Handle in Step 4. If `available` is a major
|
|
177
|
+
upgrade, use the next bullet instead. A line with both suffixes
|
|
178
|
+
(`available: v4.6.8, requires Rust 1.85, published 16 hours ago`) is also
|
|
179
|
+
held back by the MSRV.
|
|
180
|
+
- `Unchanged criterion v0.7.0 (available: v0.8.2)`, where `available` is a
|
|
181
|
+
major upgrade by the rule above:
|
|
182
|
+
Incompatible (major) upgrade for a direct dependency. A `requires Rust`
|
|
183
|
+
suffix means it also needs an MSRV bump. Cargo only displays a major version
|
|
184
|
+
that fits the current MSRV when one exists, which can hide an even newer
|
|
185
|
+
major that requires a higher Rust version. For each direct dependency listed,
|
|
186
|
+
check the newest release and its `rust-version`:
|
|
187
|
+
`cargo search <crate> --limit 1` and `cargo info <crate>@<version>`.
|
|
188
|
+
- `Unchanged foo v1.2.3 (available: v1.2.9)`, where `available` is compatible
|
|
189
|
+
by the rule above (no `requires Rust`):
|
|
190
|
+
Compatible release blocked by an `=`, `<` or `~` requirement or a `[patch]`.
|
|
191
|
+
List every requirement on the crate:
|
|
192
|
+
|
|
193
|
+
```sh
|
|
194
|
+
cargo metadata --format-version 1 --locked \
|
|
195
|
+
| jq -r '.packages[] | . as $p | .dependencies[] | select(.name == "foo")
|
|
196
|
+
| [$p.name, $p.version, .req] | @tsv' | sort -u
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The row whose requirement excludes the available version is the pin (e.g.
|
|
200
|
+
`diesel-async 0.9.2 ~2.3.9` for `diesel`, `axum 0.8.9 =0.8.4` for
|
|
201
|
+
`matchit`). If no row explains it, check `[patch]` in the root `Cargo.toml`.
|
|
202
|
+
- In one of our `Cargo.toml` files or a `[patch]`: handle it in Step 9.
|
|
203
|
+
- In another crate's manifest: change nothing, and list the crate, the pin
|
|
204
|
+
and who sets it in the report.
|
|
205
|
+
|
|
206
|
+
- `Unchanged graviola v0.4.4 (requires Rust 1.89)` (no `available:`; Step 2's
|
|
207
|
+
own output showed it as `Updating` or `Adding ... (requires Rust 1.89)`):
|
|
208
|
+
No version in range supports the MSRV, so Cargo fell back to an incompatible
|
|
209
|
+
one. First check that the crate is in the graph CI builds:
|
|
210
|
+
`cargo tree -q -i graviola@0.4.4 --workspace <graph> --all-features`.
|
|
211
|
+
- If it prints nothing, the crate is not in the graph CI checks (it is
|
|
212
|
+
only used on other targets, or only as a dev-dependency when
|
|
213
|
+
`exclude-dev` is set): ignore it.
|
|
214
|
+
- If `<graph>` is `--target all` (no `targets` in `deny.toml`), run it once
|
|
215
|
+
more without `--target all`, which checks the host target only. If only
|
|
216
|
+
the `--target all` run prints a tree, list the crate in the report as
|
|
217
|
+
"needs Rust 1.NN on other targets only" and leave it out of Step 4.
|
|
218
|
+
- Otherwise the current MSRV is already broken for features enabling this
|
|
219
|
+
crate: report it and include it in Step 4.
|
|
220
|
+
|
|
221
|
+
List where direct dependencies are declared:
|
|
222
|
+
|
|
223
|
+
```sh
|
|
224
|
+
cargo metadata --format-version 1 --no-deps \
|
|
225
|
+
| jq -r '.packages[] as $p | $p.dependencies[] | select(.path == null)
|
|
226
|
+
| [$p.name, .name, .req, (.kind // "normal")] | @tsv' | sort -u
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
If a member sets `foo.workspace = true`, edit its requirement in the root
|
|
230
|
+
`Cargo.toml` under `[workspace.dependencies]`.
|
|
231
|
+
|
|
232
|
+
Re-check advisories and diff the IDs against the baseline:
|
|
233
|
+
|
|
234
|
+
```sh
|
|
235
|
+
cargo deny --workspace --all-features check advisories > <scratch>/advisories-after.txt 2>&1 # or: cargo audit
|
|
236
|
+
diff <(grep -oE 'RUSTSEC-[0-9]{4}-[0-9]{4}' <scratch>/advisories-before.txt | sort -u) \
|
|
237
|
+
<(grep -oE 'RUSTSEC-[0-9]{4}-[0-9]{4}' <scratch>/advisories-after.txt | sort -u)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Check for malicious crates again, and stop now as in Step 1 if this prints
|
|
241
|
+
anything:
|
|
242
|
+
|
|
243
|
+
```sh
|
|
244
|
+
grep -i -n -E 'removed from crates.io|malicious crate' <scratch>/advisories-after.txt
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Compare yanked-crate warnings by crate name. Mention advisories and yanked
|
|
248
|
+
versions resolved by `cargo update` in Step 5's commit body. Include remaining
|
|
249
|
+
advisories whose fix requires a newer Rust in Step 4's question; handle all
|
|
250
|
+
others in Step 6.
|
|
251
|
+
|
|
252
|
+
## 4. Settle the MSRV
|
|
253
|
+
|
|
254
|
+
- **If nothing in Step 3 requires a newer Rust:** Proceed directly to Step 5.
|
|
255
|
+
- **If any compatible update, advisory fix or major upgrade requires a newer
|
|
256
|
+
Rust:** Stop and ask the user whether to bump the MSRV. Include all decision
|
|
257
|
+
details in a single message:
|
|
258
|
+
- Current MSRV and latest stable Rust:
|
|
259
|
+
`curl -sSf https://static.rust-lang.org/dist/channel-rust-stable.toml | awk '/^\[pkg\.rust\]/{getline; print}'`
|
|
260
|
+
- Each held-back crate: locked version, available version, required Rust
|
|
261
|
+
version, whether direct or via which dependency, and relevant fixes
|
|
262
|
+
(advisories first, then relevant changelog fixes).
|
|
263
|
+
- Major upgrades that require a newer Rust.
|
|
264
|
+
- The lowest MSRV that unlocks the needed updates, and what a smaller bump
|
|
265
|
+
would leave behind.
|
|
266
|
+
|
|
267
|
+
Example prompt:
|
|
268
|
+
|
|
269
|
+
```text
|
|
270
|
+
The MSRV (1.85) holds back:
|
|
271
|
+
|
|
272
|
+
ctutils 0.4.2 → 0.4.8, needs 1.87, via digest (sha2, hmac, md-5):
|
|
273
|
+
fixes RUSTSEC-2026-0385, which affects our signing
|
|
274
|
+
graviola 0.4.4 already needs 1.89: the graviola backend doesn't build on 1.85
|
|
275
|
+
criterion 0.7 → 0.8 (dev-dependency), needs 1.86
|
|
276
|
+
|
|
277
|
+
1.89 covers all three; the latest stable is 1.100.0. Bump the MSRV to 1.89?
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
- **If the user declines (or in a non-interactive run):** Proceed to Step 5
|
|
281
|
+
and list the held-back crates in the report.
|
|
282
|
+
|
|
283
|
+
### If the user approves the MSRV bump
|
|
284
|
+
|
|
285
|
+
1. **Revert `Cargo.lock` first** so the MSRV commit builds against the original
|
|
286
|
+
lockfile:
|
|
287
|
+
|
|
288
|
+
```sh
|
|
289
|
+
git restore Cargo.lock
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
If `Cargo.lock` is not tracked, `git restore` fails. Copy
|
|
293
|
+
`<scratch>/Cargo.lock.before` (Step 1) back to `Cargo.lock` instead, or
|
|
294
|
+
delete `Cargo.lock` if it did not exist at the start.
|
|
295
|
+
|
|
296
|
+
2. Find every reference to the old MSRV in tracked files:
|
|
297
|
+
|
|
298
|
+
```sh
|
|
299
|
+
git grep -n -E 'rust-version|msrv|MSRV'
|
|
300
|
+
git grep -n -F '1.OLD' # inspect each match
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
3. Update the MSRV in:
|
|
304
|
+
- `rust-version` in every `Cargo.toml` that sets it;
|
|
305
|
+
- CI MSRV jobs in `.github/workflows/` and `.forgejo/workflows/` (toolchain
|
|
306
|
+
flags like `rustup default 1.NN` or `toolchain: 1.NN.0`, job names like
|
|
307
|
+
`msrv / 1.NN.0`, matrix entries, and cache keys);
|
|
308
|
+
- `msrv` in `clippy.toml` (if present);
|
|
309
|
+
- `channel` in `rust-toolchain.toml`, if it pins the MSRV rather than a
|
|
310
|
+
newer toolchain;
|
|
311
|
+
- documentation and README badges, e.g.
|
|
312
|
+
`[](https://blog.rust-lang.org/YYYY/MM/DD/Rust-1.NN.0/)`
|
|
313
|
+
(get the release date from `rust-lang/rust`'s `RELEASES.md` and verify the
|
|
314
|
+
URL resolves).
|
|
315
|
+
4. Commit as `build!: bump MSRV to v1.NN` for a library crate published to
|
|
316
|
+
crates.io, or `build: bump MSRV to v1.NN` for binary-only and unpublished
|
|
317
|
+
crates (`references/ci-audit.md`, "What the jobs run"). State
|
|
318
|
+
what required the bump and, for a library crate, end with what breaks:
|
|
319
|
+
|
|
320
|
+
```text
|
|
321
|
+
build!: bump MSRV to v1.89
|
|
322
|
+
|
|
323
|
+
The graviola backend requires Rust 1.89, so the declared MSRV only held
|
|
324
|
+
for the other backends. The versions of ctutils, a dependency of digest,
|
|
325
|
+
that fix RUSTSEC-2026-0385 also require Rust 1.87, so the MSRV-aware
|
|
326
|
+
resolver kept a vulnerable version locked.
|
|
327
|
+
|
|
328
|
+
This breaks builds with Rust 1.85 to 1.88, which have to upgrade.
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
5. **Fix newly enabled clippy lints:** Run CI's clippy commands with CI's
|
|
332
|
+
pinned toolchain (`cargo +1.NN.P clippy ...`). Commit any fixes as
|
|
333
|
+
`style(clippy): fix warnings enabled by the MSRV bump`, naming each lint and
|
|
334
|
+
fix in the body.
|
|
335
|
+
6. **Clean up MSRV-gated code:** Check for `FIXME` comments waiting on the new
|
|
336
|
+
MSRV, polyfills, `rustversion`/`autocfg` checks, or always-true `cfg`s.
|
|
337
|
+
Commit small removals as `refactor: ...`; note larger refactors or newly
|
|
338
|
+
available Rust editions (Edition 2024 requires 1.85) in the report without
|
|
339
|
+
migrating unasked.
|
|
340
|
+
7. **Re-run `cargo update`** (with the Step 2 environment) to lock the newly
|
|
341
|
+
unlocked versions, and re-run Step 3's dry-run to confirm nothing unexpected
|
|
342
|
+
remains held back.
|
|
343
|
+
|
|
344
|
+
## 5. Commit the compatible upgrade
|
|
345
|
+
|
|
346
|
+
1. Run CI's check suite with `--locked`.
|
|
347
|
+
- If CI has an MSRV job, run its commands with the MSRV toolchain
|
|
348
|
+
(`rustup toolchain install 1.NN --profile minimal`) to catch crates that
|
|
349
|
+
understate `rust-version`.
|
|
350
|
+
- If a library crate published to crates.io (Step 1, "Published crates") sets
|
|
351
|
+
`rust-version` but CI has no MSRV job, run
|
|
352
|
+
`cargo +1.NN check --locked --workspace --all-features` with the MSRV
|
|
353
|
+
toolchain anyway, and list the missing MSRV job in the report. Do not add
|
|
354
|
+
the job unless the user asked for a CI audit (`references/ci-audit.md`,
|
|
355
|
+
"What the jobs run"). Binary-only and unpublished crates do not need an
|
|
356
|
+
MSRV job.
|
|
357
|
+
- If `deny.toml` exists, run `cargo deny --workspace --all-features check`
|
|
358
|
+
(checks licenses, bans and advisories), and stop and ask if a new
|
|
359
|
+
dependency introduces an unallowed license. Otherwise run `cargo audit`.
|
|
360
|
+
2. Handle check failures:
|
|
361
|
+
- **Fails only on the MSRV toolchain:** A crate understated its
|
|
362
|
+
`rust-version`. Identify it from the compiler error, downgrade it with
|
|
363
|
+
`cargo update -p <crate> --precise <last-working-version>`, check its
|
|
364
|
+
upstream issue tracker, and report it.
|
|
365
|
+
- **Fails on stable/pinned toolchain:** A compatible release regressed.
|
|
366
|
+
Identify the crate from `git diff <base> -- Cargo.lock` (bisecting with
|
|
367
|
+
`--precise` if needed), hold it back at the last working version, check
|
|
368
|
+
its upstream issue tracker, and report it.
|
|
369
|
+
- Note in the report that `--precise` holds only last until the next
|
|
370
|
+
`cargo update` unless pinned in `Cargo.toml`.
|
|
371
|
+
- Include minor code adjustments required by the compatible update (such as
|
|
372
|
+
fixing a new deprecation warning under `-D warnings`) in this commit.
|
|
373
|
+
- Remove any `deny.toml` advisory `ignore` entries that `cargo-deny` reports
|
|
374
|
+
as no longer matching.
|
|
375
|
+
3. Commit `Cargo.lock` (and any accompanying fix or obsolete `deny.toml`
|
|
376
|
+
ignore removal) as:
|
|
377
|
+
`build(deps): upgrade semver compatible Rust dependencies`.
|
|
378
|
+
Include a commit body only when there are fixed advisories (naming the
|
|
379
|
+
affected crates and what uses them), replaced yanked versions, `--precise`
|
|
380
|
+
holds, or removed `deny.toml` ignores:
|
|
381
|
+
|
|
382
|
+
```text
|
|
383
|
+
build(deps): upgrade semver compatible Rust dependencies
|
|
384
|
+
|
|
385
|
+
The locked version of ctutils, which the hmac, sha2 and md-5 crates use
|
|
386
|
+
through digest, had non-constant-time mask generation and u128
|
|
387
|
+
comparisons (RUSTSEC-2026-0385). The locked versions of h2, rustls and
|
|
388
|
+
quinn-proto, dependencies of reqwest which only the tests and examples
|
|
389
|
+
use, had 10 security advisories published since the last upgrade, and
|
|
390
|
+
the locked version of chacha20 had been yanked.
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## 6. Remaining advisories
|
|
394
|
+
|
|
395
|
+
Run `cargo deny --workspace --all-features check advisories` (or `cargo audit`
|
|
396
|
+
if there is no `deny.toml`).
|
|
397
|
+
|
|
398
|
+
A cooldown-held release whose changelog mentions a security fix but has no
|
|
399
|
+
advisory yet (Step 3) gets the same treatment as the `--precise` case below,
|
|
400
|
+
right away and without asking: audit the release diff, lock exactly that
|
|
401
|
+
version, and commit it on its own, quoting the changelog line instead of an
|
|
402
|
+
advisory ID.
|
|
403
|
+
|
|
404
|
+
For each vulnerability or `unsound` advisory:
|
|
405
|
+
|
|
406
|
+
1. **Check for a fix:**
|
|
407
|
+
- Fix is in a new major of a direct dependency: handle it in Step 7 and cite
|
|
408
|
+
the advisory in that commit's body.
|
|
409
|
+
- Fix requires a transitive dependency to upgrade: run the upstream check
|
|
410
|
+
from Step 8.
|
|
411
|
+
- Fix is a compatible release held back by the release cooldown (Step 3):
|
|
412
|
+
if the advisory applies (next point), audit the release diff
|
|
413
|
+
(`references/changelogs.md`), then lock exactly that version with
|
|
414
|
+
`CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo update -p <crate> --precise <version>`.
|
|
415
|
+
Commit it on its own as
|
|
416
|
+
`build(deps): upgrade <crate> to v<version>`, citing the advisory.
|
|
417
|
+
After this, never run a full `cargo update` again in this run: with the
|
|
418
|
+
cooldown it prints `Downgrading <crate> ...` and removes the fix. Use
|
|
419
|
+
only `cargo update -p <other-crate>`. If a full update is unavoidable
|
|
420
|
+
(an MSRV bump approved in Step 7), re-run this `--precise` command
|
|
421
|
+
afterwards and confirm the version with
|
|
422
|
+
`grep -A1 '^name = "<crate>"$' Cargo.lock`.
|
|
423
|
+
2. **Check whether it affects this repository:** Read the advisory
|
|
424
|
+
(`https://rustsec.org/advisories/<ID>`) for affected functions, features and
|
|
425
|
+
platforms. Check whether our code calls the function, enables the feature
|
|
426
|
+
(`cargo tree -q -e features -i <crate> --workspace --target all --all-features`),
|
|
427
|
+
uses the crate only in dev/build dependencies, or builds for the affected
|
|
428
|
+
target.
|
|
429
|
+
3. **Act:**
|
|
430
|
+
- **Does not apply, and `deny.toml` exists:** Ignore it in `deny.toml` in a
|
|
431
|
+
dedicated commit `build(deps): ignore RUSTSEC-YYYY-NNNN` explaining why in
|
|
432
|
+
both the comment/reason and commit body:
|
|
433
|
+
|
|
434
|
+
```toml
|
|
435
|
+
[advisories]
|
|
436
|
+
ignore = [
|
|
437
|
+
{ id = "RUSTSEC-YYYY-NNNN", reason = "only affects Foo::bar, which we don't call" },
|
|
438
|
+
]
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
- **Does not apply, and no `deny.toml` exists:** Report it (do not create
|
|
442
|
+
`deny.toml` or `.cargo/audit.toml`).
|
|
443
|
+
- **Applies and has no simple fix (needs MSRV bump, override or upstream
|
|
444
|
+
release):** Stop and present the options to the user.
|
|
445
|
+
|
|
446
|
+
For other advisory types:
|
|
447
|
+
|
|
448
|
+
- **`unmaintained`**: Report the crate and the alternatives listed in the
|
|
449
|
+
advisory. Ignore in `deny.toml` only if the user asks.
|
|
450
|
+
- **`yanked`**: Run `cargo update -p <crate>` with the Step 2 environment.
|
|
451
|
+
Report if no compatible unyanked version exists.
|
|
452
|
+
- **`notice`**: Report it. Ignore in `deny.toml` only if the user asks.
|
|
453
|
+
- **Malicious crates:** Steps 1 and 3 already stopped the run (see Step 1).
|
|
454
|
+
|
|
455
|
+
## 7. Major upgrades
|
|
456
|
+
|
|
457
|
+
Upgrade direct dependencies that have incompatible updates (from Step 3), one
|
|
458
|
+
commit per upgrade or coupled group.
|
|
459
|
+
|
|
460
|
+
**Group coupled crates into one commit.** Crates that share public types must
|
|
461
|
+
upgrade together (e.g., `usvg`/`resvg`, `rustls`/`tokio-rustls`/`hyper-rustls`,
|
|
462
|
+
RustCrypto crates like `digest`/`sha2`/`hmac`/`md-5`,
|
|
463
|
+
`graviola`/`rustls-graviola`, `opentelemetry` crates). Detect coupled crates
|
|
464
|
+
when:
|
|
465
|
+
|
|
466
|
+
- the new release's manifest requires the new major of the other crate, or
|
|
467
|
+
- upgrading one alone fails with `expected foo::Type, found foo::Type` and
|
|
468
|
+
`cargo tree -d` lists `foo` twice.
|
|
469
|
+
|
|
470
|
+
Check which other direct dependencies depend on the old major:
|
|
471
|
+
`cargo tree -q -i <crate>@<old> --workspace <graph> --all-features --depth 1`.
|
|
472
|
+
|
|
473
|
+
For each upgrade (or coupled group):
|
|
474
|
+
|
|
475
|
+
1. Update the version requirement in `Cargo.toml` (preserving the existing
|
|
476
|
+
specifier style, e.g. `"0.23"` or `"2"`) and run `cargo fetch` (not
|
|
477
|
+
`check` or `build`, which run build scripts) with the Step 2 environment.
|
|
478
|
+
`cargo fetch` succeeds even when the upgrade needs a newer Rust: if its
|
|
479
|
+
output has an `Adding` or `Updating` line ending in `(requires Rust 1.NN)`
|
|
480
|
+
with 1.NN above the MSRV, revert `Cargo.toml` and `Cargo.lock`. Then stop
|
|
481
|
+
and ask about the MSRV bump, with the same evidence Step 4 collects (if
|
|
482
|
+
Step 4's own MSRV question is still waiting for an answer, add this
|
|
483
|
+
upgrade to it instead). If the user approves, commit the MSRV bump (and
|
|
484
|
+
Step 4's lint fixes) on top of the current branch, then retry this
|
|
485
|
+
upgrade. If not, skip this upgrade and list it in the report.
|
|
486
|
+
2. Audit the release diff and changelog (`references/changelogs.md`).
|
|
487
|
+
3. Run `cargo check --workspace --all-targets --all-features`, with the Step 2
|
|
488
|
+
environment, and adapt code to breaking changes. If our code relies on an API
|
|
489
|
+
added after `.0`, set that minor/patch version as the minimum requirement in
|
|
490
|
+
`Cargo.toml`. If the migration is large, revert, skip the upgrade, and report
|
|
491
|
+
an estimate of the work required.
|
|
492
|
+
4. Run CI's checks and check for newly introduced duplicate versions (Step 8).
|
|
493
|
+
5. Commit as `build(deps): upgrade <crate> to v<major>` (or `build(deps)!:` if
|
|
494
|
+
it breaks a published library's public API; see `SKILL.md`, "Commit
|
|
495
|
+
subjects") with the commit body format from `references/changelogs.md`.
|
|
496
|
+
6. If the new release provides an API that cleanly replaces a small local
|
|
497
|
+
workaround, commit that cleanup separately as `refactor: ...`; otherwise
|
|
498
|
+
note it in the report.
|
|
499
|
+
|
|
500
|
+
## 8. Duplicate versions
|
|
501
|
+
|
|
502
|
+
After Step 5 and after each major upgrade in Step 7, diff duplicate versions
|
|
503
|
+
against the baseline:
|
|
504
|
+
|
|
505
|
+
```sh
|
|
506
|
+
sh <scratch>/dups.sh > <scratch>/dups-after.txt
|
|
507
|
+
diff <scratch>/dups-before.txt <scratch>/dups-after.txt
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
For each newly introduced duplicate, find the crates pulling in the older
|
|
511
|
+
version:
|
|
512
|
+
|
|
513
|
+
```sh
|
|
514
|
+
cargo tree -q -i <crate>@<older-version> --workspace <graph> --all-features --depth 1
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
Report every new duplicate and its offending parents. When only 1–3 crates hold
|
|
518
|
+
back the old version, check the upstream status of each offender:
|
|
519
|
+
|
|
520
|
+
1. Get the offender's repository URL (`cargo info <offender>@<version>`) and
|
|
521
|
+
published git SHA (`git.sha1` in `.cargo_vcs_info.json`; see
|
|
522
|
+
`references/changelogs.md`).
|
|
523
|
+
2. Check whether it is already upgraded on the upstream default branch:
|
|
524
|
+
|
|
525
|
+
```sh
|
|
526
|
+
git clone -q --filter=blob:limit=1m --no-checkout <repository> <scratch>/<offender>-repo
|
|
527
|
+
git -C <scratch>/<offender>-repo grep -l -E '^name = "<offender>"' origin/HEAD -- '*Cargo.toml'
|
|
528
|
+
git -C <scratch>/<offender>-repo show origin/HEAD:<manifest-path>
|
|
529
|
+
git -C <scratch>/<offender>-repo log --oneline <published-sha>..origin/HEAD
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
(If the manifest uses `<crate>.workspace = true`, check the root
|
|
533
|
+
`Cargo.toml` under `[workspace.dependencies]`.)
|
|
534
|
+
|
|
535
|
+
3. Check for open issues or PRs (including bot PRs). On GitHub:
|
|
536
|
+
|
|
537
|
+
```sh
|
|
538
|
+
curl -sS 'https://api.github.com/search/issues?q=repo:<owner>/<repo>+<crate>&per_page=20' \
|
|
539
|
+
| jq -r '.items[] | [(if .pull_request then "PR" else "issue" end), .state, .updated_at, .html_url, .title] | @tsv'
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
Report whether each offender is fixed on `HEAD` (commit and unreleased status),
|
|
543
|
+
has an open PR/issue (URL, state, last updated), or has neither. Never add
|
|
544
|
+
duplicate skips to `deny.toml` without asking.
|
|
545
|
+
|
|
546
|
+
## 9. Standing holds
|
|
547
|
+
|
|
548
|
+
Check whether existing holds and workarounds are now obsolete:
|
|
549
|
+
|
|
550
|
+
- `[patch]` entries and git dependencies waiting on an upstream release;
|
|
551
|
+
- `=` and `<` version pins (from Step 3): check the comment, or the commit
|
|
552
|
+
that added the pin (`git log -S'<pin>' -- '*Cargo.toml'`), to see if the
|
|
553
|
+
reason still holds;
|
|
554
|
+
- `deny.toml`: `[bans] skip` and `skip-tree` entries for resolved duplicates,
|
|
555
|
+
and `[advisories] ignore` entries that no longer match;
|
|
556
|
+
- `--precise` lockfile holds mentioned in earlier commit messages (which
|
|
557
|
+
`cargo update` will have cleared): verify the upstream regression was fixed.
|
|
558
|
+
|
|
559
|
+
Remove obsolete holds in a `build(deps): ...` commit explaining why the hold is
|
|
560
|
+
no longer needed (or fold into Step 5 when the compatible upgrade resolved it).
|
|
561
|
+
List all remaining holds and their reasons in the report.
|
|
562
|
+
|
|
563
|
+
## 10. CI's pinned toolchain
|
|
564
|
+
|
|
565
|
+
Verify that CI pins its Rust toolchain and runs `cargo clippy` on that pinned
|
|
566
|
+
version rather than floating `stable`, and bump the pinned toolchain if a newer
|
|
567
|
+
release is out. Follow `references/ci-audit.md` ("Toolchains").
|