@npmcli/arborist 8.0.0 → 9.0.0-pre.0
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/arborist/rebuild.js +3 -1
- package/lib/audit-report.js +16 -86
- package/package.json +7 -7
package/lib/arborist/rebuild.js
CHANGED
|
@@ -154,7 +154,9 @@ module.exports = cls => class Builder extends cls {
|
|
|
154
154
|
|
|
155
155
|
// links should run prepare scripts and only link bins after that
|
|
156
156
|
if (type === 'links') {
|
|
157
|
-
|
|
157
|
+
if (!this.options.ignoreScripts) {
|
|
158
|
+
await this.#runScripts('prepare')
|
|
159
|
+
}
|
|
158
160
|
}
|
|
159
161
|
if (this.options.binLinks) {
|
|
160
162
|
await this.#linkAllBins()
|
package/lib/audit-report.js
CHANGED
|
@@ -274,33 +274,6 @@ class AuditReport extends Map {
|
|
|
274
274
|
throw new Error('do not call AuditReport.set() directly')
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
// convert a quick-audit into a bulk advisory listing
|
|
278
|
-
static auditToBulk (report) {
|
|
279
|
-
if (!report.advisories) {
|
|
280
|
-
// tack on the report json where the response body would go
|
|
281
|
-
throw Object.assign(new Error('Invalid advisory report'), {
|
|
282
|
-
body: JSON.stringify(report),
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const bulk = {}
|
|
287
|
-
const { advisories } = report
|
|
288
|
-
for (const advisory of Object.values(advisories)) {
|
|
289
|
-
const {
|
|
290
|
-
id,
|
|
291
|
-
url,
|
|
292
|
-
title,
|
|
293
|
-
severity = 'high',
|
|
294
|
-
vulnerable_versions = '*',
|
|
295
|
-
module_name: name,
|
|
296
|
-
} = advisory
|
|
297
|
-
bulk[name] = bulk[name] || []
|
|
298
|
-
bulk[name].push({ id, url, title, severity, vulnerable_versions })
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return bulk
|
|
302
|
-
}
|
|
303
|
-
|
|
304
277
|
async [_getReport] () {
|
|
305
278
|
// if we're not auditing, just return false
|
|
306
279
|
if (this.options.audit === false || this.options.offline === true || this.tree.inventory.size === 1) {
|
|
@@ -309,39 +282,24 @@ class AuditReport extends Map {
|
|
|
309
282
|
|
|
310
283
|
const timeEnd = time.start('auditReport:getReport')
|
|
311
284
|
try {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const body = prepareBulkData(this.tree, this[_omit], this.filterSet)
|
|
315
|
-
log.silly('audit', 'bulk request', body)
|
|
316
|
-
|
|
317
|
-
// no sense asking if we don't have anything to audit,
|
|
318
|
-
// we know it'll be empty
|
|
319
|
-
if (!Object.keys(body).length) {
|
|
320
|
-
return null
|
|
321
|
-
}
|
|
285
|
+
const body = prepareBulkData(this.tree, this[_omit], this.filterSet)
|
|
286
|
+
log.silly('audit', 'bulk request', body)
|
|
322
287
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
gzip: true,
|
|
328
|
-
body,
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
return await res.json()
|
|
332
|
-
} catch (er) {
|
|
333
|
-
log.silly('audit', 'bulk request failed', String(er.body))
|
|
334
|
-
// that failed, try the quick audit endpoint
|
|
335
|
-
const body = prepareData(this.tree, this.options)
|
|
336
|
-
const res = await fetch('/-/npm/v1/security/audits/quick', {
|
|
337
|
-
...this.options,
|
|
338
|
-
registry: this.options.auditRegistry || this.options.registry,
|
|
339
|
-
method: 'POST',
|
|
340
|
-
gzip: true,
|
|
341
|
-
body,
|
|
342
|
-
})
|
|
343
|
-
return AuditReport.auditToBulk(await res.json())
|
|
288
|
+
// no sense asking if we don't have anything to audit,
|
|
289
|
+
// we know it'll be empty
|
|
290
|
+
if (!Object.keys(body).length) {
|
|
291
|
+
return null
|
|
344
292
|
}
|
|
293
|
+
|
|
294
|
+
const res = await fetch('/-/npm/v1/security/advisories/bulk', {
|
|
295
|
+
...this.options,
|
|
296
|
+
registry: this.options.auditRegistry || this.options.registry,
|
|
297
|
+
method: 'POST',
|
|
298
|
+
gzip: true,
|
|
299
|
+
body,
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
return await res.json()
|
|
345
303
|
} catch (er) {
|
|
346
304
|
log.verbose('audit error', er)
|
|
347
305
|
log.silly('audit error', String(er.body))
|
|
@@ -384,32 +342,4 @@ const prepareBulkData = (tree, omit, filterSet) => {
|
|
|
384
342
|
return payload
|
|
385
343
|
}
|
|
386
344
|
|
|
387
|
-
const prepareData = (tree, opts) => {
|
|
388
|
-
const { npmVersion: npm_version } = opts
|
|
389
|
-
const node_version = process.version
|
|
390
|
-
const { platform, arch } = process
|
|
391
|
-
const { NODE_ENV: node_env } = process.env
|
|
392
|
-
const data = tree.meta.commit()
|
|
393
|
-
// the legacy audit endpoint doesn't support any kind of pre-filtering
|
|
394
|
-
// we just have to get the advisories and skip over them in the report
|
|
395
|
-
return {
|
|
396
|
-
name: data.name,
|
|
397
|
-
version: data.version,
|
|
398
|
-
requires: {
|
|
399
|
-
...(tree.package.devDependencies || {}),
|
|
400
|
-
...(tree.package.peerDependencies || {}),
|
|
401
|
-
...(tree.package.optionalDependencies || {}),
|
|
402
|
-
...(tree.package.dependencies || {}),
|
|
403
|
-
},
|
|
404
|
-
dependencies: data.dependencies,
|
|
405
|
-
metadata: {
|
|
406
|
-
node_version,
|
|
407
|
-
npm_version,
|
|
408
|
-
platform,
|
|
409
|
-
arch,
|
|
410
|
-
node_env,
|
|
411
|
-
},
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
345
|
module.exports = AuditReport
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/arborist",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-pre.0",
|
|
4
4
|
"description": "Manage node_modules trees",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@isaacs/string-locale-compare": "^1.1.0",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"cacache": "^19.0.1",
|
|
19
19
|
"common-ancestor-path": "^1.0.1",
|
|
20
20
|
"hosted-git-info": "^8.0.0",
|
|
21
|
-
"json-parse-even-better-errors": "^4.0.0",
|
|
22
21
|
"json-stringify-nice": "^1.1.4",
|
|
23
22
|
"lru-cache": "^10.2.2",
|
|
24
23
|
"minimatch": "^9.0.4",
|
|
@@ -27,7 +26,7 @@
|
|
|
27
26
|
"npm-package-arg": "^12.0.0",
|
|
28
27
|
"npm-pick-manifest": "^10.0.0",
|
|
29
28
|
"npm-registry-fetch": "^18.0.1",
|
|
30
|
-
"pacote": "^
|
|
29
|
+
"pacote": "^20.0.0",
|
|
31
30
|
"parse-conflict-json": "^4.0.0",
|
|
32
31
|
"proc-log": "^5.0.0",
|
|
33
32
|
"proggy": "^3.0.0",
|
|
@@ -41,7 +40,8 @@
|
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"@npmcli/eslint-config": "^5.0.1",
|
|
44
|
-
"@npmcli/
|
|
43
|
+
"@npmcli/mock-registry": "^1.0.0",
|
|
44
|
+
"@npmcli/template-oss": "4.23.5",
|
|
45
45
|
"benchmark": "^2.1.4",
|
|
46
46
|
"minify-registry-metadata": "^4.0.0",
|
|
47
47
|
"nock": "^13.3.3",
|
|
@@ -82,18 +82,18 @@
|
|
|
82
82
|
"test-env": [
|
|
83
83
|
"LC_ALL=sk"
|
|
84
84
|
],
|
|
85
|
-
"timeout": "
|
|
85
|
+
"timeout": "720",
|
|
86
86
|
"nyc-arg": [
|
|
87
87
|
"--exclude",
|
|
88
88
|
"tap-snapshots/**"
|
|
89
89
|
]
|
|
90
90
|
},
|
|
91
91
|
"engines": {
|
|
92
|
-
"node": "^
|
|
92
|
+
"node": "^20.17.0 || >=22.9.0"
|
|
93
93
|
},
|
|
94
94
|
"templateOSS": {
|
|
95
95
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
96
|
-
"version": "4.23.
|
|
96
|
+
"version": "4.23.5",
|
|
97
97
|
"content": "../../scripts/template-oss/index.js"
|
|
98
98
|
}
|
|
99
99
|
}
|