Skip to content

fix(audit): respect package.json overrides in vulnerability checks#32878

Merged
bartlomieju merged 2 commits intomainfrom
fix/audit-overrides
Mar 21, 2026
Merged

fix(audit): respect package.json overrides in vulnerability checks#32878
bartlomieju merged 2 commits intomainfrom
fix/audit-overrides

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

Closes #32871

When package.json overrides force a transitive dependency to a patched version, deno audit was still reporting it as vulnerable. For example:

{
  "dependencies": { "@vitest/ui": "^4.1.0" },
  "overrides": { "flatted": "3.4.2" }
}

The override correctly resolves flatted to 3.4.2 (visible in the lockfile), but deno audit still reported the vulnerability for flatted < 3.4.2.

Root cause

The npm audit API returns advisories based on the declared dependency tree, not the resolved versions after overrides. Deno was passing all advisories through without checking if the actually-installed version falls within the vulnerable range.

Fix

After receiving advisories from the npm audit API, filter out any where no installed version actually falls within the vulnerable_versions range. Uses the finding paths to identify actual package names and cross-references with the resolution snapshot.

Test plan

  • Added tests/specs/audit/overrides spec test
  • All 12 audit tests pass (11 existing + 1 new)

🤖 Generated with Claude Code

bartlomieju and others added 2 commits March 20, 2026 17:25
…32871)

When package.json overrides force a transitive dependency to a
patched version, `deno audit` was still reporting it as vulnerable.
This happened because the npm audit API returns advisories based on
the declared dependency tree, not the resolved versions after
overrides are applied.

Fix: after receiving advisories from the npm audit API, filter out
any where no installed version actually falls within the advisory's
vulnerable_versions range. Uses the finding paths to identify the
actual package names and cross-references with the resolution
snapshot's installed versions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes deno audit false positives when package.json overrides (or similar resolution behavior) forces a transitive dependency to a non-vulnerable version, by filtering npm audit advisories against the actually-resolved versions in the NpmResolutionSnapshot.

Changes:

  • Filter npm audit advisories where no resolved/installed package version matches the advisory’s vulnerable_versions range.
  • Add a spec regression test covering an overridden transitive dependency that would otherwise be reported as vulnerable.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
cli/tools/pm/audit.rs Filters advisories using the resolution snapshot to avoid reporting vulnerabilities for packages that are resolved to patched versions via overrides.
tests/specs/audit/overrides/test.jsonc Adds a regression spec test that runs install then audit for an overrides scenario.
tests/specs/audit/overrides/package.json Defines a dependency that pulls a vulnerable transitive package, then overrides it to a patched version.
tests/specs/audit/overrides/audit.out Asserts the audit output reports no known vulnerabilities after overrides are applied.

@bartlomieju bartlomieju merged commit 8b14d5a into main Mar 21, 2026
116 checks passed
@bartlomieju bartlomieju deleted the fix/audit-overrides branch March 21, 2026 09:01
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.

Deno Audit doesn't honor overrides property

2 participants