Skip to content

Commit 7981384

Browse files
ci: pin credential-holding third-party actions by sha and default ci.yml and check-links.yml to a read-only token (#13430)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoRyAStcu3CV5kiXeCX564xD)_ CI supply-chain hardening: every third-party action that runs holding a credential now names a commit sha, and the two workflows that had no `permissions:` block default the job token to read-only. ## What changed **Third-party actions pinned by commit sha** (each with a trailing `# vX.Y.Z` comment). Each one was the commit its floating ref resolved to when this was written, read with `git ls-remote` against the upstream repository: | workflow | action | was | now | credential it holds | |---|---|---|---|---| | `changeset-release.yml` (2 steps) | `changesets/action` | `@v1` (a branch) | `a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d` # v1.9.0 | `NPM_TOKEN`, `GITHUB_TOKEN` | | `check-links.yml` | `lycheeverse/lychee-action` | `@v2` | `e7477775783ea5526144ba13e8db5eec57747ce8` # v2.9.0 | `GITHUB_TOKEN` | | `dependabot-auto-merge.yml` | `dependabot/fetch-metadata` | `@v3` | `25dd0e34f4fe68f24cc83900b1fe3fe149efef98` # v3.1.0 | `github-token` input | | `changelog.yml` | `orhun/git-cliff-action` | `@v4` | `a9a95522b26fe6403f7bb24031f21fb573d0f5ff` # v4.9.1 | job token by default (`contents: write` job) | - `changesets/action` moves from the `v1` branch to the v1.9.0 commit, which is the commit the workflow's own git-surface reading was already taken at, so the two properties the release lane depends on are unchanged. `scripts/__tests__/changeset-release-action-ref-pin.test.ts` now holds the sha, and gains one non-vacuity case: a step that goes back to the moving `v1` reds. - The four are declared exceptions in `scripts/check-action-ref-convention.mjs` (the gate's mechanism for a deliberate off-convention ref), with one shared reason. The `issue` field names this pull request. First-party `actions/*` refs stay on the floating-tag default; the repo-wide pinning posture is not changed here. - `half-state-patrol.yml` was already sha-pinned and is untouched. **Least-privilege job token.** - `ci.yml`: top-level `permissions: contents: read`. The seven jobs without their own block (changeset-check, type-check, test, test-dist-pins, test-coverage, e2e, docs) were measured for token use: no step passes `GITHUB_TOKEN`, `github.token`, `gh`, or `github-script` in any of them; `actions/cache` and `actions/upload-artifact` use the runner's own token. `test-aggregate` and `coverage-report` keep their existing `contents: read` + `actions: read` blocks. **No job was widened.** - `check-links.yml`: top-level `permissions: contents: read`; lychee's token is a read for API rate limits. **Dependabot.** The `github-actions` ecosystem now runs weekly and groups minor/patch updates into one pull request, so the pinned shas get their updates. Majors stay separate, so a declined major (the deliberate `changesets/action` v1 hold) does not block the group. The `npm` entry is unchanged. ## Verification - `node scripts/check-action-ref-convention.mjs` → exit 0: 141 refs in 28 workflow files, 13 distinct, 0 undeclared, 0 stale. - `node scripts/check-changeset-presence.mjs` → exit 0: no released package's source or contract changed, so no changeset is owed. - Vitest over `changeset-release-action-ref-pin.test.ts`, `check-action-ref-convention.test.ts`, `check-links-workflow.test.ts`: 33/33 passed once the exception entries name this PR. ⚠️ Run with a scratch vitest 4.1.10 + yaml 2.9.0 runner rather than the repo-root config (this container had no `pnpm run setup` build of the objectstack pin); CI's `pnpm test` is the authoritative run. ## Governed surface The diff touches `.github/workflows/**`, so this stays a draft until an authorized approval. Security change: the maintainer approves before merge. - [x] Adds no product-specific widget, dialog, hook or string (see AGENTS.md › Product-neutral renderer) Session: `https://claude.ai/code/session_01W9H2WdXx3kPkf6moDnRdRE` 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01W9H2WdXx3kPkf6moDnRdRE --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 861fdff commit 7981384

8 files changed

Lines changed: 118 additions & 25 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,22 @@ updates:
4343
- "minor"
4444
- "patch"
4545

46-
# Enable version updates for GitHub Actions
46+
# Enable version updates for GitHub Actions. Weekly and grouped into one
47+
# pull request: the third-party actions that hold a credential are pinned
48+
# by commit sha, so a release reaches them only through this update.
4749
- package-ecosystem: "github-actions"
4850
directory: "/"
4951
schedule:
50-
interval: "monthly"
52+
interval: "weekly"
53+
groups:
54+
# Majors stay separate pull requests: one declined major (the
55+
# changesets/action v1 pin is deliberate) must not hold the group.
56+
github-actions:
57+
patterns:
58+
- "*"
59+
update-types:
60+
- "minor"
61+
- "patch"
5162
labels:
5263
- "dependencies"
5364
- "github-actions"

‎.github/workflows/changelog.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
# shells out to pnpm, and this workflow pins no toolchain.
100100

101101
- name: Generate changelog
102-
uses: orhun/git-cliff-action@v4
102+
uses: orhun/git-cliff-action@a9a95522b26fe6403f7bb24031f21fb573d0f5ff # v4.9.1
103103
id: changelog
104104
with:
105105
config: cliff.toml

‎.github/workflows/changeset-release.yml‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,9 @@ jobs:
880880
# plausibly the shape that makes the clear step unnecessary — which is an
881881
# argument for revisiting the pin eventually, not for bumping it blind.
882882
#
883-
# ⛔ WHAT NOTICES A BUMP. This `@v1` ref is pinned by exactly one thing:
883+
# ⛔ WHAT NOTICES A BUMP. This v1 ref is pinned by exactly one thing:
884884
# `scripts/__tests__/changeset-release-action-ref-pin.test.ts`. It fails on
885-
# a bump of EITHER `uses: changesets/action@v1` line in this file and names
885+
# a bump of EITHER `uses: changesets/action@...` line in this file and names
886886
# the two properties above as what a bump must re-establish. There is no
887887
# second guard — the type checker and the linters do not read this file at
888888
# all — so ⛔ do not delete that test as collateral of some other cleanup.
@@ -895,9 +895,19 @@ jobs:
895895
# `CLAUDE.md` / `GEMINI.md` and on `.changeset/pre/`). objectui#6081
896896
# deleted that mirror, because the bundled copy is a minified chunk behind
897897
# a MOVING tag and cannot be pinned from here at any effort — a retag of
898-
# `v1` in place changed it and nothing here failed. A ref pin cannot catch
899-
# a retag either, but it does not pretend to: it catches the DELIBERATE
900-
# bump, which is the only moment anyone can act on.
898+
# `v1` in place changed it and nothing here failed. A ref pin catches the
899+
# DELIBERATE bump, which is the only moment anyone can act on.
900+
#
901+
# ⭐ THE REF IS A COMMIT SHA, NOT THE MOVING `v1`. Both `uses:` lines name
902+
# `a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d`, the commit the `v1` branch
903+
# and the `v1.9.0` tag both resolved to when this was written, and the
904+
# same commit the git-surface reading above was taken at. This step runs
905+
# with `NPM_TOKEN`, so a retag of `v1` would otherwise hand the publish
906+
# credential to code nobody here has read; a sha cannot move. A bump is
907+
# still a deliberate edit of both lines to another sha (the trailing
908+
# `# vX.Y.Z` comment names the release it is), and it still has to
909+
# re-establish the two properties above. The sha is a declared exception
910+
# to `scripts/check-action-ref-convention.mjs`'s floating-tag default.
901911

902912
# ⚠️ THE STEP THAT LETS THE PREDICATE REACH THE ACTION (objectui#5442).
903913
#
@@ -1019,7 +1029,7 @@ jobs:
10191029
- name: Publish to npm
10201030
id: changesets-publish
10211031
if: github.event_name == 'push'
1022-
uses: changesets/action@v1
1032+
uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d # v1.9.0
10231033
with:
10241034
publish: pnpm changeset:publish
10251035
env:
@@ -1437,7 +1447,7 @@ jobs:
14371447
- name: Refresh the version PR
14381448
id: changesets-version
14391449
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
1440-
uses: changesets/action@v1
1450+
uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d # v1.9.0
14411451
with:
14421452
version: pnpm changeset:version
14431453
title: 'chore: release packages'

‎.github/workflows/check-links.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ on:
6161
# - main
6262
# pull_request:
6363

64+
# Least privilege: the job checks out and reads public pages. The token lychee
65+
# receives is for GitHub's API rate limit on link checks, a read.
66+
permissions:
67+
contents: read
68+
6469
jobs:
6570
check-links:
6671
runs-on: ubuntu-latest
@@ -145,7 +150,7 @@ jobs:
145150
uses: actions/checkout@v7
146151

147152
- name: Check links with Lychee
148-
uses: lycheeverse/lychee-action@v2
153+
uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2.9.0
149154
with:
150155
# Both trees:
151156
# content/docs/** — the published site's documentation (the fumadocs

‎.github/workflows/ci.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ on:
114114
# which on a queue build is the queue's own generation ref
115115
# (`gh-readonly-queue/main/pr-<n>-<sha>`) — colliding with
116116
# neither a PR group nor a push group, exactly as before.
117+
# Least privilege for the job token. Every job without its own `permissions:`
118+
# block (changeset-check, type-check, test, test-dist-pins, test-coverage,
119+
# e2e, docs) only checks out, builds, tests, and saves caches and artifacts;
120+
# none of those calls the API with this token (actions/cache and
121+
# actions/upload-artifact use the runner's own token), so `contents: read` is
122+
# all they get. The two jobs that read the Actions API (test-aggregate,
123+
# coverage-report) declare their own block, which replaces this one.
124+
permissions:
125+
contents: read
126+
117127
concurrency:
118128
group: >-
119129
ci-${{ github.workflow }}-${{ github.event.pull_request.number

‎.github/workflows/dependabot-auto-merge.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ jobs:
153153

154154
- name: Dependabot metadata
155155
id: metadata
156-
uses: dependabot/fetch-metadata@v3
156+
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
157157
with:
158158
github-token: "${{ secrets.GITHUB_TOKEN }}"
159159

‎scripts/__tests__/changeset-release-action-ref-pin.test.ts‎

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,30 @@ import { parse as parseYaml } from 'yaml';
4848
* on that ref. Move the assertion somewhere that survives first — do not just
4949
* drop it.
5050
*
51-
* ## What this pin does NOT do
51+
* ## The ref is a commit sha, so a retag cannot reach it
5252
*
53-
* It cannot catch a **retag of `v1` in place**. `changesets/action@v1` is a
54-
* moving tag whose bundled `@changesets/read` is a minified chunk nothing here
55-
* installs, so no test can execute it and no lockfile records it — that gap is
56-
* objectui#6081's subject, and it is the reason the mirror was deleted rather
57-
* than given a better referent. This pin catches the DELIBERATE bump, which is
58-
* the only moment anyone can act on anyway.
53+
* `changesets/action@v1` names a moving branch whose bundled `@changesets/read`
54+
* is a minified chunk nothing here installs, so no test can execute it and no
55+
* lockfile records it — that gap is objectui#6081's subject, and it is the
56+
* reason the mirror was deleted rather than given a better referent. Both
57+
* `uses:` lines now name the v1.9.0 commit instead, so a retag of `v1` in place
58+
* no longer changes what runs; this pin catches the DELIBERATE bump, which is
59+
* the only moment anyone can act on anyway, and a step that drifts back onto
60+
* the moving `v1`.
5961
*/
6062
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
6163
const workflowPath = path.join(repoRoot, '.github/workflows/changeset-release.yml');
6264
const workflowSource = fs.readFileSync(workflowPath, 'utf8');
6365

64-
const PINNED_REF = 'changesets/action@v1';
66+
/**
67+
* The v1 commit, not the moving `v1` branch: `v1` and the `v1.9.0` tag both
68+
* resolved to this sha when the pin moved off the branch, and it is the commit
69+
* the workflow's git-surface reading was taken at. The publish step runs with
70+
* the npm token, so the ref it executes must not be able to move under it.
71+
*/
72+
const PINNED_SHA = 'a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d';
73+
const PINNED_REF = `changesets/action@${PINNED_SHA}`;
74+
const PINNED_LINE = ` uses: ${PINNED_REF} # v1.9.0`;
6575

6676
interface Step {
6777
name?: string;
@@ -93,7 +103,7 @@ function changesetsActionSteps(source: string): Array<{ job: string; step: strin
93103
return found;
94104
}
95105

96-
describe('changeset-release.yml pins changesets/action to @v1', () => {
106+
describe('changeset-release.yml pins changesets/action to the v1.9.0 commit', () => {
97107
it('still uses the action at all — the pin is not vacuous', () => {
98108
// Without this, every assertion below passes over a workflow that dropped
99109
// the action entirely, which is the one way a "toContain" pin lies.
@@ -145,15 +155,15 @@ describe('the pin can fail (non-vacuity)', () => {
145155
}
146156

147157
it('goes red when the publish step is bumped to @v2', () => {
148-
const bumped = mutate(' uses: changesets/action@v1\n with:\n publish:', ' uses: changesets/action@v2\n with:\n publish:');
158+
const bumped = mutate(`${PINNED_LINE}\n with:\n publish:`, ' uses: changesets/action@v2\n with:\n publish:');
149159
const offenders = changesetsActionSteps(bumped).filter((s) => s.uses !== PINNED_REF);
150160
expect(offenders).toEqual([
151161
{ job: 'release', step: 'Publish to npm', uses: 'changesets/action@v2' },
152162
]);
153163
});
154164

155165
it('goes red when the refresh step is bumped to @v2', () => {
156-
const bumped = mutate(' uses: changesets/action@v1\n with:\n version:', ' uses: changesets/action@v2\n with:\n version:');
166+
const bumped = mutate(`${PINNED_LINE}\n with:\n version:`, ' uses: changesets/action@v2\n with:\n version:');
157167
const offenders = changesetsActionSteps(bumped).filter((s) => s.uses !== PINNED_REF);
158168
expect(offenders).toEqual([
159169
{ job: 'release', step: 'Refresh the version PR', uses: 'changesets/action@v2' },
@@ -164,15 +174,23 @@ describe('the pin can fail (non-vacuity)', () => {
164174
// The shape a real v2 migration takes: `changesets/action/publish@v2`. A
165175
// pin that matched only the exact old string would find nothing here and
166176
// pass.
167-
const bumped = mutate(' uses: changesets/action@v1\n with:\n publish:', ' uses: changesets/action/publish@v2\n with:\n publish:');
177+
const bumped = mutate(`${PINNED_LINE}\n with:\n publish:`, ' uses: changesets/action/publish@v2\n with:\n publish:');
168178
const offenders = changesetsActionSteps(bumped).filter((s) => s.uses !== PINNED_REF);
169179
expect(offenders).toEqual([
170180
{ job: 'release', step: 'Publish to npm', uses: 'changesets/action/publish@v2' },
171181
]);
172182
});
173183

184+
it('goes red when the publish step goes back to the moving v1 branch', () => {
185+
const floating = mutate(`${PINNED_LINE}\n with:\n publish:`, ' uses: changesets/action@v1\n with:\n publish:');
186+
const offenders = changesetsActionSteps(floating).filter((s) => s.uses !== PINNED_REF);
187+
expect(offenders).toEqual([
188+
{ job: 'release', step: 'Publish to npm', uses: 'changesets/action@v1' },
189+
]);
190+
});
191+
174192
it('goes red when the action is dropped from the workflow entirely', () => {
175-
const stripped = mutate(' uses: changesets/action@v1', ' uses: actions/checkout@v7');
193+
const stripped = mutate(PINNED_LINE, ' uses: actions/checkout@v7');
176194
expect(changesetsActionSteps(stripped).length).toBeLessThan(2);
177195
});
178196
});

‎scripts/check-action-ref-convention.mjs‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,45 @@ export const DECLARED_EXCEPTIONS = [
141141
'reviewed moment; a floating ref would re-adopt every upstream change on the next scheduled ' +
142142
'run, with nothing in this repository to roll back to.',
143143
},
144+
// The four below share one reason, said once: each is a third-party action
145+
// that runs holding a credential, so the code a floating tag resolves to
146+
// would receive that credential on the next run after the tag moved, with
147+
// nothing here reviewing it. A commit sha cannot move; the trailing
148+
// `# vX.Y.Z` comment names the release it is. First-party `actions/*` refs
149+
// stay on the floating-tag default.
150+
{
151+
workflow: 'changeset-release.yml',
152+
action: 'changesets/action',
153+
issue: 'objectui#13430',
154+
reason:
155+
'runs with NPM_TOKEN and GITHUB_TOKEN in the publish and version-PR steps; pinned to the ' +
156+
'v1.9.0 commit, the one the workflow comment and the ref-pin test say both v1 properties ' +
157+
'were read at (scripts/__tests__/changeset-release-action-ref-pin.test.ts holds the sha).',
158+
},
159+
{
160+
workflow: 'check-links.yml',
161+
action: 'lycheeverse/lychee-action',
162+
issue: 'objectui#13430',
163+
reason:
164+
'receives GITHUB_TOKEN through its env and its token input default; pinned to the v2.9.0 ' +
165+
'commit so the link checker cannot change under that token between reviews.',
166+
},
167+
{
168+
workflow: 'dependabot-auto-merge.yml',
169+
action: 'dependabot/fetch-metadata',
170+
issue: 'objectui#13430',
171+
reason:
172+
'receives GITHUB_TOKEN as its github-token input in a job that approves and enqueues ' +
173+
'Dependabot pull requests; pinned to the v3.1.0 commit.',
174+
},
175+
{
176+
workflow: 'changelog.yml',
177+
action: 'orhun/git-cliff-action',
178+
issue: 'objectui#13430',
179+
reason:
180+
'defaults its github_token input to the job token, which holds contents: write in this ' +
181+
'job; pinned to the v4.9.1 commit.',
182+
},
144183
];
145184

146185
/**

0 commit comments

Comments
 (0)