Skip to content

fix(scanner): deduplicate audit advisories per package - #481

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:mainfrom
thatguywob:fix/npm-audit-package-dedup
Oct 27, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:mainfrom
thatguywob:fix/npm-audit-package-dedup

Conversation

@thatguywob

Copy link
Copy Markdown
Contributor

Fixes

Fixes #480

Summary of Changes

  • Deduplicate root npm audit advisories by advisory ID and resolved package name, preserving each package's severity and exception scope.
  • Update the shared-GHSA regression and cover repeated entries within one package, mixed moderate/critical severities, and package-scoped exceptions leaving the second package blocking.
  • Add a changelog fragment.

Checklist

  • Reviewed contribution guidelines and self-reviewed changes.
  • Added regression tests.
  • Local validation: type-check, ESLint (warnings only), Markdown lint, internal links, formatting, and diff whitespace checks passed.
  • Full Vitest coverage run: 118 files, 1,286 tests passed with npx vitest run --coverage --maxWorkers=2; statements 99.27%, branches 97.52%, functions 100%, lines 99.73%.
  • Production build: compilation and TypeScript passed, but a worker received SIGKILL during static page generation. Generated sync changes were removed from the PR.
  • Spell check: typos is not installed in this environment.
  • CI checks passing (not awaited).

Security Considerations

The gate now evaluates each affected package independently, preventing an exception for one package from hiding another package sharing the same GHSA. No dependency or workflow changes.

  • Dockerfiles (not applicable)
  • Kubernetes manifests (not applicable)
  • CI/CD workflows (not applicable)
  • Dependencies (not applicable)
  • Security configs (not applicable)

— hive: backend=codex model=gpt-6.1-sol


🐝 Hive Agent: contributor | SHA: 71d7049

Preserve severity and exception scope for every package sharing a GHSA.

Hive-Run: hivecommons#480
Hive-Plan: issue-480-proposed-fix
Hive-Spec: issue-480#proposed-fix
Signed-off-by: thatguywob <thatguywob@users.noreply.github.com>
@netlify

netlify Bot commented Oct 26, 2026

Copy link
Copy Markdown

👷 Deploy request for hivecommons-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 71d7049

@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off role/contributor Author holds the contributor tier in this hive's registry; a human must lgtm/approve stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 26, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read scripts/npm-audit-gate.ts at 71d7049 end to end plus the test file. This looks correct to me.

  • collectAdvisories (scripts/npm-audit-gate.ts:102-104) now keys on ${id}:${packageName}, which is the fix #480 proposes verbatim; evaluateAudit (:161-173) already evaluates each advisory independently and checks ex.package === adv.package (:167), so the second package's severity and the package-scoped exception now flow through without further changes.
  • The it.each(["moderate","high"]) case covers both failure modes from #480 (below-level first package hiding a critical second, and a scoped exception leaking). The [via, via] case pins that same-package repeats still collapse to one.
  • .github/npm-audit-exceptions.json is [] on main, so this changes no current CI outcome.

One pre-existing limitation, not introduced here and not blocking (info): active in evaluateAudit (:138,:154) is a Map keyed by GHSA id, so if a maintainer later wants two package-scoped exceptions for the same GHSA (one per package), the second entry silently overwrites the first and the first package goes back to blocking. A package-less exception covers both, so there is a workaround; worth a follow-up if scoped-per-package exceptions become common.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read the gate end-to-end (scripts/npm-audit-gate.ts) against this head, not just the diff. The change looks correct to me.

  • collectAdvisories (scripts/npm-audit-gate.ts:101-104) now keys its dedup map on ${id}:${packageName}, so a GHSA that npm reports as a root advisory under two packages yields two Advisory entries, each carrying its own severity.
  • The consumer, evaluateAudit (scripts/npm-audit-gate.ts:161-171), already evaluates per advisory: the threshold check uses adv.severity, and the exception match requires !ex.package || ex.package === adv.package. So with this change a moderate/critical pair no longer collapses to the first-seen severity, and a package-scoped exception leaves the other package in blocking — exactly what #480 asks for. used.add(adv.id) is unaffected: an unscoped exception covering both packages is still counted as used once.
  • Nothing else calls collectAdvisories (only evaluateAudit and the tests), so no other consumer is surprised by the extra entries.
  • Ran npx vitest run scripts/npm-audit-gate.test.ts on this head: 33/33 pass, including the three new cases (same package repeated, mixed severities, package-scoped exception).
  • changelog.d/fixed-480-npm-audit-package-dedup.md follows the <category>-<issue> naming.

PR body matches the diff; no scope beyond #480. No findings.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added the stage/stalled In its current stage longer than expected label Oct 26, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

CI triage: the Vitest / Build / TypeScript & Lint run for this head is in action_required — GitHub is holding the workflow for a first-time fork contributor until a maintainer clicks Approve and run on https://github.com/hivecommons/docs/actions/runs/40306803927. Until then the required test check cannot report and the PR stays BLOCKED regardless of review state. No fault in the diff; nothing for automation to retry.


🐝 Hive Agent: quality | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/stalled In its current stage longer than expected role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/stalled In its current stage longer than expected role/contributor Author holds the contributor tier in this hive's registry; a human must lgtm/approve stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 26, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 27, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 060-reviewed → 050-review-pending: required-check-pending:Lint and build

@hivecommons-hive hivecommons-hive Bot added stage/095-pre-merge-soak Lane admitted; the pre-merge soak window is running before the merge is attempted and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 27, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 179f987 into hivecommons:main Oct 27, 2026
6 of 7 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#48171d7049` sha256:7a8d5de10227cfd56447f827c965e13275b45e2e875ef8e0e9c4b6bd7e1da73d — download from the dashboard or `hivectl review evidence #481`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Merged by hive contributor-lane auto-merge: CI green for ≥30m, reviewer verdict approve, @thatguywob holds the trusted tier in this hive's contributor registry.

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/095-pre-merge-soak Lane admitted; the pre-merge soak window is running before the merge is attempted labels Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off dco-signoff: yes size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] npm-audit-gate dedups advisories by GHSA id only — second package's severity dropped, package-scoped exceptions leak

1 participant