test: assert package.json overrides are enforced in package-lock.json (tests/lockfile-overrides.test.mjs) - #324
Open
kubestellar-hive[bot] wants to merge 1 commit into
Open
kubestellar-hive[bot] wants to merge 1 commit into
kubestellar-hive[bot] wants to merge 1 commit into
Conversation
npm ci exits 0 against a lockfile whose root records no overrides, so an override floor raised in package.json without regenerating the lockfile silently keeps installing the version the override was added to eliminate. Adds tests/lockfile-overrides.test.mjs, which asserts every override selector resolves to a real package and no installed instance sits below its floor, following Node's nested-then-hoisted resolution order for nested overrides. Closes #323 Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
Contributor
Author
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" 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 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.
Test Improvement
Adds one test-only file,
tests/lockfile-overrides.test.mjs(5 tests),asserting that the
overridesblock inpackage.jsonis actually enforced bythe resolved tree in
package-lock.json.Files claimed by this PR:
tests/lockfile-overrides.test.mjs(new).Nothing else — no production code, no workflow, no
package.json, nolockfile, no new dependency.
The gap
All 7 overrides exist to hold a transitive dependency at or above a version
that fixes a known advisory. Nothing verifies that they work.
npm cidoesnot: copying only the two manifests into an empty directory at
00b44dfandrunning
npm ci --ignore-scriptsexits 0 even though the lockfile's rootpackages[""]entry records nooverrideskey whilepackage.jsondeclaresall 7. So raising an override floor without regenerating the lockfile leaves CI
installing the vulnerable version, green and silent.
What the 5 tests assert
lockfileVersion >= 3,nameandversionagree, and it lists a non-zero number of packages.package.jsondeclares a non-emptyoverridesblock, so nothing below canpass vacuously if it is dropped or renamed.
parent > childoverride resolves to one — catching a typo'd or staleoverride that pins nothing.
Node's resolution order (own
node_modules, then each enclosing one).Two deliberate design notes, both to avoid a test that looks strict but is not:
tinyglobbydeclarespicomatch ^4.0.4,which
^2.3.2cannot satisfy, so npm gives it a nestedpicomatch@4.0.5.That is benign — 4.0.5 is above the floor, the advisory intent holds — but an
equality assertion would be red against
mainfor a dependency that is fine.The floor is the invariant the overrides actually encode.
sockjs > uuidis hoisted tonode_modules/uuidin the current tree. A test that looked only for
node_modules/sockjs/node_modules/uuidwould find nothing and passvacuously; test 3 fails loudly instead.
semveris not a declared devDependency, so the floor is parsed directly andany range form the test does not understand fails the run rather than being
skipped.
Verification
Local clone of
cncf/endusersat00b44dfafternpm ci, node v26.8.2.node --test: 60 pass, 0 fail (55 before; the 5 new tests are the delta).npx prettier --check tests/lockfile-overrides.test.mjs: clean.Mutation-checked — an assertion that cannot fail is not a test. Five
deliberate breakages, each reverted, each caught by exactly one assertion:
serialize-javascript7.1.0 → 7.0.1joi-typomatching nothingsockjs > uuidfloor →^12.0.0overridesblocklatestBaseline re-verified green after each revert.
Disjointness from open PRs
tests/workflow-scripts.test.mjs) readspackage.jsonbut onlyits
scriptsblock; it never readsoverridesand never openspackage-lock.json.[sec-check], adds aqsoverride) editspackage.jsonandpackage-lock.jsonand ships no test. This PR touches neither manifest, sothere is no file overlap — and once [sec-check] fix: override qs to ^6.16.0 (package.json overrides + package-lock.json) #191 lands, these assertions are what
verify its override took effect in the lockfile.
package-lock.json.Related Issue
Closes #323
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5