fix: make the npm vulnerability gate see dev dependencies - #67
Merged
Conversation
The trivy filesystem job is named for npm dependency coverage and is wired to fail the build on a fixable HIGH or CRITICAL. It reported zero while the lockfile carried one. Trivy's npm parser drops dev dependencies unless told otherwise. It says so on every run — "Suppressing dependencies for development and testing" — and the job read the resulting empty result set as a clean bill of health. Everything about the gate was right except the set of packages it was looking at. What it could not see: HIGH nanoid@3.3.16 -> 3.3.17 CVE-2026-67213 / GHSA-2v37-7h3g-55p8 A custom generator loops forever when asked for a size of zero. nanoid arrives through postcss. Sibling repositories scanning the same shape of tree with osv-scanner count dev dependencies and went red on this advisory: one package, one version, two scanners, opposite verdicts. ─── Coverage ─── TRIVY_INCLUDE_DEV_DEPS is set at job level so the report step and the gate step inherit one value and cannot drift apart. It is an environment variable because trivy-action exposes no input for the flag. A build-time package is not out of scope. It executes in CI holding this repository's credentials, which is the surface the gate exists to watch. ─── Remediation ─── An override floors nanoid at ^3.3.17. The caret is deliberate: an open-ended `>=` floor resolves to nanoid 6, which is ESM-only and is not the API postcss calls. The lockfile change touches nanoid and nothing else. ─── Action pinning ─── trivy-action moves from @master to the v0.36.0 commit. A mutable branch ref means the scanner deciding whether this repository ships is fetched from wherever that branch points on the day, which is a strange place to accept unpinned input. The same action is pinned by digest elsewhere in the org. Verified with the gate's own arguments — HIGH/CRITICAL, ignore-unfixed, dev dependencies included: one finding before the override, none after.
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.
The gate reported zero because it was not looking
The trivy filesystem job is named for npm dependency coverage and fails the build on a fixable HIGH or CRITICAL. It reported nothing while the lockfile carried a fixable HIGH.
Trivy's npm parser drops dev dependencies unless told otherwise, and announces it on every run:
The severity logic, the
ignore-unfixedpolicy and the exit-code wiring were all correct. The package set they were applied to was short.What was hidden
nanoid@3.3.163.3.17A custom generator loops forever when asked for a size of zero. nanoid arrives through postcss.
Worth noting how this surfaced: the repos scanning the same shape of tree with osv-scanner count dev dependencies and went red on this exact advisory. Same package, same version, two scanners, opposite verdicts inside one org. Whichever policy is right, it should not depend on which tool a repo happens to use.
Changes
Coverage.
TRIVY_INCLUDE_DEV_DEPSis set at job level so the report step and the gate step inherit one value and cannot drift apart. It is an env var becausetrivy-actionexposes no input for the flag.A build-time dependency is not out of scope. It executes in CI holding this repository's credentials — the surface this gate exists to watch.
Remediation. An override floors nanoid at
^3.3.17. The caret is deliberate: an open>=floor resolves to nanoid 6, which is ESM-only and is not the API postcss calls. The lockfile diff touches nanoid and nothing else.Pinning.
trivy-actionmoves from@masterto the v0.36.0 commit. A mutable branch ref means the scanner that decides whether this repo ships is pulled from wherever that branch points on the day. The same action is already pinned by digest elsewhere in the org.Verification
Run with the gate's own arguments —
HIGH,CRITICAL,ignore-unfixed, dev deps included — one finding before the override, zero after. The flag was confirmed to work by A/B rather than assumed from the naming convention: without it the scan returns 0, with it the nanoid HIGH appears.