Skip to content

Commit

Permalink
Merge pull request #4760 from canonical/KU-2230/trivy-job-fix
Browse files Browse the repository at this point in the history
Trivy job fix
  • Loading branch information
Maciek Gołaszewski authored Nov 27, 2024
2 parents cb00e90 + b9d88f4 commit ff13a81
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions .github/workflows/build-snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,35 +210,26 @@ jobs:
with:
name: microk8s.snap
path: build
- name: Setup Trivy vulnerability scanner
- name: Create sarifs directory
run: |
mkdir -p sarifs
VER=$(curl --silent -qI https://github.com/aquasecurity/trivy/releases/latest | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}');
wget https://github.com/aquasecurity/trivy/releases/download/${VER}/trivy_${VER#v}_Linux-64bit.tar.gz
tar -zxvf ./trivy_${VER#v}_Linux-64bit.tar.gz
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: "fs"
ignore-unfixed: true
format: "sarif"
output: "trivy-microk8s-repo-scan--results.sarif"
severity: "CRITICAL"
- name: Gather Trivy repo scan results
run: |
cp trivy-microk8s-repo-scan--results.sarif ./sarifs/
- name: Install Trivy vulnerability scanner
uses: aquasecurity/[email protected]
- name: Run Trivy vulnerability scanner on codebase
run: |
trivy fs . --format sarif --severity CRITICAL > sarifs/trivy-microk8s-repo-scan--results.sarif
- name: Run Trivy vulnerability scanner on images
run: |
for i in $(cat ./build-scripts/images.txt) ; do
name=$(echo $i | awk -F ':|/' '{print $(NF-1)}')
./trivy image $i --format sarif > sarifs/$name.sarif
trivy image $i --format sarif > sarifs/$name.sarif
done
- name: Run Trivy vulnerability scanner on the snap
run: |
cp build/microk8s.snap .
unsquashfs microk8s.snap
./trivy rootfs ./squashfs-root/ --format sarif > sarifs/snap.sarif
trivy rootfs ./squashfs-root/ --format sarif > sarifs/snap.sarif
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "sarifs"

0 comments on commit ff13a81

Please sign in to comment.