@npmcli/arborist 5.0.5 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/audit-report.js +36 -39
- package/lib/edge.js +5 -0
- package/lib/node.js +3 -0
- package/package.json +1 -1
package/lib/audit-report.js
CHANGED
|
@@ -134,16 +134,7 @@ class AuditReport extends Map {
|
|
|
134
134
|
const seen = new Set()
|
|
135
135
|
for (const advisory of advisories) {
|
|
136
136
|
const { name, range } = advisory
|
|
137
|
-
|
|
138
|
-
// don't flag the exact same name/range more than once
|
|
139
|
-
// adding multiple advisories with the same range is fine, but no
|
|
140
|
-
// need to search for nodes we already would have added.
|
|
141
137
|
const k = `${name}@${range}`
|
|
142
|
-
if (seen.has(k)) {
|
|
143
|
-
continue
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
seen.add(k)
|
|
147
138
|
|
|
148
139
|
const vuln = this.get(name) || new Vuln({ name, advisory })
|
|
149
140
|
if (this.has(name)) {
|
|
@@ -151,44 +142,50 @@ class AuditReport extends Map {
|
|
|
151
142
|
}
|
|
152
143
|
super.set(name, vuln)
|
|
153
144
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
145
|
+
// don't flag the exact same name/range more than once
|
|
146
|
+
// adding multiple advisories with the same range is fine, but no
|
|
147
|
+
// need to search for nodes we already would have added.
|
|
148
|
+
if (!seen.has(k)) {
|
|
149
|
+
const p = []
|
|
150
|
+
for (const node of this.tree.inventory.query('packageName', name)) {
|
|
151
|
+
if (!shouldAudit(node, this[_omit], this.filterSet)) {
|
|
152
|
+
continue
|
|
153
|
+
}
|
|
159
154
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
155
|
+
// if not vulnerable by this advisory, keep searching
|
|
156
|
+
if (!advisory.testVersion(node.version)) {
|
|
157
|
+
continue
|
|
158
|
+
}
|
|
164
159
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
160
|
+
// we will have loaded the source already if this is a metavuln
|
|
161
|
+
if (advisory.type === 'metavuln') {
|
|
162
|
+
vuln.addVia(this.get(advisory.dependency))
|
|
163
|
+
}
|
|
169
164
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
// already marked this one, no need to do it again
|
|
166
|
+
if (vuln.nodes.has(node)) {
|
|
167
|
+
continue
|
|
168
|
+
}
|
|
174
169
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
170
|
+
// haven't marked this one yet. get its dependents.
|
|
171
|
+
vuln.nodes.add(node)
|
|
172
|
+
for (const { from: dep, spec } of node.edgesIn) {
|
|
173
|
+
if (dep.isTop && !vuln.topNodes.has(dep)) {
|
|
174
|
+
this[_checkTopNode](dep, vuln, spec)
|
|
175
|
+
} else {
|
|
181
176
|
// calculate a metavuln, if necessary
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
177
|
+
const calc = this.calculator.calculate(dep.packageName, advisory)
|
|
178
|
+
p.push(calc.then(meta => {
|
|
179
|
+
if (meta.testVersion(dep.version, spec)) {
|
|
180
|
+
advisories.add(meta)
|
|
181
|
+
}
|
|
182
|
+
}))
|
|
183
|
+
}
|
|
188
184
|
}
|
|
189
185
|
}
|
|
186
|
+
await Promise.all(p)
|
|
187
|
+
seen.add(k)
|
|
190
188
|
}
|
|
191
|
-
await Promise.all(p)
|
|
192
189
|
|
|
193
190
|
// make sure we actually got something. if not, remove it
|
|
194
191
|
// this can happen if you are loading from a lockfile created by
|
package/lib/edge.js
CHANGED
|
@@ -215,6 +215,11 @@ class Edge {
|
|
|
215
215
|
|
|
216
216
|
reload (hard = false) {
|
|
217
217
|
this[_explanation] = null
|
|
218
|
+
if (this[_from].overrides) {
|
|
219
|
+
this.overrides = this[_from].overrides.getEdgeRule(this)
|
|
220
|
+
} else {
|
|
221
|
+
delete this.overrides
|
|
222
|
+
}
|
|
218
223
|
const newTo = this[_from].resolve(this.name)
|
|
219
224
|
if (newTo !== this[_to]) {
|
|
220
225
|
if (this[_to]) {
|
package/lib/node.js
CHANGED
|
@@ -792,6 +792,9 @@ class Node {
|
|
|
792
792
|
target.root = root
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
+
if (!this.overrides && this.parent && this.parent.overrides) {
|
|
796
|
+
this.overrides = this.parent.overrides.getNodeRule(this)
|
|
797
|
+
}
|
|
795
798
|
// tree should always be valid upon root setter completion.
|
|
796
799
|
treeCheck(this)
|
|
797
800
|
treeCheck(root)
|