Skip to content

fix(security): split design-system build and publish jobs (#2335) - #2369

Merged
juanresendiz813 merged 3 commits into
developmentfrom
fix/2335-design-system-split
Nov 18, 2026
Merged

juanresendiz813 merged 3 commits into
developmentfrom
fix/2335-design-system-split

Conversation

@buggtb

@buggtb buggtb commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

design-system.yml ran npm ci/build/check and npm publish in one job holding id-token: write, with NPM_TOKEN in env for a publish that still ran lifecycle scripts.

Fix

Mirrors the release.yml embed split (#1992):

  • build job: contents: read only, no registry-url/token, npm ci --ignore-scripts, explicit design-system build, check, verification, registry-exists check, npm pack --ignore-scripts, upload tarball. dry_run runs only this job.
  • publish job: no checkout, no install; downloads the tarball and runs npm publish pkg/*.tgz --access public --provenance --ignore-scripts. Only job with id-token: write; declares environment: npm-publish.
  • Verified locally that npm ci --ignore-scripts + the workspace build + npm run check + npm pack --ignore-scripts all succeed in saiku-ui.
  • docs/ci-overview.md updated.

Maintainer action required (repo settings)

  • Create environment npm-publish with required reviewers and move NPM_TOKEN into it (or enable npm Trusted Publishing for the three packages and delete the token). Until the environment exists GitHub auto-creates it with no protection, so behaviour is unchanged.
  • Rotate NPM_TOKEN (it was exposed to a scripted publish); prefer a granular token limited to the packages.

Not done (follow-up)

dependabot-automerge.mjs still auto-merges npm patch bumps of production deps; changing that eligibility rule (and ci.yml's ui job --ignore-scripts) is a separate policy decision.

Test plan

  • acceptance/2335 command spec: red on base, green on head
  • actionlint .github/workflows/design-system.yml clean
  • node --test .github/scripts/*.test.mjs (401 pass), test_workflow_pins.py
  • workflow_dispatch with dry_run: true shows only the build job (after merge)

Closes #2335

🤖 Generated with Claude Code

buggtb and others added 2 commits November 12, 2026 17:07
…#2335)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The build job runs npm ci --ignore-scripts with no id-token or npm token; the
publish job (environment npm-publish) only downloads the packed tarball and
runs npm publish --ignore-scripts --provenance.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@buggtb buggtb added the security Created by Hive for agent-filed issue provenance label Nov 12, 2026
@github-actions github-actions Bot added risk/high Change risk tier: high (see docs/risk-tiers.md) ci Created by Hive for agent-filed issue provenance docs and removed risk/high Change risk tier: high (see docs/risk-tiers.md) labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown

Semantic model diff

No semantic model changed in this pull request, so there was nothing to diff.
saiku#1434 · reproduce locally with saiku model diff

@juanresendiz813 juanresendiz813 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The split is the right shape and mirrors release.yml: no token, no registry-url and no id-token in the job that runs dependency code. Two one-line fixes before it can merge.

Blocking

  1. blocking · Security · .github/workflows/design-system.yml:169
    The Publish step's script interpolates ${{ needs.build.outputs.version }} directly. That step has NODE_AUTH_TOKEN in its env and runs in the job holding id-token: write, and version comes from the build job this PR labels untrusted. The runner substitutes the value into the script text before bash runs, so anything that controls the build job's output controls a command in the privileged job (reproduced locally with the exact step script and a dummy token). Base passed the version through env, so this is new.
    Would accept: pass it through env: and print "$VERSION", or move the summary to its own step with no token; better, read name and version from the downloaded tarball and check them against a strict pattern. Add an acceptance clause that no run: in the id-token: write job contains ${{.

  2. blocking · Build · design-system.yml:105-109
    npm pack --pack-destination "$RUNNER_TEMP/pack" writes into a directory nothing creates, and npm doesn't create it. Replaying the build job on a clean checkout of this head: install, build, check and verify pass, then npm pack exits 254 with ENOENT (with mkdir -p first it packs 73 files). So every run fails here, including the one the merge triggers.
    Would accept: mkdir -p "$RUNNER_TEMP/pack" before the pack, plus a link to a workflow_dispatch run with dry_run: true from the PR branch (only the unprivileged build job runs, so it's safe pre-merge).

Non-blocking

  • non-blocking · design-system.yml:158-168: publish takes whatever pkg/*.tgz holds, and NPM_TOKEN covers the whole @concepttocloud scope. Check there's exactly one tarball named @concepttocloud/saiku-design-system.
  • non-blocking · design-system.yml:141: the npm-publish environment doesn't exist yet, so GitHub creates it unprotected on first use, and NPM_TOKEN stays a repository secret until moved and rotated (the body notes this).
  • non-blocking · design-system.yml:147: the new setup-node line pins v7.0.0; use #2399's SHA on rebase.

🤖 Generated with Claude Code

@juanresendiz813 juanresendiz813 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. #2421 tracks the follow-ups. One thing to land with or right after this: npm pack --pack-destination "$RUNNER_TEMP/pack" writes to a directory nothing creates, so design-system runs fail until there's a mkdir -p. Please add it together with passing the version via env: rather than ${{ }} interpolation in the publish script; fixing only the mkdir makes that interpolation reachable.

🤖 Generated with Claude Code

…sign-system publish (#2335)

npm pack does not create --pack-destination, so the build job exited 254
(ENOENT) before upload; mkdir -p it first. With that fixed the publish
step becomes reachable, so the build job's version output must not be
interpolated into the privileged script text: pass it through env and
print "$VERSION". Both land together (refs #2421).

Signed-off-by: Juan Resendiz <50384386+juanresendiz813@users.noreply.github.com>
@github-actions github-actions Bot added the risk/high Change risk tier: high (see docs/risk-tiers.md) label Nov 18, 2026
@juanresendiz813
juanresendiz813 added this pull request to the merge queue Nov 18, 2026
Merged via the queue into development with commit e748e30 Nov 18, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Created by Hive for agent-filed issue provenance docs risk/high Change risk tier: high (see docs/risk-tiers.md) security Created by Hive for agent-filed issue provenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[security] design-system.yml runs the untrusted npm lifecycle in the job that holds id-token: write + NPM_TOKEN, and publishes without --ignore-scripts

2 participants