Skip to content

fix: make the npm vulnerability gate see dev dependencies - #67

Merged
stxkxs merged 1 commit into
mainfrom
fix/trivy-dev-dependency-coverage
Aug 8, 2026
Merged

fix: make the npm vulnerability gate see dev dependencies#67
stxkxs merged 1 commit into
mainfrom
fix/trivy-dev-dependency-coverage

Conversation

@stxkxs

@stxkxs stxkxs commented Aug 8, 2026

Copy link
Copy Markdown
Member

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:

INFO  Suppressing dependencies for development and testing.
      To display them, try the '--include-dev-deps' flag.

The severity logic, the ignore-unfixed policy and the exit-code wiring were all correct. The package set they were applied to was short.

What was hidden

severity package fix advisory
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.

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_DEPS is set at job level so the report step and the gate step inherit one value and cannot drift apart. It is an env var because trivy-action exposes 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-action moves from @master to 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.

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.
@stxkxs
stxkxs merged commit 59fcb59 into main Aug 8, 2026
16 checks passed
@stxkxs
stxkxs deleted the fix/trivy-dev-dependency-coverage branch August 8, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant