Skip to content

Commit

Permalink
deps: @npmcli/metavuln-calculator@7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Apr 16, 2024
1 parent 6512112 commit 38ed048
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 2 additions & 0 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ graph LR;
npmcli-metavuln-calculator-->cacache;
npmcli-metavuln-calculator-->json-parse-even-better-errors;
npmcli-metavuln-calculator-->pacote;
npmcli-metavuln-calculator-->proc-log;
npmcli-metavuln-calculator-->semver;
npmcli-mock-globals-->npmcli-eslint-config["@npmcli/eslint-config"];
npmcli-mock-globals-->npmcli-template-oss["@npmcli/template-oss"];
Expand Down Expand Up @@ -676,6 +677,7 @@ graph LR;
npmcli-metavuln-calculator-->cacache;
npmcli-metavuln-calculator-->json-parse-even-better-errors;
npmcli-metavuln-calculator-->pacote;
npmcli-metavuln-calculator-->proc-log;
npmcli-metavuln-calculator-->semver;
npmcli-mock-globals-->npmcli-eslint-config["@npmcli/eslint-config"];
npmcli-mock-globals-->npmcli-template-oss["@npmcli/template-oss"];
Expand Down
22 changes: 11 additions & 11 deletions node_modules/@npmcli/metavuln-calculator/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// class handles all the IO with the registry and cache.
const pacote = require('pacote')
const cacache = require('cacache')
const { time } = require('proc-log')
const Advisory = require('./advisory.js')
const { homedir } = require('os')
const jsonParse = require('json-parse-even-better-errors')
Expand Down Expand Up @@ -48,34 +49,33 @@ class Calculator {

async [_calculate] (name, source) {
const k = `security-advisory:${name}:${source.id}`
const t = `metavuln:calculate:${k}`
process.emit('time', t)
const timeEnd = time.start(`metavuln:calculate:${k}`)
const advisory = new Advisory(name, source, this[_options])
// load packument and cached advisory
const [cached, packument] = await Promise.all([
this[_cacheGet](advisory),
this[_packument](name),
])
process.emit('time', `metavuln:load:${k}`)
const timeEndLoad = time.start(`metavuln:load:${k}`)
advisory.load(cached, packument)
process.emit('timeEnd', `metavuln:load:${k}`)
timeEndLoad()
if (advisory.updated) {
await this[_cachePut](advisory)
}
this[_advisories].set(k, advisory)
process.emit('timeEnd', t)
timeEnd()
return advisory
}

async [_cachePut] (advisory) {
const { name, id } = advisory
const key = `security-advisory:${name}:${id}`
process.emit('time', `metavuln:cache:put:${key}`)
const timeEnd = time.start(`metavuln:cache:put:${key}`)
const data = JSON.stringify(advisory)
const options = { ...this[_options] }
this[_cacheData].set(key, jsonParse(data))
await cacache.put(this[_cache], key, data, options).catch(() => {})
process.emit('timeEnd', `metavuln:cache:put:${key}`)
timeEnd()
}

async [_cacheGet] (advisory) {
Expand All @@ -87,12 +87,12 @@ class Calculator {
return this[_cacheData].get(key)
}

process.emit('time', `metavuln:cache:get:${key}`)
const timeEnd = time.start(`metavuln:cache:get:${key}`)
const p = cacache.get(this[_cache], key, { ...this[_options] })
.catch(() => ({ data: '{}' }))
.then(({ data }) => {
data = jsonParse(data)
process.emit('timeEnd', `metavuln:cache:get:${key}`)
timeEnd()
this[_cacheData].set(key, data)
return data
})
Expand All @@ -105,7 +105,7 @@ class Calculator {
return this[_packuments].get(name)
}

process.emit('time', `metavuln:packument:${name}`)
const timeEnd = time.start(`metavuln:packument:${name}`)
const p = pacote.packument(name, { ...this[_options] })
.catch((er) => {
// presumably not something from the registry.
Expand All @@ -116,7 +116,7 @@ class Calculator {
}
})
.then(paku => {
process.emit('timeEnd', `metavuln:packument:${name}`)
timeEnd()
this[_packuments].set(name, paku)
return paku
})
Expand Down
3 changes: 2 additions & 1 deletion node_modules/@npmcli/metavuln-calculator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/metavuln-calculator",
"version": "7.0.1",
"version": "7.1.0",
"main": "lib/index.js",
"files": [
"bin/",
Expand Down Expand Up @@ -42,6 +42,7 @@
"cacache": "^18.0.0",
"json-parse-even-better-errors": "^3.0.0",
"pacote": "^18.0.0",
"proc-log": "^4.1.0",
"semver": "^7.3.5"
},
"engines": {
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1751,13 +1751,14 @@
}
},
"node_modules/@npmcli/metavuln-calculator": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-7.0.1.tgz",
"integrity": "sha512-665lHkHWufnWA3i6H1dJ/EDvK0s0JHrECuBLv/SdLsB53e4v70twsK1baDxatn1pZp7g11HhH80upkfgsBAFFg==",
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-7.1.0.tgz",
"integrity": "sha512-D4VZzVLZ4Mw+oUCWyQ6qzlm5SGlrLnhKtZscDwQXFFc1FUPvw69Ibo2E5ZpJAmjFSYkA5UlCievWmREW0JLC3w==",
"dependencies": {
"cacache": "^18.0.0",
"json-parse-even-better-errors": "^3.0.0",
"pacote": "^18.0.0",
"proc-log": "^4.1.0",
"semver": "^7.3.5"
},
"engines": {
Expand Down Expand Up @@ -16161,7 +16162,7 @@
"@npmcli/fs": "^3.1.0",
"@npmcli/installed-package-contents": "^2.0.2",
"@npmcli/map-workspaces": "^3.0.2",
"@npmcli/metavuln-calculator": "^7.0.1",
"@npmcli/metavuln-calculator": "^7.1.0",
"@npmcli/name-from-folder": "^2.0.0",
"@npmcli/node-gyp": "^3.0.0",
"@npmcli/package-json": "^5.0.3",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/arborist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@npmcli/fs": "^3.1.0",
"@npmcli/installed-package-contents": "^2.0.2",
"@npmcli/map-workspaces": "^3.0.2",
"@npmcli/metavuln-calculator": "^7.0.1",
"@npmcli/metavuln-calculator": "^7.1.0",
"@npmcli/name-from-folder": "^2.0.0",
"@npmcli/node-gyp": "^3.0.0",
"@npmcli/package-json": "^5.0.3",
Expand Down

0 comments on commit 38ed048

Please sign in to comment.