Skip to content

Commit

Permalink
MVP-318: Vuln Report Fixes (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyMitch authored Jul 10, 2024
2 parents 0e08126 + 0feaaf7 commit 7fd84b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/helpers/npm-audit/create-report.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const escapeForGitHubActions = (str) =>
else if (highestSeverity === 'moderate') highestSeverityColor = yellow; // Moderate

// Output summary.
if (total ? total === 0 : metadata.vulnerabilities === 0) {
if ((total && total === 0) || metadata.vulnerabilities === 0) {
results[dirPath] += `${line(noVulnerabilities)}`;
} else {
// Output highest severity.
Expand Down
11 changes: 7 additions & 4 deletions .github/helpers/npm-audit/run-npm-audit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ const parseDetails = (auditData) => {
};
});

const highestSeverity = vulnerabilities.reduce((max, vuln) => {
const severities = ['low', 'moderate', 'high', 'critical'];
return severities.indexOf(vuln.severity) > severities.indexOf(max) ? vuln.severity : max;
}, 'low');
const highestSeverity =
vulnerabilities.length === 0
? null
: vulnerabilities.reduce((max, vuln) => {
const severities = ['low', 'moderate', 'high', 'critical'];
return severities.indexOf(vuln.severity) > severities.indexOf(max) ? vuln.severity : max;
}, 'low');

return {
vulnerabilities,
Expand Down

0 comments on commit 7fd84b6

Please sign in to comment.