diff --git a/lib/commands/info/index.js b/lib/commands/info/index.js index abee2416..5ded7c78 100644 --- a/lib/commands/info/index.js +++ b/lib/commands/info/index.js @@ -145,6 +145,28 @@ async function fetchPackageData (pkgName, pkgVersion, { includeAllIssues, strict if (objectSome(severityCount)) { const issueSummary = formatSeverityCount(severityCount) spinner[strict ? 'fail' : 'succeed'](`Package has these issues: ${issueSummary}`) + + // Return the alert types for critical and high alerts + const issueDetails = result.data.filter(d => d.value?.severity === 'high' || d.value?.severity === 'critical') + const uniqueIssues = issueDetails.reduce((/** @type {{ [key: string]: number }} */ acc, issue) => { + const { type } = issue + if (type) { + let count = 0 + if (!acc[type]) { + count += 1 + acc[type] = count + } else { + acc[type]++ + } + } + return acc + }, {}) + Object.keys(uniqueIssues).map(issue => { + if (uniqueIssues[issue] === 1) { + return console.log(`- ${issue}`) + } + return console.log(`- ${issue}: ${uniqueIssues[issue]}`) + }) } else { spinner.succeed('Package has no issues') } @@ -165,7 +187,7 @@ async function fetchPackageData (pkgName, pkgVersion, { includeAllIssues, strict if (outputJson) { console.log(JSON.stringify(data, undefined, 2)) } else { - console.log('\nPackage report card:\n') + console.log('\nPackage report card:') const scoreResult = { 'Supply Chain Risk': Math.floor(score.supplyChainRisk.score * 100),