Wip: trivy image sec #9
Workflow file for this run
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
name: Image Scan 🕷️ | |
on: | |
push: | |
branches: | |
- '*' | |
tags: | |
- '*' | |
env: | |
BUILDAH_FORMAT: "docker" | |
#IMAGE_TAG: ${{ github.sha }} | |
REGISTRY: docker.io | |
REPOSITORY: docker.io/containerscrew/infratools | |
jobs: | |
build: | |
name: Scan image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Get latest image tag to scan | |
id: set_tag | |
run: | | |
# Get latest tag | |
LATEST_TAG=$(curl -s https://api.github.com/repos/containerscrew/infratools/tags | jq -r '.[0].name') | |
echo "LATEST_TAG=$LATEST_TAG" >> "$GITHUB_ENV" | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: '${{env.REPOSITORY}}:${{env.LATEST_TAG}}' | |
format: 'sarif' | |
output: 'trivy-results.sarif' | |
vuln-type: 'os,library' | |
ignore-unfixed: false | |
severity: 'CRITICAL,HIGH' | |
env: | |
TRIVY_USERNAME: ${{ secrets.DOCKERHUB_AUTH_USERNAME }} | |
TRIVY_PASSWORD: ${{ secrets.DOCKERHUB_AUTH_TOKEN }} | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: 'trivy-results.sarif' |