|
| 1 | +name: Docker vulnerability scans |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + pull_request: |
| 10 | + |
| 11 | +permissions: {} |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + grype: |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + file: [Dockerfile, go.Dockerfile] |
| 23 | + # TODO: Use self-hosted runners when available. |
| 24 | + runs-on: [github-hosted-ubuntu-arm64-large, github-hosted-ubuntu-x64-large] |
| 25 | + |
| 26 | + name: grype scanning (${{ matrix.runs-on }}, ${{ matrix.file }}) |
| 27 | + runs-on: ${{ matrix.runs-on }} |
| 28 | + permissions: |
| 29 | + contents: read # clone the repository |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + persist-credentials: false |
| 34 | + - uses: actions/setup-go@v5 |
| 35 | + with: |
| 36 | + go-version-file: go.mod |
| 37 | + cache: false |
| 38 | + |
| 39 | + - name: docker build |
| 40 | + env: |
| 41 | + DOCKER_BUILDKIT: 1 |
| 42 | + BUILDKIT_STEP_LOG_MAX_SIZE: -1 |
| 43 | + BUILDKIT_STEP_LOG_MAX_SPEED: -1 |
| 44 | + FILE: ${{ matrix.file }} |
| 45 | + run: docker build . -t image-renderer -f "$FILE" |
| 46 | + |
| 47 | + - name: Scan with Grype |
| 48 | + id: scan |
| 49 | + uses: anchore/scan-action@1638637db639e0ade3258b51db49a9a137574c3e # v6 |
| 50 | + with: |
| 51 | + image: image-renderer |
| 52 | + fail-build: true |
| 53 | + - uses: github/codeql-action/upload-sarif@86b04fb0e47484f7282357688f21d5d0e32175fe # v3 |
| 54 | + if: success() || failure() |
| 55 | + with: |
| 56 | + sarif_file: ${{ steps.scan.outputs.sarif }} |
| 57 | + category: Grype |
| 58 | + |
| 59 | + trivy: |
| 60 | + strategy: |
| 61 | + fail-fast: false |
| 62 | + matrix: |
| 63 | + file: [Dockerfile, go.Dockerfile] |
| 64 | + # TODO: Use self-hosted runners when available. |
| 65 | + runs-on: [github-hosted-ubuntu-arm64-large, github-hosted-ubuntu-x64-large] |
| 66 | + |
| 67 | + name: trivy scanning (${{ matrix.runs-on }}, ${{ matrix.file }}) |
| 68 | + runs-on: ${{ matrix.runs-on }} |
| 69 | + permissions: |
| 70 | + contents: read # clone the repository |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v4 |
| 73 | + with: |
| 74 | + persist-credentials: false |
| 75 | + - uses: actions/setup-go@v5 |
| 76 | + with: |
| 77 | + go-version-file: go.mod |
| 78 | + cache: false |
| 79 | + |
| 80 | + - name: docker build |
| 81 | + env: |
| 82 | + DOCKER_BUILDKIT: 1 |
| 83 | + BUILDKIT_STEP_LOG_MAX_SIZE: -1 |
| 84 | + BUILDKIT_STEP_LOG_MAX_SPEED: -1 |
| 85 | + FILE: ${{ matrix.file }} |
| 86 | + run: docker build . -t image-renderer -f "$FILE" |
| 87 | + |
| 88 | + - name: Scan with Trivy |
| 89 | + uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1 |
| 90 | + with: |
| 91 | + image-ref: image-renderer |
| 92 | + format: sarif |
| 93 | + output: trivy-results.sarif |
| 94 | + exit-code: 1 |
| 95 | + - uses: github/codeql-action/upload-sarif@86b04fb0e47484f7282357688f21d5d0e32175fe # v3 |
| 96 | + if: success() || failure() |
| 97 | + with: |
| 98 | + sarif_file: trivy-results.sarif |
| 99 | + category: Trivy |
0 commit comments