Skip to content

Commit 03de41d

Browse files
committed
chore: fix audit-deps.js script to handle references to vulnerabilities (#2684)
1 parent b4338b5 commit 03de41d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/audit-deps.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ if (auditReport) {
7979
// New npm audit json format introduced in npm v8.
8080
for (const vulnerablePackage of Object.keys(auditReport.vulnerabilities)) {
8181
const item = auditReport.vulnerabilities[vulnerablePackage];
82+
// `item.via` can be either objects or (string) names of vulnerable
83+
// packages in the audit json report. We need to normalize the data so
84+
// that we always deal with a list of objects.
85+
item.via = item.via.reduce((acc, via) => {
86+
if (typeof via === 'object') {
87+
acc.push(via);
88+
} else {
89+
acc.push(...auditReport.vulnerabilities[via].via);
90+
}
91+
92+
return acc;
93+
}, []);
8294

8395
if (item.via.every((via) => exceptions.includes(via.url))) {
8496
ignoredIssues.push(item);

0 commit comments

Comments
 (0)