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/