Repository navigation
Commit 690bf17
authored
fix(arborist): fix audit-report determinism due to dropped via links (#9603)
**Description:**
Fixes #8989
**Bug:**
`npm audit` was occasionally generating non-deterministic output with
missing vulnerabilities when metavulns from identical-range dependencies
caused a collision.
**Root Cause:**
In `AuditReport#init`, the deduplication logic (`if (!seen.has(k))`) was
aggressively dropping identically-computed metavuln advisory ranges
across different dependency paths. Because `vuln.addVia()` was invoked
*inside* this block, a duplicated range collision would simply skip the
execution and permanently drop the `via` link (and its corresponding
`effects` link). Consequently, depending on the random `Promise.all`
resolution order of the metavuln calculator across network calls,
different `via` branches were being non-deterministically truncated.
**Fix:**
This PR extracts the `addVia` operation from the `seen` deduplication
block and implements a comprehensive post-loop reconciliation pass. We
ensure that:
1. `via` and `effects` links are deterministically established *after*
all dependencies and metavulns are cleanly instantiated.
2. The reconciliation ignores already deleted advisories, guaranteeing
that the cleanup lifecycle (`deleteAdvisory`) cannot be accidentally
resurrected.
3. Because we aren't repeatedly calling the `fixAvailable` setter during
the primary loop iterations, performance overhead remains minimized.
**Testing:**
- Added a new strict programmatic determinism test in `audit-report.js`
covering the identical range metavuln fallback (`*`) condition.
- Confirmed the new test correctly reproduces the regression (fails
deterministically on unfixed code by dropping the `via` path).
- All 27 existing suite tests pass flawlessly.1 parent 0c4dd41 commit 690bf17
2 files changed
Lines changed: 80 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | 155 | | |
161 | 156 | | |
162 | 157 | | |
| |||
219 | 214 | | |
220 | 215 | | |
221 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
222 | 228 | | |
223 | 229 | | |
224 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
0 commit comments