@@ -6,9 +6,6 @@ name: "[Code Analysis] Trivy"
66run-name : " [Code Analysis] Trivy"
77
88on :
9- schedule :
10- - cron : " 0 2 * * 0" # Every Sunday at 2:00 AM UTC
11- workflow_call : {}
129 workflow_dispatch : {}
1310 push :
1411 branches :
2320 - synchronize
2421 - reopened
2522
26- # Trigger workflow when enqueued to a merge group
27- # (must be under 'on')
28- merge_group :
29-
3023permissions :
3124 contents : read # needed for actions/checkout
3225
3326jobs :
3427 trivy-image-scan :
3528 name : " Build images and run Trivy image scan"
36- if : ${{ github.event_name == 'push' }}
3729 permissions :
3830 contents : read
3931 runs-on : ubuntu-latest
32+ if : github.event_name != 'pull_request'
4033 steps :
4134 - name : Checkout Repository
42- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 .0.0
35+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 .0.2
4336 with :
4437 persist-credentials : false
38+ - name : Free up runner space
39+ run : |
40+ # Remove Java (JDKs)
41+ sudo rm -rf /usr/lib/jvm
42+ # Remove .NET SDKs
43+ sudo rm -rf /usr/share/dotnet
44+ # Remove Swift toolchain
45+ sudo rm -rf /usr/share/swift
46+ # Remove Haskell (GHC)
47+ sudo rm -rf /usr/local/.ghcup
48+ # Remove Julia
49+ sudo rm -rf /usr/local/julia*
50+ # Remove Android SDKs
51+ sudo rm -rf /usr/local/lib/android
52+ - name : " Remove all Docker images"
53+ uses : ./.github/actions/cleanup
54+ with :
55+ system-prune : " true"
4556 - name : Install Trivy
4657 id : setup_trivy
47- uses : aquasecurity/setup-trivy@e6c2c5e321ed9123bda567646e2f96565e34abe1 # v0.2.4
58+ uses : aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514 # v0.2.5
4859 with :
49- version : " v0.65.0 "
60+ version : " v0.69.2 "
5061 - name : " Build images"
5162 id : build_images
5263 run : |
53- git rev-parse HEAD > version.txt
5464 echo "SCENESCAPE_VERSION=$(cat version.txt)" >> "$GITHUB_ENV"
55- make
56- docker image ls | awk '{print $1 ":" $2}' | grep $(cat version.txt) | grep -v "\-test" > images.txt
57- # Step name corrected from "Run Trivy Cirital/High Image Scan" to "Run Trivy Critical/High Image Scan".
58- # Verified that no dependent processes rely on the old name.
65+ make build-all
66+ docker image ls | awk '{print $1}' | grep $(cat version.txt) | grep -v "\-test" > images.txt
5967 - name : " Run Trivy Image Scan"
6068 if : always() && steps.build_images.outcome == 'success' && steps.setup_trivy.outcome == 'success'
6169 run : |
@@ -65,10 +73,11 @@ jobs:
6573 while read image; do
6674 echo "::group::Scanning image: $image"
6775 scan_name=$(echo $image | cut -f1 -d":")
68- trivy image --list-all-pkgs --severity HIGH,CRITICAL --config ".github/resources/sdl/trivy_config.yml" --exit-code 1 "$image"
76+ trivy image --config ".github/resources/sdl/trivy_config.yml" "$image"
77+ IMAGE_CODE=$?
78+ EXIT_CODE=$((EXIT_CODE || IMAGE_CODE))
6979 echo "::endgroup::"
70- EXIT_CODE=$((EXIT_CODE || $?))
71- if [ $EXIT_CODE -eq 1 ]; then
80+ if [ $IMAGE_CODE -eq 1 ]; then
7281 echo "::error title=Trivy Image Scan Failed::Trivy scan found HIGH or CRITICAL vulnerabilities in image ${image}"
7382 fi
7483 done <<< $(cat images.txt)
@@ -81,20 +90,16 @@ jobs:
8190 runs-on : ubuntu-latest
8291 steps :
8392 - name : Checkout code
84- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 .0.0
93+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 .0.2
8594 with :
8695 persist-credentials : false
8796 - name : Run Trivy Critical Filesystem Scan
88- uses : aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1
97+ uses : aquasecurity/trivy-action@c1824fd6edce30d7ab345a9989de00bbd46ef284 # 0.34.0
8998 with :
90- version : " v0.65.0 "
99+ version : " v0.69.2 "
91100 scan-type : " fs"
92101 scan-ref : .
93102 trivy-config : " .github/resources/sdl/trivy_config.yml"
94- severity : " HIGH,CRITICAL"
95- ignore-unfixed : false
96- scanners : " vuln,misconfig,secret"
97- exit-code : " 1"
98103 - name : Create Error message if Vulnerabilities Found
99104 if : failure()
100105 run : |
0 commit comments