fix(security): install from the lockfile on the documented setup path - #704
Open
hivecommons-hive[bot] wants to merge 1 commit into
Open
hivecommons-hive[bot] wants to merge 1 commit into
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
Every CI workflow installs with `npm ci`, but README.md, CONTRIBUTING.md, AGENTS.md and the devcontainer's postCreateCommand all told a human to run `npm install`. That command does not read package-lock.json as an instruction: it re-resolves the caret ranges in package.json against the registry, runs the lifecycle scripts of whatever it resolved, and rewrites the lockfile in the contributor's tree. So the documented path installed and executed dependency code that was never reviewed or pinned, skipped the lockfile's integrity hashes, and let a dependency upgrade drift into an unrelated PR. Point all four at `npm ci` and add a regression test to tests/dev-environment.test.mjs that rejects a bare `npm install` in a developer doc or a devcontainer lifecycle command. `npm install <package>` is still the way to add a dependency, so only the bare form is rejected. Closes #703 Signed-off-by: hivecommons-hive[bot] <hivecommons-hive@hive.kubestellar.io>
Contributor
Author
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "sec-check" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security Fix
Every CI workflow installs dependencies with
npm ci—ci.yml:26/:82,deploy-gh-pages.yml:37,import-architectures.yml:27,refresh-community-people.yml:26,refresh-radar-reports.yml:26,pr-queue-hygiene.yml:30. Every contributor-facing entry point told a humanto run
npm installinstead:README.md:37,CONTRIBUTING.md:11,AGENTS.md:43, and.devcontainer/devcontainer.json'spostCreateCommand.npm installdoes not readpackage-lock.jsonas an instruction. It re-resolvesthe semver ranges in
package.jsonagainst the registry, takes whatever isnewest and matching, runs its lifecycle scripts, and rewrites the lockfile. Ten
direct dependencies use caret ranges (
react ^19.3.0,@docusaurus/faster ^3.10.2,prettier ^3.9.8,cspell ^10.3.3,npm-check-updates ^23.1.0,…), so those ranges are open in practice.
The documented setup path therefore installed and executed dependency code that
nobody here reviewed or pinned, across a graph of 1569 packages with install
scripts present in it; skipped the integrity hashes
npm cifails closed on;and let a dependency upgrade drift silently into an unrelated PR, to be
installed faithfully by CI's
npm cion every later run. The devcontainer madeit automatic —
postCreateCommandruns without anyone typing it.The suite already assumed the opposite: the comment at
tests/dev-environment.test.mjs:312-313callsnpm ci"the first documentedsetup step". Nothing actually said that, and nothing failed when a doc said
otherwise.
What this changes
README.md,CONTRIBUTING.md,AGENTS.md— the install step becomesnpm ci, each with one sentence on why, and on usingnpm install <package>deliberately when adding or upgrading a dependency..devcontainer/devcontainer.json—postCreateCommandbecomesnpm ci.tests/dev-environment.test.mjs— new testno developer doc or devcontainer command prescribes a bare npm install,which scans the three docs and all six devcontainer lifecycle hooks. It
matches only the bare form (
\bnpm install\s*(?=$|[\n'"&|;])), sonpm install— still the correct way to add a dependency — passes. It reuses the file's existingstripJsonComments/devcontainerRawhelpers and the lifecycle-key list already used byevery npm script invoked by devcontainer lifecycle commands exists`.No lockfile change:
npm cialready succeeds onmainas-is, so this onlychanges which command people are told to run.
Files and functions claimed by this PR
README.md(install step),CONTRIBUTING.md(development setup),AGENTS.md(Build & Test install bullet).devcontainer/devcontainer.json(postCreateCommand)tests/dev-environment.test.mjs(new test +BARE_NPM_INSTALL)Disjoint from every open hold-gated PR: #676 (
scripts/lib/mdx-active-content.mjs),#684 (
scripts/validate-projects-born.mjs,package.json), #691(
scripts/validate-architecture-assets.mjs), #674 (package.json), and thetest PRs #678/#680/#686/#688/#693/#702, which touch
tests/{import-architectures-fallbacks,svg-active-content,fetch-community-people,validate-*,collect-*,coverage-report-collect}.test.mjs.None touches these five files, and this PR does not touch
package.json.Verification
npm test(runsnpm run checkthen the unit suite) → 1181 pass, 0 failnpm run test:unit:coverage:check→ exit 0 (src files100.00% lines /97.95% regions, unchanged — this PR adds no source file)
postCreateCommandtonpm installfails the new testwith
actual: [ 'devcontainer.postCreateCommand' ]; the doc arm caught a barenpm installcode span during development and was confirmed the same way.Closes #703
Filed by sec-check agent (ACMM L4/L5 — hold-gated mode). Hold-gated: human review required.
— hive: agent=sec-check backend=copilot model=claude-opus-5 copilot=1.0.88