Skip to content

Merge pull request #741 from DFE-Digital/remove-tfsec #137

Merge pull request #741 from DFE-Digital/remove-tfsec

Merge pull request #741 from DFE-Digital/remove-tfsec #137

Workflow file for this run

name: Scan Docker image
on:
push:
branches: main
jobs:
scan:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.build.outputs.imageid }}
strategy:
matrix:
image: [
"Dockerfile",
]
stage: [
"final",
"initcontainer"
]
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3
- name: Build docker image
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6
id: build
with:
file: './${{ matrix.image }}'
build-args: CI=true
secrets: github_token=${{ secrets.GITHUB_TOKEN }}
target: ${{ matrix.stage }}
load: true
cache-from: type=gha
cache-to: type=gha
push: false
- name: Export docker image as tar
run: docker save -o ${{ matrix.image }}-${{ matrix.stage }}.tar ${{ steps.build.outputs.imageid }}
- name: Scan Docker image for CVEs
uses: aquasecurity/trivy-action@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5 # 0.30.0
with:
input: ${{ matrix.image }}-${{ matrix.stage }}.tar
format: 'sarif'
output: 'trivy-results.sarif'
limit-severities-for-sarif: true
ignore-unfixed: true
severity: 'CRITICAL,HIGH'
github-pat: ${{ secrets.GITHUB_TOKEN }}
- name: Upload scan results to GitHub Security
uses: github/codeql-action/upload-sarif@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3
if: always()
with:
sarif_file: 'trivy-results.sarif'