Skip to content

Commit b86b550

Browse files
feat: remove skip scan option and add scan_high_severity flag (#186)
* feat: remove skip scan option and add optional removal of high severity scan * fix: linting * fix: linting * fix: branch name * fix: pass env correctly * fix: add fromJson * fix: add all options * chore: remove logs * fix: readd skip_image_scan * fix: reset branches
1 parent 1762af6 commit b86b550

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

.github/workflows/build-docker-artifacts-config.schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@
3838
"skip_image_scan": {
3939
"type": "boolean",
4040
"default": false,
41-
"description": "Skip scanning the image for vulnerabilities"
41+
"description": "[Deprecated: use scan_high_severity or the .trivyignore file instead] Skip scanning the image for vulnerabilities"
42+
},
43+
"scan_high_severity": {
44+
"type": "boolean",
45+
"default": true,
46+
"description": "Scan the image for high severity vulnerabilities"
4247
}
4348
},
4449
"required": ["directory", "ecr_repository"]

.github/workflows/build-docker-artifacts.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ on:
2626
type: boolean
2727
required: false
2828
default: false
29+
scan_high_severity:
30+
description: 'Include high severity'
31+
type: boolean
32+
required: false
33+
default: true
2934
runs_on:
3035
type: string
3136
required: false
@@ -240,6 +245,16 @@ jobs:
240245
# https://github.com/docker/build-push-action/issues/1156#issuecomment-2437227730
241246
DOCKER_BUILD_SUMMARY: false
242247

248+
- name: Determine trivy scan severity levels
249+
id: set_severity
250+
run: |
251+
if [[ "${{ github.event.inputs.scan_high_severity }}" == "false" ]] || \
252+
[[ "${{ vars.SCAN_HIGH_SEVERITY }}" == "false" ]] || \
253+
[[ "${{ matrix.component.scan_high_severity }}" == "false" ]]; then
254+
echo "severity=CRITICAL" >> "$GITHUB_OUTPUT"
255+
else
256+
echo "severity=HIGH,CRITICAL" >> "$GITHUB_OUTPUT"
257+
fi
243258
- name: Run Trivy vulnerability scanner
244259
if: ${{ inputs.skip_image_scan != true && fromJson(vars.SKIP_IMAGE_SCAN || 'false') != true && matrix.component.skip_image_scan != true }}
245260
uses: aquasecurity/[email protected]
@@ -249,7 +264,7 @@ jobs:
249264
exit-code: '1'
250265
ignore-unfixed: false
251266
vuln-type: 'os,library'
252-
severity: 'HIGH,CRITICAL'
267+
severity: ${{ steps.set_severity.outputs.severity }}
253268
continue-on-error: false
254269

255270
- name: Push image

0 commit comments

Comments
 (0)