@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.
@@ -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
- const p = []
155
- for (const node of this.tree.inventory.query('packageName', name)) {
156
- if (!shouldAudit(node, this[_omit], this.filterSet)) {
157
- continue
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
- // if not vulnerable by this advisory, keep searching
161
- if (!advisory.testVersion(node.version)) {
162
- continue
163
- }
155
+ // if not vulnerable by this advisory, keep searching
156
+ if (!advisory.testVersion(node.version)) {
157
+ continue
158
+ }
164
159
 
165
- // we will have loaded the source already if this is a metavuln
166
- if (advisory.type === 'metavuln') {
167
- vuln.addVia(this.get(advisory.dependency))
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
- // already marked this one, no need to do it again
171
- if (vuln.nodes.has(node)) {
172
- continue
173
- }
165
+ // already marked this one, no need to do it again
166
+ if (vuln.nodes.has(node)) {
167
+ continue
168
+ }
174
169
 
175
- // haven't marked this one yet. get its dependents.
176
- vuln.nodes.add(node)
177
- for (const { from: dep, spec } of node.edgesIn) {
178
- if (dep.isTop && !vuln.topNodes.has(dep)) {
179
- this[_checkTopNode](dep, vuln, spec)
180
- } else {
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
- const calc = this.calculator.calculate(dep.packageName, advisory)
183
- p.push(calc.then(meta => {
184
- if (meta.testVersion(dep.version, spec)) {
185
- advisories.add(meta)
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npmcli/arborist",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
4
4
  "description": "Manage node_modules trees",
5
5
  "dependencies": {
6
6
  "@isaacs/string-locale-compare": "^1.1.0",