Commit 44c0d5f
feat(bridge): split phantom into phantom-declared vs phantom-transitive
The Track E sweep across 29 Cargo CVE issues revealed that the previous
classifier marked any crate without a direct `use <crate>` statement as
`reach=phantom`, conflating two very different remediation paths:
- True phantom (`PhantomDeclared`): crate IS in a Cargo.toml dependency
block but never imported. Fix: `cargo machete --fix` strips the dep and
the whole subtree drops from Cargo.lock. file-soup#50 is the canonical
case.
- Misclassified (`PhantomTransitive`): crate is NOT in any Cargo.toml —
pulled in by a parent. Local strip is impossible; the fix requires
bumping the parent past the affected version. Of 28 non-pilot Track E
repos, ~26 fell here (Batch A 7/7 misclassified, Cohort E-2 4/5).
Changes
-------
- `ReachabilityStatus::Phantom` split into `PhantomDeclared` /
`PhantomTransitive`. Serde rename_all = kebab-case so the JSON wire
values are `phantom-declared` / `phantom-transitive`.
- `ReachabilityEvidence` gains an optional `parent_dep` (set only on
`PhantomTransitive` when identifiable via Cargo.lock).
- `reachability::check_reachability_with_manifest` is the new entry
point — takes the declared-deps set and a parent map, returns the
correct variant. The old `check_reachability` is `#[cfg(test)]` only.
- `lockfile::collect_cargo_parents` parses `Cargo.lock`'s `dependencies`
arrays and BFS-walks from each direct dep, attributing every
transitive to a parent (first match wins).
- `classify::classify` no longer takes `is_direct` — the variant on the
evidence already carries that information. Three-way classifier
output (Mitigable / Unmitigable / Informational) is unchanged. The
rationale and fix-action diverge per variant:
- PhantomDeclared: "Strip from Cargo.toml — run `cargo machete --fix`"
- PhantomTransitive: "Pulled in transitively by `<parent>` — fix
requires bumping the parent dependency past the affected version"
- `BridgeReport::schema_version` bumped 0.1.0 → 0.2.0 to flag the
reach-field semantics change.
Tests
-----
Added 8 regression tests covering:
- `reachability::phantom_declared_when_crate_in_cargo_toml_but_no_use`
- `reachability::phantom_transitive_when_crate_not_in_cargo_toml`
(with parent identified)
- `reachability::reachable_when_declared_and_used`
- `reachability::phantom_transitive_with_unknown_parent_is_still_classified`
- `reachability::phantom_classification_normalises_underscore_to_hyphen`
- `reachability::phantom_declared_resolves_workspace_member_dep`
- `lockfile::parent_map_identifies_direct_to_transitive_path`
- `lockfile::parent_map_normalises_underscore_to_hyphen`
- `lockfile::parent_map_returns_empty_when_no_lockfile`
- `classify::test_phantom_declared_recommends_machete_strip`
- `classify::test_phantom_transitive_recommends_parent_bump`
- `classify::test_phantom_transitive_unknown_parent_falls_back_gracefully`
- `classify::test_phantom_variants_both_classify_informational`
Existing tests rewritten to use the new evidence shape; all 38 bridge
tests pass + full suite (327 lib + integration) is green.
Refs: panic-attack#74 (vendored-pin allowlist), panic-attack#75
(Dioxus/GTK informational), file-soup#50 (true phantom-declared).
Closes #32 (Track C/E sweep parent).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7935204 commit 44c0d5f
4 files changed
Lines changed: 601 additions & 73 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
30 | | - | |
31 | 35 | | |
32 | 36 | | |
33 | | - | |
34 | | - | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | | - | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
43 | | - | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
65 | 76 | | |
66 | 77 | | |
67 | 78 | | |
| |||
183 | 194 | | |
184 | 195 | | |
185 | 196 | | |
186 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
187 | 207 | | |
188 | 208 | | |
189 | 209 | | |
190 | | - | |
| 210 | + | |
| 211 | + | |
191 | 212 | | |
192 | 213 | | |
193 | 214 | | |
| |||
200 | 221 | | |
201 | 222 | | |
202 | 223 | | |
| 224 | + | |
203 | 225 | | |
204 | 226 | | |
205 | 227 | | |
206 | 228 | | |
207 | | - | |
208 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
209 | 233 | | |
210 | 234 | | |
211 | | - | |
212 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
213 | 241 | | |
214 | 242 | | |
215 | 243 | | |
216 | 244 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
222 | 253 | | |
223 | 254 | | |
224 | | - | |
225 | | - | |
| 255 | + | |
| 256 | + | |
226 | 257 | | |
227 | 258 | | |
228 | | - | |
| 259 | + | |
229 | 260 | | |
230 | 261 | | |
231 | 262 | | |
232 | | - | |
233 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
234 | 269 | | |
235 | 270 | | |
236 | 271 | | |
237 | 272 | | |
238 | 273 | | |
239 | 274 | | |
240 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
241 | 292 | | |
242 | 293 | | |
243 | | - | |
| 294 | + | |
244 | 295 | | |
245 | 296 | | |
246 | 297 | | |
247 | 298 | | |
248 | 299 | | |
249 | | - | |
| 300 | + | |
250 | 301 | | |
251 | 302 | | |
252 | 303 | | |
253 | 304 | | |
254 | 305 | | |
255 | 306 | | |
256 | | - | |
| 307 | + | |
257 | 308 | | |
258 | 309 | | |
259 | 310 | | |
260 | 311 | | |
261 | 312 | | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
268 | 319 | | |
269 | 320 | | |
0 commit comments