mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
ci: add Trivy container vulnerability scan to release pipeline
Scans the amd64 Docker image for CRITICAL/HIGH CVEs with available fixes before publishing multi-arch manifests. Results upload to GitHub Security tab as SARIF. Blocks release if fixable vulnerabilities are found.
This commit is contained in:
@@ -8,6 +8,7 @@ permissions:
|
|||||||
issues: write
|
issues: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
packages: write
|
packages: write
|
||||||
|
security-events: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
@@ -128,9 +129,58 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
|
scan:
|
||||||
|
name: Trivy Container Scan
|
||||||
|
needs: [release, docker]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download amd64 digest
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-linux-amd64
|
||||||
|
path: /tmp/digests
|
||||||
|
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
|
||||||
|
- name: Get digest
|
||||||
|
id: digest
|
||||||
|
run: |
|
||||||
|
sha=$(ls /tmp/digests | head -1)
|
||||||
|
echo "sha=$sha" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Run Trivy vulnerability scanner
|
||||||
|
uses: aquasecurity/trivy-action@v0.29.0
|
||||||
|
with:
|
||||||
|
image-ref: "ghcr.io/snapotter-hq/snapotter@sha256:${{ steps.digest.outputs.sha }}"
|
||||||
|
format: "table"
|
||||||
|
exit-code: "1"
|
||||||
|
ignore-unfixed: true
|
||||||
|
severity: "CRITICAL,HIGH"
|
||||||
|
|
||||||
|
- name: Upload results to GitHub Security
|
||||||
|
if: always()
|
||||||
|
uses: aquasecurity/trivy-action@v0.29.0
|
||||||
|
with:
|
||||||
|
image-ref: "ghcr.io/snapotter-hq/snapotter@sha256:${{ steps.digest.outputs.sha }}"
|
||||||
|
format: "sarif"
|
||||||
|
output: "trivy-results.sarif"
|
||||||
|
ignore-unfixed: true
|
||||||
|
severity: "CRITICAL,HIGH"
|
||||||
|
|
||||||
|
- name: Upload SARIF
|
||||||
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
sarif_file: "trivy-results.sarif"
|
||||||
|
|
||||||
manifest:
|
manifest:
|
||||||
name: Create Multi-Arch Manifests
|
name: Create Multi-Arch Manifests
|
||||||
needs: [release, docker]
|
needs: [release, docker, scan]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Download digests
|
- name: Download digests
|
||||||
|
|||||||
Reference in New Issue
Block a user