feat(security): integrate Trivy vulnerability scanning
- add Trivy security stage - scan generated SBOM artifacts - publish vulnerability reports as GitLab artifacts
This commit is contained in:
@@ -33,6 +33,8 @@ deploy-prod:
|
||||
|
||||
sbom:
|
||||
stage: security
|
||||
needs:
|
||||
- deploy-prod
|
||||
script:
|
||||
- ansible-playbook playbooks/sbom.yml
|
||||
artifacts:
|
||||
@@ -40,3 +42,39 @@ sbom:
|
||||
paths:
|
||||
- reports/sbom/
|
||||
expire_in: 365 days
|
||||
|
||||
trivy:sbom:
|
||||
stage: security
|
||||
needs:
|
||||
- job: sbom
|
||||
artifacts: true
|
||||
script:
|
||||
- ls -R reports || true
|
||||
- mkdir -p reports/trivy
|
||||
- |
|
||||
if compgen -G "reports/sbom/*.json" > /dev/null; then
|
||||
for sbom in reports/sbom/*.json; do
|
||||
filename=$(basename "$sbom" .json)
|
||||
|
||||
echo "Scanning $sbom"
|
||||
|
||||
trivy sbom \
|
||||
--format json \
|
||||
--output "reports/trivy/${filename}-trivy.json" \
|
||||
--exit-code 0 \
|
||||
"$sbom"
|
||||
trivy sbom \
|
||||
--format table \
|
||||
--output "reports/trivy/${filename}-trivy.txt" \
|
||||
--exit-code 0 \
|
||||
"$sbom"
|
||||
done
|
||||
else
|
||||
echo "No SBOM files found."
|
||||
exit 1
|
||||
fi
|
||||
artifacts:
|
||||
when: always
|
||||
expire_in: 365 days
|
||||
paths:
|
||||
- reports/trivy/
|
||||
|
||||
Reference in New Issue
Block a user