Commit 50ab7f4
fix(aletheia): SHA-pinning check could never fail; make it real
`check_workflow_pins` decided a line was unpinned with:
if line.contains("@v") && !line.contains("@") {
`contains("@v")` implies `contains("@")`, so the second clause is always false
and `has_unpinned` could never be set. Every repository passed the check
unconditionally, including ones with `@v4` or `@master` refs. Verified with a
standalone binary before changing anything:
uses: actions/checkout@v4 old_detects_unpinned=false
This is aletheia's Silver-level "GitHub Actions SHA pinning" check — a gate
that has never been able to fail. It is also, pointedly, the exact check that
would have caught `SonarSource/sonarqube-scan-action@master`, the unpinned
action that broke this repo's Governance and CodeQL in #139.
Replaced with `uses_line_is_pinned`, which requires the ref after the final `@`
to be 40 hex characters, and:
- accepts both `uses:` and list form `- uses:` (the estate's existing
workflow linter anchors to line-start and misses the inline form)
- ignores a trailing `# v7.0.1` provenance comment, so a correctly pinned
line with a stale version comment is not a false positive
- exempts `./…` local actions/reusable workflows and `docker://` refs, which
cannot carry a Git SHA
Also replaced `assert!(true)` in test_file_exists with a real assertion. It had
given up on CWD-dependence; anchoring on `env!("CARGO_MANIFEST_DIR")` makes it
deterministic, and it now covers the negative case and the is_file()-not-
exists() distinction.
Verified: 29 unit tests pass (was 26), `cargo fmt --check` clean, clippy 25 -> 23
findings. End-to-end `cargo run -- .` against this repo now reports
`[FAIL] GitHub Actions SHA pinning`, correctly identifying the one genuinely
unpinned action, where before the fix it reported a pass.
Refs #125.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent bb151f9 commit 50ab7f4
1 file changed
Lines changed: 103 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 144 | + | |
| 145 | + | |
155 | 146 | | |
156 | 147 | | |
157 | 148 | | |
| |||
176 | 167 | | |
177 | 168 | | |
178 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
179 | 213 | | |
180 | 214 | | |
181 | 215 | | |
| |||
300 | 334 | | |
301 | 335 | | |
302 | 336 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
309 | 395 | | |
310 | 396 | | |
311 | 397 | | |
| |||
0 commit comments