Skip to content

Commit af2bdbb

Browse files
committed
Add report-only Trivy CVE scan to CI
Run aquasecurity/trivy-action against the locally loaded image between smoke test and push. CRITICAL and HIGH severities only, OS plus library packages, ignore-unfixed so the report focuses on actionable findings (CVEs that have a patch available). Exit-code 0 for now so we get the report into the build log without blocking the push. Flip to 1 once we've cleared the baseline and want to gate on regressions. Refactor: hoist the primary image tag from steps.meta.outputs.tags into GITHUB_ENV in its own step, so the smoke test and the scan step share it cleanly.
1 parent 3e5331d commit af2bdbb

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/docker.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
type=semver,pattern={{version}}
3636
type=semver,pattern={{major}}.{{minor}}
3737
38+
- name: Resolve primary image tag
39+
run: |
40+
FIRST_TAG="$(printf '%s\n' "${{ steps.meta.outputs.tags }}" | head -n1)"
41+
echo "FIRST_TAG=$FIRST_TAG" >> "$GITHUB_ENV"
42+
3843
- name: Build image (load locally for smoke test)
3944
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
4045
with:
@@ -47,7 +52,6 @@ jobs:
4752
- name: Smoke test
4853
run: |
4954
set -euo pipefail
50-
FIRST_TAG="$(printf '%s\n' "${{ steps.meta.outputs.tags }}" | head -n1)"
5155
CM_SETTINGS='{"neuron-name-service":{"component_list":[{"id":"skeletonid","name":"Skeleton ID"},{"id":"neuronname","name":"Neuron name"},{"id":"all-meta","name":"All annotations annotated with \"neuron name\"","option":"neuron name"}]}}'
5256
docker run -d --name catmaid-test -p 80:80 \
5357
-e INSTANCE_MEMORY=900 \
@@ -61,6 +65,18 @@ jobs:
6165
grep -q 'VFB-GA-INJECTED' /tmp/response.html
6266
grep -q "$(docker exec catmaid-test printenv GA_TAG_ID)" /tmp/response.html
6367
68+
- name: Scan image for known vulnerabilities
69+
# Report-only for now (exit-code 0). Flip exit-code to 1 once the
70+
# baseline is clean to gate the build on regressions.
71+
uses: aquasecurity/trivy-action@0.28.0
72+
with:
73+
image-ref: ${{ env.FIRST_TAG }}
74+
format: table
75+
severity: CRITICAL,HIGH
76+
ignore-unfixed: true
77+
exit-code: '0'
78+
vuln-type: os,library
79+
6480
- name: Push image
6581
if: github.event_name != 'pull_request'
6682
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc

0 commit comments

Comments
 (0)