diff --git a/node_modules/.gitignore b/node_modules/.gitignore index 380d0b268bf7f..2075e41dc40b5 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -158,11 +158,6 @@ !/npm-pick-manifest !/npm-profile !/npm-registry-fetch -!/npm-registry-fetch/node_modules/ -/npm-registry-fetch/node_modules/* -!/npm-registry-fetch/node_modules/@npmcli/ -/npm-registry-fetch/node_modules/@npmcli/* -!/npm-registry-fetch/node_modules/@npmcli/redact !/npm-user-validate !/p-map !/pacote diff --git a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/deep-map.js b/node_modules/@npmcli/redact/lib/deep-map.js similarity index 100% rename from node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/deep-map.js rename to node_modules/@npmcli/redact/lib/deep-map.js diff --git a/node_modules/@npmcli/redact/lib/index.js b/node_modules/@npmcli/redact/lib/index.js index e5b5e74157c2a..9b10c7f6a0081 100644 --- a/node_modules/@npmcli/redact/lib/index.js +++ b/node_modules/@npmcli/redact/lib/index.js @@ -1,29 +1,15 @@ -const { URL } = require('url') +const matchers = require('./matchers') +const { redactUrlPassword } = require('./utils') const REPLACE = '***' -const TOKEN_REGEX = /\bnpm_[a-zA-Z0-9]{36}\b/g -const GUID_REGEX = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/g const redact = (value) => { if (typeof value !== 'string' || !value) { return value } - - let urlValue - try { - urlValue = new URL(value) - } catch { - // If it's not a URL then we can ignore all errors - } - - if (urlValue?.password) { - urlValue.password = REPLACE - value = urlValue.toString() - } - - return value - .replace(TOKEN_REGEX, `npm_${REPLACE}`) - .replace(GUID_REGEX, REPLACE) + return redactUrlPassword(value, REPLACE) + .replace(matchers.NPM_SECRET.pattern, `npm_${REPLACE}`) + .replace(matchers.UUID.pattern, REPLACE) } // split on \s|= similar to how nopt parses options @@ -49,7 +35,6 @@ const redactLog = (arg) => { } else if (Array.isArray(arg)) { return arg.map((a) => typeof a === 'string' ? splitAndRedact(a) : a) } - return arg } diff --git a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/matchers.js b/node_modules/@npmcli/redact/lib/matchers.js similarity index 100% rename from node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/matchers.js rename to node_modules/@npmcli/redact/lib/matchers.js diff --git a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/server.js b/node_modules/@npmcli/redact/lib/server.js similarity index 100% rename from node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/server.js rename to node_modules/@npmcli/redact/lib/server.js diff --git a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/utils.js b/node_modules/@npmcli/redact/lib/utils.js similarity index 100% rename from node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/utils.js rename to node_modules/@npmcli/redact/lib/utils.js diff --git a/node_modules/@npmcli/redact/package.json b/node_modules/@npmcli/redact/package.json index 1fc64a4c02f28..2bcee9ea0884b 100644 --- a/node_modules/@npmcli/redact/package.json +++ b/node_modules/@npmcli/redact/package.json @@ -1,8 +1,13 @@ { "name": "@npmcli/redact", - "version": "1.1.0", + "version": "2.0.0", "description": "Redact sensitive npm information from output", "main": "lib/index.js", + "exports": { + ".": "./lib/index.js", + "./server": "./lib/server.js", + "./package.json": "./package.json" + }, "scripts": { "test": "tap", "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"", @@ -32,7 +37,8 @@ "nyc-arg": [ "--exclude", "tap-snapshots/**" - ] + ], + "timeout": 120 }, "devDependencies": { "@npmcli/eslint-config": "^4.0.2", diff --git a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/LICENSE b/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/LICENSE deleted file mode 100644 index c21644115c85d..0000000000000 --- a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 npm - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/index.js b/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/index.js deleted file mode 100644 index 9b10c7f6a0081..0000000000000 --- a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -const matchers = require('./matchers') -const { redactUrlPassword } = require('./utils') - -const REPLACE = '***' - -const redact = (value) => { - if (typeof value !== 'string' || !value) { - return value - } - return redactUrlPassword(value, REPLACE) - .replace(matchers.NPM_SECRET.pattern, `npm_${REPLACE}`) - .replace(matchers.UUID.pattern, REPLACE) -} - -// split on \s|= similar to how nopt parses options -const splitAndRedact = (str) => { - // stateful regex, don't move out of this scope - const splitChars = /[\s=]/g - - let match = null - let result = '' - let index = 0 - while (match = splitChars.exec(str)) { - result += redact(str.slice(index, match.index)) + match[0] - index = splitChars.lastIndex - } - - return result + redact(str.slice(index)) -} - -// replaces auth info in an array of arguments or in a strings -const redactLog = (arg) => { - if (typeof arg === 'string') { - return splitAndRedact(arg) - } else if (Array.isArray(arg)) { - return arg.map((a) => typeof a === 'string' ? splitAndRedact(a) : a) - } - return arg -} - -module.exports = { - redact, - redactLog, -} diff --git a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/package.json b/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/package.json deleted file mode 100644 index 2bcee9ea0884b..0000000000000 --- a/node_modules/npm-registry-fetch/node_modules/@npmcli/redact/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "@npmcli/redact", - "version": "2.0.0", - "description": "Redact sensitive npm information from output", - "main": "lib/index.js", - "exports": { - ".": "./lib/index.js", - "./server": "./lib/server.js", - "./package.json": "./package.json" - }, - "scripts": { - "test": "tap", - "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"", - "postlint": "template-oss-check", - "template-oss-apply": "template-oss-apply --force", - "lintfix": "npm run lint -- --fix", - "snap": "tap", - "posttest": "npm run lint" - }, - "keywords": [], - "author": "GitHub Inc.", - "license": "ISC", - "files": [ - "bin/", - "lib/" - ], - "repository": { - "type": "git", - "url": "https://github.com/npm/redact.git" - }, - "templateOSS": { - "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.21.3", - "publish": true - }, - "tap": { - "nyc-arg": [ - "--exclude", - "tap-snapshots/**" - ], - "timeout": 120 - }, - "devDependencies": { - "@npmcli/eslint-config": "^4.0.2", - "@npmcli/template-oss": "4.21.3", - "tap": "^16.3.10" - }, - "engines": { - "node": "^16.14.0 || >=18.0.0" - } -} diff --git a/package-lock.json b/package-lock.json index 6693448b04e90..924b2b28c9566 100644 --- a/package-lock.json +++ b/package-lock.json @@ -93,7 +93,7 @@ "@npmcli/map-workspaces": "^3.0.6", "@npmcli/package-json": "^5.1.0", "@npmcli/promise-spawn": "^7.0.1", - "@npmcli/redact": "^1.1.0", + "@npmcli/redact": "^2.0.0", "@npmcli/run-script": "^8.1.0", "@sigstore/tuf": "^2.3.2", "abbrev": "^2.0.0", @@ -1787,9 +1787,9 @@ } }, "node_modules/@npmcli/redact": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/redact/-/redact-1.1.0.tgz", - "integrity": "sha512-PfnWuOkQgu7gCbnSsAisaX7hKOdZ4wSAhAzH3/ph5dSGau52kCRrMMGbiSQLwyTZpgldkZ49b0brkOr1AzGBHQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/redact/-/redact-2.0.0.tgz", + "integrity": "sha512-SEjCPAVHWYUIQR+Yn03kJmrJjZDtJLYpj300m3HV9OTRZNpC5YpbMsM3eTkECyT4aWj8lDr9WeY6TWefpubtYQ==", "inBundle": true, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -9043,15 +9043,6 @@ "node": "^16.14.0 || >=18.0.0" } }, - "node_modules/npm-registry-fetch/node_modules/@npmcli/redact": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/redact/-/redact-2.0.0.tgz", - "integrity": "sha512-SEjCPAVHWYUIQR+Yn03kJmrJjZDtJLYpj300m3HV9OTRZNpC5YpbMsM3eTkECyT4aWj8lDr9WeY6TWefpubtYQ==", - "inBundle": true, - "engines": { - "node": "^16.14.0 || >=18.0.0" - } - }, "node_modules/npm-run-path": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", @@ -14979,7 +14970,7 @@ "@npmcli/node-gyp": "^3.0.0", "@npmcli/package-json": "^5.1.0", "@npmcli/query": "^3.1.0", - "@npmcli/redact": "^1.1.0", + "@npmcli/redact": "^2.0.0", "@npmcli/run-script": "^8.1.0", "bin-links": "^4.0.1", "cacache": "^18.0.0", diff --git a/package.json b/package.json index 7808fdaea3b7f..97b9a340e2ddc 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@npmcli/map-workspaces": "^3.0.6", "@npmcli/package-json": "^5.1.0", "@npmcli/promise-spawn": "^7.0.1", - "@npmcli/redact": "^1.1.0", + "@npmcli/redact": "^2.0.0", "@npmcli/run-script": "^8.1.0", "@sigstore/tuf": "^2.3.2", "abbrev": "^2.0.0", diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index c28e4e96203b0..0a411ec347abb 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -12,7 +12,7 @@ "@npmcli/node-gyp": "^3.0.0", "@npmcli/package-json": "^5.1.0", "@npmcli/query": "^3.1.0", - "@npmcli/redact": "^1.1.0", + "@npmcli/redact": "^2.0.0", "@npmcli/run-script": "^8.1.0", "bin-links": "^4.0.1", "cacache": "^18.0.0",