Repository navigation
fix(security): split design-system build and publish jobs (#2335) - #2369
Conversation
…#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>
Semantic model diffNo semantic model changed in this pull request, so there was nothing to diff. |
juanresendiz813
left a comment
There was a problem hiding this comment.
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
-
blocking· Security ·.github/workflows/design-system.yml:169
ThePublishstep's script interpolates${{ needs.build.outputs.version }}directly. That step hasNODE_AUTH_TOKENin its env and runs in the job holdingid-token: write, andversioncomes 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 throughenv, so this is new.
Would accept: pass it throughenv: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 norun:in theid-token: writejob contains${{. -
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, thennpm packexits 254 withENOENT(withmkdir -pfirst 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 aworkflow_dispatchrun withdry_run: truefrom 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 whateverpkg/*.tgzholds, andNPM_TOKENcovers the whole@concepttocloudscope. Check there's exactly one tarball named@concepttocloud/saiku-design-system.non-blocking·design-system.yml:141: thenpm-publishenvironment doesn't exist yet, so GitHub creates it unprotected on first use, andNPM_TOKENstays 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
left a comment
There was a problem hiding this comment.
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>
Summary
design-system.ymlrannpm ci/build/check andnpm publishin one job holdingid-token: write, withNPM_TOKENin env for a publish that still ran lifecycle scripts.Fix
Mirrors the
release.ymlembed split (#1992):buildjob:contents: readonly, noregistry-url/token,npm ci --ignore-scripts, explicit design-system build, check, verification, registry-exists check,npm pack --ignore-scripts, upload tarball.dry_runruns only this job.publishjob: no checkout, no install; downloads the tarball and runsnpm publish pkg/*.tgz --access public --provenance --ignore-scripts. Only job withid-token: write; declaresenvironment: npm-publish.npm ci --ignore-scripts+ the workspace build +npm run check+npm pack --ignore-scriptsall succeed in saiku-ui.Maintainer action required (repo settings)
npm-publishwith required reviewers and moveNPM_TOKENinto 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.NPM_TOKEN(it was exposed to a scripted publish); prefer a granular token limited to the packages.Not done (follow-up)
dependabot-automerge.mjsstill auto-merges npm patch bumps of production deps; changing that eligibility rule (andci.yml'suijob--ignore-scripts) is a separate policy decision.Test plan
acceptance/2335command spec: red on base, green on headactionlint .github/workflows/design-system.ymlcleannode --test .github/scripts/*.test.mjs(401 pass),test_workflow_pins.pyworkflow_dispatchwithdry_run: trueshows only the build job (after merge)Closes #2335
🤖 Generated with Claude Code