Skip to content

ci: harden GitHub Actions workflows - #1052

Merged
EhabY merged 3 commits into
mainfrom
ci/supply-chain-hardening
Jul 30, 2026
Merged

ci: harden GitHub Actions workflows#1052
EhabY merged 3 commits into
mainfrom
ci/supply-chain-hardening

Conversation

@EhabY

@EhabY EhabY commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Review priority: 2/10. Fast review, config only; hardens the pipeline every later release ships through.
Diff: CI config +62/-12, no production or test code

Hardens the GitHub Actions release/publish pipeline. No runtime code changes; nothing changes on today's happy path.

Changes

  • Least-privilege GITHUB_TOKEN: workflows default to contents: read; only the release-creating job keeps contents: write + pull-requests: read (same scopes as before, now job-scoped). All checkouts set persist-credentials: false; no job pushes or fetches after checkout, and pnpm clones the github:coder/coder dependency anonymously in its own store, so this is inert.
  • Marketplace/OpenVSX publish jobs run in a publish environment as an attachment point for approval gating.
  • No more install -g latest at publish time: the locked @vscode/vsce version is extracted from pnpm-lock.yaml (fails closed on a miss), so packaging and publishing run the same tool version. ovsx is pinned to 1.0.2 (today's latest; not a project dependency, so no lockfile to sync against).
  • PATs passed via VSCE_PAT/OVSX_PAT env vars (read natively by both tools) instead of -p <token> argv, which is world-readable via /proc.

Alternatives considered

  • Full checkout + pnpm install in the publish job to run pnpm vsce publish directly. Pro: zero version extraction. Con: installs hundreds of packages into the one job holding marketplace PATs; larger exfiltration surface. Rejected.
  • Hardcoded vsce version pin. Pro: simplest. Con: drifts from the lockfile silently. Replaced by lockfile extraction.

Important

Admin follow-up: the publish environment auto-creates on first run with no protection rules, so it blocks nothing by itself. Add required reviewers, and ideally move VSCE_PAT/OVSX_PAT into environment secrets so only approved runs can read them.

Intentionally unchanged: pre-release tags remain buildable off main (used for testing); dev-only pnpm audit findings (mocha transitives, unreachable from the shipped extension) are deferred. Dependency provenance for the coder git dependency is handled in #1053.

EhabY added 2 commits July 29, 2026 15:45
- Add least-privilege permissions blocks at workflow and job level so
  jobs only receive the scopes they need (contents: read by default,
  write only where releases are created).
- Set persist-credentials: false on all actions/checkout steps that do
  not push, so the repo-scoped token is not left on disk for later
  steps and node_modules scripts.
- pre-release: verify the release tag commit is an ancestor of
  origin/main before building, preventing releases from tags pointing
  at unreviewed commits.
- publish-extension: gate marketplace publish jobs behind a 'publish'
  environment, pin vsce and ovsx to exact versions instead of
  installing latest at run time, and pass marketplace PATs via env vars
  instead of argv (argv is world-readable via /proc on the runner).
Pre-release tags are intentionally used to test builds without merging
everything to main first, so drop the ancestor check and full fetch;
stable release.yaml keeps its existing tag-on-main verification.
@EhabY
EhabY force-pushed the ci/supply-chain-hardening branch from 75892d1 to f6ec3b7 Compare July 29, 2026 16:02
@EhabY EhabY changed the title ci: harden workflows and override vulnerable transitive dependencies ci: harden GitHub Actions workflows Jul 29, 2026
The setup job extracts the locked @vscode/vsce version from
pnpm-lock.yaml (fails closed on a miss via pipefail) and the
Marketplace publish job installs exactly that version, so packaging
and publishing always run the same tool version.
@EhabY
EhabY force-pushed the ci/supply-chain-hardening branch from 68d43e6 to 8b25074 Compare July 29, 2026 22:02
@EhabY EhabY self-assigned this Jul 29, 2026
@EhabY
EhabY requested a review from jdomeracki-coder July 30, 2026 07:37
@EhabY
EhabY merged commit a63fd13 into main Jul 30, 2026
11 checks passed
@EhabY
EhabY deleted the ci/supply-chain-hardening branch July 30, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants