Skip to content

Commit 2c81413

Browse files
cliffhallclaude
andcommitted
fix: close two pin-guard bypasses; update the merge branch by name from a detached worktree
- Action names are matched without regard to case, as GitHub resolves them. - A reusable-workflow call upstream of a credentialed downloader counts as an artifact producer: the called workflow uploads into the same run and is not read by the guard. - The release skill fast-forwards the remote merge branch by name, since the verification worktree is detached and a plain push there moves nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 2392c9e commit 2c81413

3 files changed

Lines changed: 76 additions & 9 deletions

File tree

‎.claude/skills/release/SKILL.md‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,22 @@ A row that says "verified" without saying what was run is not a ledger entry.
314314

315315
**4e. When verification finds something, the fix goes on `v2/main`, never on
316316
the merge branch.** File the issue (`/issue-create`), fix it through an
317-
ordinary PR, then fast-forward the merge branch to the new `origin/v2/main`
318-
(`git merge --ff-only origin/v2/main`, then push), so the fix arrives the way
319-
everything else did and the branch is still `v2/main` with nothing added.
317+
ordinary PR, then fast-forward the merge branch to the new `origin/v2/main`,
318+
so the fix arrives the way everything else did and the branch is still
319+
`v2/main` with nothing added. The verification worktree is detached, so a
320+
merge and a plain `git push` there would move nothing. Update the remote
321+
branch by name, then move the worktree onto it:
322+
323+
```sh
324+
git fetch origin v2/main
325+
# A fast-forward only: the push is refused if the branch holds anything
326+
# v2/main does not.
327+
git push origin "origin/v2/main:refs/heads/v2/chore/$N-release-$MILESTONE"
328+
git fetch origin
329+
git switch --detach "origin/v2/chore/$N-release-$MILESTONE" && npm ci
330+
```
331+
332+
Then repeat step 3's `git merge-tree` check.
320333
Re-run what the fix touches and update the ledger. If the fix changed a
321334
package, its version PR (2b or 2c) runs again first.
322335

‎scripts/verify-action-pins.mjs‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
// 3. uploads an artifact that a credentialed job downloads and has anywhere
3030
// in its transitive `needs` (an artifact is scoped to the run, so a job
3131
// can download from any job that finished before it), so every producer
32-
// in a `source → package → publish` chain counts, not only the last. Here that is `release.yml`'s two build jobs:
32+
// in a `source → package → publish` chain counts, not only the last. A
33+
// job that calls a reusable workflow counts as a producer too, since the
34+
// called workflow can upload into the same run and is not read here. Here that is `release.yml`'s two build jobs:
3335
// each builds the tarball or wheel its publish job hands to the registry
3436
// under provenance, so a moved tag in the build job publishes as surely
3537
// as one in the publish job would. (The build was split out of the
@@ -112,11 +114,25 @@ function handedSecret(job, inherited) {
112114
const needsOf = (job) =>
113115
job.needs == null ? [] : [job.needs].flat().map(String);
114116

117+
// GitHub resolves an action's owner and repository without regard to case, so
118+
// `Actions/Upload-Artifact@v7` is the same action and must be recognized.
115119
const stepsUsing = (job, action) =>
116120
(job.steps ?? []).some(
117-
(step) => typeof step?.uses === "string" && step.uses.startsWith(action),
121+
(step) =>
122+
typeof step?.uses === "string" &&
123+
step.uses.toLowerCase().startsWith(action),
118124
);
119125

126+
/**
127+
* Can this job have produced an artifact? It can when one of its steps
128+
* uploads one, and also when it CALLS A REUSABLE WORKFLOW: the called
129+
* workflow's jobs upload into the same run, and this guard does not read
130+
* them. So a workflow call upstream of a credentialed downloader is counted
131+
* rather than assumed harmless, which makes its own ref subject to the pin.
132+
*/
133+
const mayUploadArtifact = (job) =>
134+
typeof job.uses === "string" || stepsUsing(job, "actions/upload-artifact@");
135+
120136
/**
121137
* @param {string} yaml raw contents of a workflow file
122138
* @param {string} [file] only for the parse-error message
@@ -171,10 +187,7 @@ export function credentialedJobs(yaml, file) {
171187
if (!held.has(name) || !stepsUsing(job, "actions/download-artifact@"))
172188
continue;
173189
for (const producer of upstreamOf(name)) {
174-
if (
175-
!held.has(producer) &&
176-
stepsUsing(workflow.jobs[producer], "actions/upload-artifact@")
177-
) {
190+
if (!held.has(producer) && mayUploadArtifact(workflow.jobs[producer])) {
178191
held.add(producer);
179192
grew = true;
180193
}

‎scripts/verify-action-pins.test.mjs‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,47 @@ test("a producer behind a job that neither downloads nor uploads still counts",
220220
]);
221221
});
222222

223+
test("action names are matched without regard to case, as GitHub resolves them", () => {
224+
const yaml = wf(
225+
"jobs:",
226+
" package:",
227+
" steps:",
228+
" - uses: Actions/Upload-Artifact@v7",
229+
" publish:",
230+
" needs: package",
231+
" permissions:",
232+
" id-token: write",
233+
" steps:",
234+
` - uses: Actions/Download-Artifact@${SHA} # v8.0.1`,
235+
);
236+
assert.deepEqual([...credentialedJobs(yaml)].sort(), ["package", "publish"]);
237+
assert.deepEqual(unpinnedRefs(yaml), [
238+
{ job: "package", uses: "Actions/Upload-Artifact@v7" },
239+
]);
240+
});
241+
242+
test("an upstream reusable-workflow call counts as an artifact producer", () => {
243+
const yaml = wf(
244+
"jobs:",
245+
" build:",
246+
" uses: org/repo/.github/workflows/build.yml@v1",
247+
" lint:",
248+
" uses: org/repo/.github/workflows/lint.yml@v1",
249+
" publish:",
250+
" needs: build",
251+
" permissions:",
252+
" id-token: write",
253+
" steps:",
254+
` - uses: actions/download-artifact@${SHA} # v8.0.1`,
255+
);
256+
// The called workflow can upload into this run and is not read here, so the
257+
// call upstream of the downloader is held to the pin. `lint` is not upstream.
258+
assert.deepEqual([...credentialedJobs(yaml)].sort(), ["build", "publish"]);
259+
assert.deepEqual(unpinnedRefs(yaml), [
260+
{ job: "build", uses: "org/repo/.github/workflows/build.yml@v1" },
261+
]);
262+
});
263+
223264
test("an upload is not credentialed when the consumer downloads nothing", () => {
224265
const yaml = wf(
225266
"jobs:",

0 commit comments

Comments
 (0)