Repository navigation
Commit 4f51cca
fix(ci): build the scanner, not the caller, in scan-and-report.yml (#286)
Refs #276 and #212. This pull request does not close #276 by itself: the
first acceptance criterion needs a hosted run from an external caller
(see "Not shown yet").
## Symptom
Every repository that calls `scan-and-report.yml` as a reusable workflow
fails at **Run scan** with exit 127: `./target/release/panic-attack`
does not exist. Observed on hyperpolymath/echidna `main`, Security Scan
run 42351376316.
## Cause
In a reusable workflow, `actions/checkout` with no `repository:` checks
out the **caller**. The step `cargo build --locked --release` therefore
built the caller's crate. It worked only when this repository ran the
workflow on itself.
## Change
The workflow now fetches the scanner source at the commit of this
workflow file and builds that.
- **Source:** `job.workflow_repository` at `job.workflow_sha`. GitHub
documents both as the repository and commit of the workflow file that
defines the job.
- A caller that pins `scan-and-report.yml@<sha>` gets the scanner at
that SHA. It is never `main` by name, which keeps the #212 property.
- A run of this workflow in its own repository still builds the commit
under test.
- **Location:** the runner's temp directory, outside the workspace. The
scan cannot report on the scanner's own files.
- **Refusals:** the fetch step exits 2 for a repository that is not
`owner/name` and for a commit that is not a full SHA. It also checks
that the fetched `HEAD` is that SHA.
- **Cache:** the cache step keys on the scanner's workspace, not the
caller's.
- **Scan step:** it takes the target path from the environment and
quotes it.
No `uses:` reference changes, so `actions.lock` is unchanged.
One difference from the proposal in #276: the proposal names
`hyperpolymath/panic-attack` as a literal. This change takes the
repository from `job.workflow_repository`, so a rename of this
repository cannot break the fetch.
## Acceptance criteria
| Criterion | State |
|---|---|
| An external caller reaches `Run scan`, and the binary exists | Local
run only. Needs a hosted run from an external caller. |
| This repository's own run still builds the commit under test | Hosted
`workflow_dispatch` run on this branch: see the comment below when it
completes. |
| The report contains no findings from the scanner source | Holds by
construction: the source is outside the workspace. The local report
names no scanner path. |
## Evidence (local)
I extracted the changed steps from the workflow file and ran them on
x86_64 Linux with cargo 1.97.0.
- **Fetch:** succeeds at `c7b1c44` (`main` at that time). It is refused
with exit 2 for `main`, a short SHA, a malformed repository and an empty
repository.
- **Build:** 3 min 14 s. The binary exists at the path that the scan
step uses.
- **Scan:** a checkout of hyperpolymath/echidna as the caller. Exit 0,
schema 2.6 report, 951 of 951 files analysed, 130 weak points. The
report names no scanner source path, and no scanner source is inside the
workspace.
## Not shown yet
That `job.workflow_sha` names this repository's commit inside a call
from another repository. The local run cannot show it. A caller must pin
a commit that contains this change; echidna's `security-scan.yml` still
pins `be6ac46`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_0136P7ZmAsYpFA9gxfQLF3F6)_
Signed-off-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>1 parent c7b1c44 commit 4f51cca
1 file changed
Lines changed: 51 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
41 | 70 | | |
42 | 71 | | |
43 | 72 | | |
44 | 73 | | |
45 | 74 | | |
46 | 75 | | |
47 | 76 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
56 | 93 | | |
57 | 94 | | |
58 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
59 | 99 | | |
60 | | - | |
61 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
62 | 103 | | |
63 | 104 | | |
64 | 105 | | |
| |||
0 commit comments