This repository was archived by the owner on Jul 14, 2026. It is now read-only.
Security Scan #212
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Security Scan | |
| on: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| - cron: '0 6 * * *' # Daily at 06:00 UTC | |
| workflow_dispatch: | |
| env: | |
| IMAGE_NAME: simplyblock/spdkcsi | |
| jobs: | |
| scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| security-events: write # required to upload SARIF to GitHub Security tab | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build image for scanning (linux/amd64 only) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: deploy/image/Dockerfile | |
| platforms: linux/amd64 | |
| load: true | |
| tags: ${{ env.IMAGE_NAME }}:scan | |
| # Grype uses Red Hat's Security Data API — much more current than Trivy's OVAL source. | |
| - name: Run Grype vulnerability scan (Red Hat advisories) | |
| id: grype | |
| uses: anchore/scan-action@v6 | |
| with: | |
| image: ${{ env.IMAGE_NAME }}:scan | |
| severity-cutoff: medium | |
| fail-build: true | |
| only-fixed: true | |
| output-format: table | |
| - name: Run Trivy vulnerability scan (Go binary + secrets) | |
| uses: aquasecurity/trivy-action@v0.35.0 | |
| with: | |
| image-ref: ${{ env.IMAGE_NAME }}:scan | |
| format: sarif | |
| output: trivy-results.sarif | |
| severity: CRITICAL,HIGH,MEDIUM | |
| ignore-unfixed: true | |
| exit-code: '1' | |
| scanners: vuln,secret | |
| - name: Upload Trivy scan results to GitHub Security | |
| uses: github/codeql-action/upload-sarif@v3 | |
| if: always() | |
| with: | |
| sarif_file: trivy-results.sarif | |
| - name: Generate SBOM (CycloneDX) | |
| uses: aquasecurity/trivy-action@v0.35.0 | |
| with: | |
| image-ref: ${{ env.IMAGE_NAME }}:scan | |
| format: cyclonedx | |
| output: sbom.cdx.json | |
| - name: Upload SBOM artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sbom-${{ github.sha }} | |
| path: sbom.cdx.json | |
| retention-days: 90 | |
| - name: Notify Slack on scan failure | |
| if: failure() | |
| uses: slackapi/slack-github-action@v2 | |
| with: | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| { | |
| "text": ":rotating_light: *Security scan failed* — vulnerabilities found in `${{ github.repository }}`", | |
| "attachments": [ | |
| { | |
| "color": "danger", | |
| "fields": [ | |
| { "title": "Branch", "value": "${{ github.ref_name }}", "short": true }, | |
| { "title": "Commit", "value": "${{ github.sha }}", "short": true }, | |
| { "title": "Workflow", "value": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>", "short": false } | |
| ] | |
| } | |
| ] | |
| } |