Repository navigation
ci: enforce npm ci on Studio install paths (follow-up to #5604) - #5616
Conversation
PR #5604 committed three npm lockfiles (studio/, studio/frontend/, studio/backend/core/data_recipe/oxc-validator/) but the install paths still ran `npm install` -- mutates the lockfile, ignores integrity hashes. Flip them to `npm ci`, which is non-mutating and refuses to run unless the committed package-lock.json matches the dependency tree byte-for-byte. This closes the gap between "the lockfile passes the audit" and "the install respected that lockfile". For bun: gate every `bun install` on `[ -f bun.lock ]` (Test-Path on Windows) plus `command -v bun` (Get-Command), and add `--frozen-lockfile --no-progress` to the bun invocation. No bun.lock is committed in this PR, so the gate fails closed today and execution falls through to `npm ci`. When the eventual bun.lock PR lands, the gate auto-activates with no further script edits. Existing bun infrastructure (cache-corruption retry + critical-binary verification + npm fallback) is kept intact so the auto-upgrade is clean. Deliberately NOT introducing _BUN_PIN_VERSION or the 3-attempt cache-corruption recovery ladder; both require committed bun.lock to be useful. Touches three files only: - build.sh - studio/setup.sh - studio/setup.ps1
Point the existing audit + install + content-sanity workflows at the two lockfiles PR #5604 introduced (studio/package-lock.json and studio/backend/core/data_recipe/oxc-validator/package-lock.json) so the Studio Tauri CLI holder and the oxc-validator runtime benefit from the same per-PR coverage the frontend already has. release-desktop.yml: - Tauri CLI install: `npm install --save-dev --prefix studio` -> `npm ci --prefix studio --no-fund --no-audit`. - Frontend install: `npm install --no-fund --no-audit` -> `npm ci --no-fund --no-audit`. - New "Lockfile supply-chain audit" step inserted BEFORE the Tauri CLI install so the structural audit fires before any tarball-side lifecycle script. studio-tauri-smoke.yml: - Tauri CLI install: `npm install --save-dev --prefix studio` -> `npm ci --prefix studio --no-fund --no-audit`. - Existing audit step relocated to run BEFORE the Tauri CLI install (same ordering rationale). wheel-smoke.yml: - One-line content-sanity assertion ensuring the oxc-validator package-lock.json is shipped in the wheel. security-audit.yml: - `paths` trigger gains the 4 new entries (oxc + Tauri CLI holder package.json + package-lock.json). - `Scanned:` summary string updated to list the two new lockfiles. - OSV-scanner picks up `--lockfile=` for both. - Two new `npm audit` steps: oxc-validator runtime + Studio Tauri CLI holder. - `npm audit signatures` block split into three (frontend / oxc / Tauri CLI), each preceded by `npm ci --ignore-scripts` in its own directory. - `check_new_install_scripts.py` invocation extended to diff both new lockfiles base->head, with `git show ... 2>/dev/null || echo '{}'` fallback for PRs whose base predates #5604. - `upload-artifact` paths extended for the new log files. Deliberately NOT included: removing `continue-on-error` from the existing `scan_npm_packages` job. That is a policy flip from advisory to blocking and is orthogonal to install-path hardening.
…t install paths main rewrote every file this PR touched. Kept main's side and re-derived the change: - setup.sh, setup.ps1, build.sh: npm ci when package-lock.json exists (npm install only as the no-lockfile fallback, as docker/unsloth_studio_update.sh does), including the npmmirror retry; bun only with a committed bun.lock, --frozen-lockfile. - release-desktop, studio-tauri-smoke, desktop-app-clean-machine-ci: Tauri CLI via npm ci --prefix studio instead of npm install --save-dev; release frontend via npm ci. - security-audit: npm audit, OSV, audit signatures and install-script diff cover the oxc-validator and Tauri CLI lockfiles. - wheel-smoke asserts the oxc-validator lockfile ships. - tests/studio/test_installers_npm_ci.py, mirror retry case for npm ci.
bun.lock is gitignored and earlier bun installs wrote one, so gating bun on its existence picked bun --frozen-lockfile over an old graph instead of npm ci.
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a006dff3f9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if command -v bun &>/dev/null; then | ||
| _NPM_INSTALL=install | ||
| [ -f package-lock.json ] && _NPM_INSTALL=ci | ||
| if [ ! -f package-lock.json ] && [ -f bun.lock ] && command -v bun &>/dev/null; then |
There was a problem hiding this comment.
Gate Bun provisioning before forcing npm ci
When a local/source install needs a frontend rebuild and selects bundled Node, the earlier block still runs npm install -g bun --allow-scripts=bun; with the committed package-lock.json, this new condition is always false, so setup immediately uses npm ci instead. This makes every first such setup download and execute Bun's postinstall without ever using Bun, adding avoidable latency and network-failure exposure. Apply the same lockfile/Bun-lock condition to Bun provisioning, including the analogous block in setup.ps1.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 238efa3: setup.sh and setup.ps1 skip the global bun install when frontend/package-lock.json exists, since the frontend then installs with npm ci.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Summary
Follow-up to #5604. The three Studio lockfiles (
studio/frontend,studio/backend/core/data_recipe/oxc-validator,studio) are committed and audited, but the installers and two desktop workflows still rannpm install, which rewrites the lockfile whenpackage.jsondrifts and installs whatever the drift asks for. This switches those paths tonpm ci, which installs exactly the audited lockfile or fails.Rebased onto current main by merge (main had rewritten every touched file since May); #5695 already moved the lockfile audit ahead of the installs, so that part is dropped here.
Changes
studio/setup.sh,studio/setup.ps1,build.sh: frontend and OXC validator installs usenpm ciwhenpackage-lock.jsonis present,npm installonly when it is absent (same rule asdocker/unsloth_studio_update.sh). The npmmirror fallback retry uses the same verb.package-lock.jsonalways decides the install. bun runs only when there is none and abun.lockexists (--frozen-lockfile):bun.lockis gitignored and earlier bun installs left one behind, so it must not outrank the audited npm lockfile. On a driftedpackage.json,bun install(1.4.2 tested) installs the extra dependency and writes a newbun.lock, likenpm install.release-desktop.yml,studio-tauri-smoke.yml,desktop-app-clean-machine-ci.yml: Tauri CLI vianpm ci --prefix studio(thestudio/package.jsonlockfile holder exists for exactly this) instead ofnpm install --save-dev [email protected]; release frontend vianpm ci.security-audit.yml:npm audit, OSV scanner,npm audit signaturesand the new-install-script diff now also cover the oxc-validator and Tauri CLI lockfiles.wheel-smoke.yml: asserts the oxc-validatorpackage-lock.jsonships in the wheel (the installers runnpm ciagainst it in site-packages).tests/studio/test_installers_npm_ci.py(3 of 4 fail on main), plus a mirror-retry case intests/sh/test_mirror_fallback.sh.Verification
npm cion all three lockfiles at this head: succeeds, lockfiles byte-identical afterwards,tauri-cli 2.10.1, oxc native bindings present.package.json(extra dependency):npm installexits 0, rewrites the lockfile and installs the extra package;npm ciexits 1 withEUSAGEand installs nothing.tests/security,tests/studio,tests/python,tests/test_*.pyon main vs this head: no head-only failures (the 18 failures on both sides are environment-related).tests/sh/test_mirror_fallback.sh253/253,tests/sh/test_system_node_readonly.shpass.Behaviour note:
npm ciremoves an existingnode_modulesbefore installing, so re-running setup reinstalls the frontend and validator dependencies from scratch instead of reusing them.