@@ -84,6 +84,12 @@ var actualAudits = 0;
84
84
* /
85
85
var dependencies = [];
86
86
87
+ /**
88
+ * Map of dependencies to audit. This ensures we only audit a dependency
89
+ * once.
90
+ * /
91
+ var auditLookup = {};
92
+
87
93
/**
88
94
* Count encountered vulnerabilities
89
95
* /
@@ -297,7 +303,15 @@ function getDependencyList(depMap) {
297
303
// Only add a dependency once
298
304
if(lookup[name + o.version] == undefined) {
299
305
lookup[name + o.version] = true;
300
- results.push({"pm": pm, "name": name, "version": o.version});
306
+ // We need both the local and global "auditLookup" tables.
307
+ // The global lookup is used to ensure we only audit a
308
+ // dependency once, but cannot be done at the same level
309
+ // as the local lookup since the sub-dependencies are not
310
+ // available at all locations of the dependency tree (depMap).
311
+ if (auditLookup[name + o.version] == undefined) {
312
+ auditLookup[name + o.version] = true;
313
+ results.push({"pm": pm, "name": name, "version": o.version});
314
+ }
301
315
if(o.dependencies) {
302
316
var deps = getDependencyList(o.dependencies);
303
317
@@ -311,7 +325,10 @@ function getDependencyList(depMap) {
311
325
// Only add a dependency once
312
326
if(lookup[name + o] == undefined) {
313
327
lookup[name + o] = true;
314
- results.push({"pm": pm, "name": name, "version": o});
328
+ if (auditLookup[name + o] == undefined) {
329
+ auditLookup[name + o] = true;
330
+ results.push({"pm": pm, "name": name, "version": o});
331
+ }
315
332
}
316
333
}
317
334
}
0 commit comments