From 76b16dcc23b0b2f0119e712e3e79dfef5eac8199 Mon Sep 17 00:00:00 2001 From: "noussair.hamrit" Date: Thu, 25 Jun 2026 14:32:14 +0200 Subject: [PATCH] feat(security): integrate Trivy vulnerability scanning - add Trivy security stage - scan generated SBOM artifacts - publish vulnerability reports as GitLab artifacts --- .gitlab-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c890581..6ae8cc3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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/