Skip to content

Commit ac357ae

Browse files
taro-kayoalexjurkiewicz
authored andcommitted
fix: Scan job fails even though CVE is on ignore list
1 parent ff9105b commit ac357ae

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

index.js

+25-6
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,26 @@ function configureGlobalProxy(proxyUrl) {
135135
});
136136
}
137137

138+
function countFailingVulnerabilities(failThreshold, foundCounts, ignoredCounts) {
139+
let count = foundCounts.critical - ignoredCounts.critical;
140+
if (failThreshold === 'critical') {
141+
return count;
142+
}
143+
count += foundCounts.high - ignoredCounts.high;
144+
if (failThreshold === 'high') {
145+
return count;
146+
}
147+
count += foundCounts.medium - ignoredCounts.medium;
148+
if (failThreshold === 'medium') {
149+
return count;
150+
}
151+
count += foundCounts.low - ignoredCounts.low;
152+
if (failThreshold === 'low') {
153+
return count;
154+
}
155+
return count + foundCounts.informational - ignoredCounts.informational;
156+
}
157+
138158
const main = async () => {
139159
core.debug('Entering main')
140160
const repository = core.getInput('repository', { required: true })
@@ -247,12 +267,11 @@ const main = async () => {
247267
console.log('=================')
248268
console.log(`${total.toString().padStart(3, ' ')} Total ${getCount('total', ignoredCounts)}`)
249269

250-
const numFailingVulns =
251-
failThreshold === 'informational' ? total - ignoredCounts.informational
252-
: failThreshold === 'low' ? critical + high + medium + low - ignoredCounts.low
253-
: failThreshold === 'medium' ? critical + high + medium - ignoredCounts.medium
254-
: failThreshold === 'high' ? critical + high - ignoredCounts.high
255-
: /* failThreshold === 'critical' ? */ critical - ignoredCounts.critical
270+
const numFailingVulns = countFailingVulnerabilities(
271+
failThreshold,
272+
{ informational, low, medium, high, critical },
273+
ignoredCounts,
274+
)
256275

257276
if (numFailingVulns > 0) {
258277
throw new Error(`Detected ${numFailingVulns} vulnerabilities with severity >= ${failThreshold} (the currently configured fail_threshold).`)

0 commit comments

Comments
 (0)