Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use @npmcli/redact for url cleaning #7363

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ graph LR;
npmcli-arborist-->npmcli-node-gyp["@npmcli/node-gyp"];
npmcli-arborist-->npmcli-package-json["@npmcli/package-json"];
npmcli-arborist-->npmcli-query["@npmcli/query"];
npmcli-arborist-->npmcli-redact["@npmcli/redact"];
npmcli-arborist-->npmcli-run-script["@npmcli/run-script"];
npmcli-arborist-->npmcli-template-oss["@npmcli/template-oss"];
npmcli-arborist-->npmlog;
Expand Down Expand Up @@ -623,6 +624,7 @@ graph LR;
npmcli-arborist-->npmcli-node-gyp["@npmcli/node-gyp"];
npmcli-arborist-->npmcli-package-json["@npmcli/package-json"];
npmcli-arborist-->npmcli-query["@npmcli/query"];
npmcli-arborist-->npmcli-redact["@npmcli/redact"];
npmcli-arborist-->npmcli-run-script["@npmcli/run-script"];
npmcli-arborist-->npmcli-template-oss["@npmcli/template-oss"];
npmcli-arborist-->npmlog;
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/owner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const log = require('../utils/log-shim')
const otplease = require('../utils/otplease.js')
const pkgJson = require('@npmcli/package-json')
const BaseCommand = require('../base-command.js')
const { redact } = require('@npmcli/redact')

const readJson = async (path) => {
try {
Expand Down Expand Up @@ -119,7 +120,7 @@ class Owner extends BaseCommand {
this.npm.output(maintainers.map(m => `${m.name} <${m.email}>`).join('\n'))
}
} catch (err) {
log.error('owner ls', "Couldn't get owner data", npmFetch.cleanUrl(pkg))
log.error('owner ls', "Couldn't get owner data", redact(pkg))
throw err
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/ping.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')
const log = require('../utils/log-shim')
const pingUtil = require('../utils/ping.js')
const BaseCommand = require('../base-command.js')
Expand All @@ -9,7 +9,7 @@ class Ping extends BaseCommand {
static name = 'ping'

async exec (args) {
const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
const cleanRegistry = redact(this.npm.config.get('registry'))
log.notice('PING', cleanRegistry)
const start = Date.now()
const details = await pingUtil({ ...this.npm.flatOptions })
Expand Down
1 change: 1 addition & 0 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16130,6 +16130,7 @@
"@npmcli/node-gyp": "^3.0.0",
"@npmcli/package-json": "^5.0.0",
"@npmcli/query": "^3.1.0",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.2",
"bin-links": "^4.0.1",
"cacache": "^18.0.0",
Expand Down
4 changes: 2 additions & 2 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { readdirScoped } = require('@npmcli/fs')
const { lstat, readlink } = require('fs/promises')
const { depth } = require('treeverse')
const log = require('proc-log')
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')

const {
OK,
Expand Down Expand Up @@ -1213,7 +1213,7 @@ This is a one-time fix-up, please be patient...
if (this.#manifests.has(spec.raw)) {
return this.#manifests.get(spec.raw)
} else {
const cleanRawSpec = cleanUrl(spec.rawSpec)
const cleanRawSpec = redact(spec.rawSpec)
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
const o = {
...options,
Expand Down
4 changes: 2 additions & 2 deletions workspaces/arborist/lib/place-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

const localeCompare = require('@isaacs/string-locale-compare')('en')
const log = require('proc-log')
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')
const deepestNestingTarget = require('./deepest-nesting-target.js')
const CanPlaceDep = require('./can-place-dep.js')
const {
Expand Down Expand Up @@ -188,7 +188,7 @@ class PlaceDep {
`${this.dep.name}@${this.dep.version}`,
this.canPlace.description,
`for: ${this.edge.from.package._id || this.edge.from.location}`,
`want: ${cleanUrl(this.edge.spec || '*')}`
`want: ${redact(this.edge.spec || '*')}`
)

const placementType = this.canPlace.canPlace === CONFLICT
Expand Down
1 change: 1 addition & 0 deletions workspaces/arborist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@npmcli/node-gyp": "^3.0.0",
"@npmcli/package-json": "^5.0.0",
"@npmcli/query": "^3.1.0",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.2",
"bin-links": "^4.0.1",
"cacache": "^18.0.0",
Expand Down
Loading