-
Notifications
You must be signed in to change notification settings - Fork 777
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4760 from canonical/KU-2230/trivy-job-fix
Trivy job fix
- Loading branch information
Showing
1 changed file
with
9 additions
and
18 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" |