This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scan the built docker image for CVEs (#812)
- Loading branch information
1 parent
4c9cf92
commit 8dd4357
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Scan Docker image | ||
|
||
on: | ||
push: | ||
branches: main | ||
|
||
jobs: | ||
scan: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image: ${{ steps.build.outputs.imageid }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build docker image | ||
uses: docker/build-push-action@v6 | ||
id: build | ||
with: | ||
secrets: github_token=${{ secrets.GITHUB_TOKEN }} | ||
load: true | ||
cache-from: type=gha | ||
cache-to: type=gha | ||
push: false | ||
|
||
- name: Export docker image as tar | ||
run: docker save -o ${{ github.ref_name }}.tar ${{ steps.build.outputs.imageid }} | ||
|
||
- name: Scan Docker image for CVEs | ||
uses: aquasecurity/trivy-action@0.20.0 | ||
with: | ||
input: ${{ github.ref_name }}.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@v2 | ||
if: always() | ||
with: | ||
sarif_file: 'trivy-results.sarif' |