From 0bab6ffc2c9ebbdcbe72e09f26347d463fe38fba Mon Sep 17 00:00:00 2001 From: tgrall Date: Sun, 28 Jan 2024 14:54:14 +0100 Subject: [PATCH] Fix vulnerability check to print warnings instead of failing --- src/main.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index d109f93..b4f70dc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -131,7 +131,7 @@ async function run(): Promise { if (config.vulnerability_check) { summary.addChangeVulnerabilitiesToSummary(vulnerableChanges, minSeverity) - printVulnerabilitiesBlock(vulnerableChanges, minSeverity) + printVulnerabilitiesBlock(vulnerableChanges, minSeverity, warnOnly) } if (config.license_check) { summary.addLicensesToSummary(invalidLicenseChanges, config) @@ -174,19 +174,25 @@ async function run(): Promise { function printVulnerabilitiesBlock( addedChanges: Changes, - minSeverity: Severity + minSeverity: Severity, + warnOnly: boolean ): void { - let failed = false + let vulFound = false core.group('Vulnerabilities', async () => { if (addedChanges.length > 0) { for (const change of addedChanges) { printChangeVulnerabilities(change) } - failed = true + vulFound = true } - if (failed) { - core.setFailed('Dependency review detected vulnerable packages.') + if (vulFound) { + const msg = 'Dependency review detected vulnerable packages.' + if (warnOnly) { + core.warning(msg) + } else { + core.setFailed(msg) + } } else { core.info( `Dependency review did not detect any vulnerable packages with severity level "${minSeverity}" or higher.`