Skip to content

Commit

Permalink
Merge pull request #48 from josh-linushealth/errorMissedIgnores
Browse files Browse the repository at this point in the history
errorMissedIgnores parameter
  • Loading branch information
pzi authored Aug 2, 2024
2 parents 0259bd2 + e33cbe3 commit a17ece3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ As of version `3.0.0`, only enhanced scanning is supported. Basic scanning suppo
| repository | :white_check_mark: | ECR repository, eg myorg/myimage |
| tag | :white_check_mark: | Image tag to scan |
| 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`. |
| 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. |
| 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. |

## Outputs
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ inputs:
default: medium
ignore_list:
description: List of CVE IDs to ignore in the vulnerability findings.
error_missed_ignores:
description: >
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.
required: false
default: error
outputs:
critical:
description: Number of critical vulnerabilities detected.
Expand Down
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ const main = async () => {
const tag = core.getInput('tag', { required: true })
const failThreshold = core.getInput('fail_threshold') || 'high'
const ignoreList = parseIgnoreList(core.getInput('ignore_list'))
const missedCVELogLevel = core.getInput('missedCVELogLevel') || 'error'

//Validate missedCVELogLevel
if (
missedCVELogLevel !== 'warn' &&
missedCVELogLevel !== 'error'
) {
throw new Error('missedCVELogLevel input value is invalid. It must be either "warn" or "error".')
}

const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy
if (proxyUrl !== undefined) {
Expand Down Expand Up @@ -240,7 +249,11 @@ const main = async () => {
const missedIgnores = ignoreList.filter(vulnerabilityId => !ignoredFindings.map(({ packageVulnerabilityDetails }) => packageVulnerabilityDetails.vulnerabilityId).includes(vulnerabilityId));
console.log('The following CVEs were not found in the result set:');
missedIgnores.forEach(miss => console.log(` ${miss}`));
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.`);
if (missedCVELogLevel === 'error') {
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.`);
} else {
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.`);
}
}

const ignoredCounts = countIgnoredFindings(ignoredFindings)
Expand Down

0 comments on commit a17ece3

Please sign in to comment.