Skip to content

Commit 0bc255b

Browse files
committed
Filter out unpopularPackage and unstableOwnership alerts for blessed packages
1 parent 6fbd6b2 commit 0bc255b

File tree

1 file changed

+47
-26
lines changed

1 file changed

+47
-26
lines changed

src/shadow/arborist.ts

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -394,22 +394,40 @@ async function packagesHaveRiskyIssues(
394394
const id = `${name}@${version}`
395395

396396
let displayWarning = false
397-
let failures: { block?: boolean; raw?: any; type?: string }[] = []
397+
let failures: {
398+
type: string
399+
block: boolean
400+
raw?: any
401+
}[] = []
398402
if (pkgData.type === 'missing') {
399403
result = true
400404
failures.push({
401-
type: 'missingDependency'
405+
type: 'missingDependency',
406+
block: false,
407+
raw: undefined
402408
})
403409
} else {
404410
let blocked = false
405411
for (const failure of pkgData.value.issues) {
412+
const { type } = failure
406413
// eslint-disable-next-line no-await-in-loop
407414
const ux = await uxLookup({
408415
package: { name, version },
409-
issue: { type: failure.type }
416+
issue: { type }
410417
})
411-
if (ux.display || ux.block) {
412-
failures.push({ raw: failure, block: ux.block })
418+
if (ux.block) {
419+
result = true
420+
blocked = true
421+
}
422+
if (ux.display) {
423+
displayWarning = true
424+
}
425+
if (ux.block || ux.display) {
426+
failures.push({
427+
type,
428+
block: ux.block,
429+
raw: failure
430+
})
413431
// Before we ask about problematic issues, check to see if they
414432
// already existed in the old version if they did, be quiet.
415433
const pkg = pkgs.find(
@@ -422,20 +440,13 @@ async function packagesHaveRiskyIssues(
422440
failures = failures.filter(
423441
issue =>
424442
oldPkgData.value.issues.find(
425-
oldIssue => oldIssue.type === issue.raw.type
426-
) == null
443+
oldIssue => oldIssue.type === issue.type
444+
) === undefined
427445
)
428446
}
429447
}
430448
}
431449
}
432-
if (ux.block) {
433-
result = true
434-
blocked = true
435-
}
436-
if (ux.display) {
437-
displayWarning = true
438-
}
439450
}
440451
if (!blocked) {
441452
const pkg = pkgs.find(p => p.pkgid === id)
@@ -455,20 +466,30 @@ async function packagesHaveRiskyIssues(
455466
spinner.stop(
456467
`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:`
457468
)
458-
failures.sort((a, b) => (a.raw.type < b.raw.type ? -1 : 1))
469+
// Filter issues for blessed packages.
470+
if (
471+
name === 'socket' ||
472+
name.startsWith('@socketregistry/') ||
473+
name.startsWith('@socketsecurity/')
474+
) {
475+
failures = failures.filter(
476+
({ type }) =>
477+
type !== 'unpopularPackage' && type !== 'unstableOwnership'
478+
)
479+
}
480+
failures.sort((a, b) => (a.type < b.type ? -1 : 1))
481+
459482
const lines = new Set()
460483
for (const failure of failures) {
461-
const type = failure.raw.type
462-
if (type) {
463-
// Based data from { pageProps: { alertTypes } } of:
464-
// https://socket.dev/_next/data/94666139314b6437ee4491a0864e72b264547585/en-US.json
465-
const info = translations.issues[type]
466-
const title = info?.title ?? type
467-
const maybeBlocking = failure.block ? '' : ' (non-blocking)'
468-
const maybeDesc = info?.description ? ` - ${info.description}` : ''
469-
// TODO: emoji seems to mis-align terminals sometimes
470-
lines.add(` ${title}${maybeBlocking}${maybeDesc}\n`)
471-
}
484+
const { type } = failure
485+
// Based data from { pageProps: { alertTypes } } of:
486+
// https://socket.dev/_next/data/94666139314b6437ee4491a0864e72b264547585/en-US.json
487+
const info = translations.issues[type]
488+
const title = info?.title ?? type
489+
const maybeBlocking = failure.block ? '' : ' (non-blocking)'
490+
const maybeDesc = info?.description ? ` - ${info.description}` : ''
491+
// TODO: emoji seems to mis-align terminals sometimes
492+
lines.add(` ${title}${maybeBlocking}${maybeDesc}\n`)
472493
}
473494
for (const line of lines) {
474495
output?.write(line)

0 commit comments

Comments
 (0)