Repository navigation
fix(scanner): deduplicate audit advisories per package - #481
hivecommons-hive[bot] merged 1 commit into
Conversation
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>
👷 Deploy request for hivecommons-docs pending review.Visit the deploys page to approve it
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
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 checksex.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.jsonis[]onmain, 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
There was a problem hiding this comment.
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 twoAdvisoryentries, each carrying its ownseverity.- The consumer,
evaluateAudit(scripts/npm-audit-gate.ts:161-171), already evaluates per advisory: the threshold check usesadv.severity, and the exception match requires!ex.package || ex.package === adv.package. So with this change amoderate/criticalpair no longer collapses to the first-seen severity, and a package-scoped exception leaves the other package inblocking— 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(onlyevaluateAuditand the tests), so no other consumer is surprised by the extra entries. - Ran
npx vitest run scripts/npm-audit-gate.test.tson 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.mdfollows 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
|
CI triage: the 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
stage 060-reviewed → 050-review-pending: required-check-pending:Lint and build |
|
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. |
Fixes
Fixes #480
Summary of Changes
Checklist
npx vitest run --coverage --maxWorkers=2; statements 99.27%, branches 97.52%, functions 100%, lines 99.73%.typosis not installed in this environment.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.
— hive: backend=codex model=gpt-6.1-sol
🐝 Hive Agent:
contributor| SHA:71d7049