Skip to content

Commit a17ece3

Browse files
authored
Merge pull request #48 from josh-linushealth/errorMissedIgnores
errorMissedIgnores parameter
2 parents 0259bd2 + e33cbe3 commit a17ece3

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ As of version `3.0.0`, only enhanced scanning is supported. Basic scanning suppo
2626
| repository | :white_check_mark: | ECR repository, eg myorg/myimage |
2727
| tag | :white_check_mark: | Image tag to scan |
2828
| fail_threshold | | Fail if any vulnerabilities equal to or over this severity level are detected. Valid values: `critical`, `high`, `medium`, `low`, `informational`. Default value is `high`. |
29+
| missedCVELogLevel | | Set the log level for missed CVEs. Valid values: `error`, `warn`. Determines whether a core.error or a core.warning is raised when the ignore list contains CVE IDs that were not found in the scan results. Default value is error. |
2930
| ignore_list | | List of CVE IDs to ignore.<br/>:warning: **Note**: The `ignore_list` can either be a multi-line string (like the example below) or a list (separated using commas or spaces) containing CVE IDs to be ignored. |
3031

3132
## Outputs

action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ inputs:
1313
default: medium
1414
ignore_list:
1515
description: List of CVE IDs to ignore in the vulnerability findings.
16+
error_missed_ignores:
17+
description: >
18+
Set to "error" if you want to raise an error when CVEs in the ignore list are not found. Set to "warn" to raise a warning only, and prevent the workflow from failing when CVEs in the ignore list are not found.
19+
required: false
20+
default: error
1621
outputs:
1722
critical:
1823
description: Number of critical vulnerabilities detected.

index.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@ const main = async () => {
174174
const tag = core.getInput('tag', { required: true })
175175
const failThreshold = core.getInput('fail_threshold') || 'high'
176176
const ignoreList = parseIgnoreList(core.getInput('ignore_list'))
177+
const missedCVELogLevel = core.getInput('missedCVELogLevel') || 'error'
178+
179+
//Validate missedCVELogLevel
180+
if (
181+
missedCVELogLevel !== 'warn' &&
182+
missedCVELogLevel !== 'error'
183+
) {
184+
throw new Error('missedCVELogLevel input value is invalid. It must be either "warn" or "error".')
185+
}
177186

178187
const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy
179188
if (proxyUrl !== undefined) {
@@ -240,7 +249,11 @@ const main = async () => {
240249
const missedIgnores = ignoreList.filter(vulnerabilityId => !ignoredFindings.map(({ packageVulnerabilityDetails }) => packageVulnerabilityDetails.vulnerabilityId).includes(vulnerabilityId));
241250
console.log('The following CVEs were not found in the result set:');
242251
missedIgnores.forEach(miss => console.log(` ${miss}`));
243-
throw new Error(`Ignore list contains CVE IDs that were not returned in the findings result set. They may be invalid or no longer be current vulnerabilities.`);
252+
if (missedCVELogLevel === 'error') {
253+
throw new Error(`Ignore list contains CVE IDs that were not returned in the findings result set. They may be invalid or no longer be current vulnerabilities.`);
254+
} else {
255+
core.warning(`Ignore list contains CVE IDs that were not returned in the findings result set. They may be invalid or no longer be current vulnerabilities.`);
256+
}
244257
}
245258

246259
const ignoredCounts = countIgnoredFindings(ignoredFindings)

0 commit comments

Comments
 (0)