1- # This workflow uses actions that are not certified by GitHub.
2- # They are provided by a third-party and are governed by
3- # separate terms of service, privacy policy, and support
4- # documentation.
5-
61name : trivy
72
83on :
94 push :
105 branches : [ "main" ]
116 pull_request :
12- # The branches below must be a subset of the branches above
137 branches : [ "main" ]
148 schedule :
159 - cron : ' 29 6 * * 2'
@@ -18,31 +12,59 @@ permissions:
1812 contents : read
1913
2014jobs :
21- build :
15+ image-scan :
2216 permissions :
23- contents : read # for actions/checkout to fetch code
24- security-events : write # for github/codeql-action/upload-sarif to upload SARIF results
25- actions : read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
26- name : Build
17+ contents : read
18+ security-events : write
19+ actions : read
20+ name : Image Scan
2721 runs-on : ubuntu-latest
2822 steps :
2923 - name : Checkout code
3024 uses : actions/checkout@v4
3125
32- - name : Build an image from Dockerfile
26+ - name : Build image from .devcontainer/ Dockerfile
3327 run : |
34- docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
28+ docker build -t ghcr.io/ona-samples/github-security:${{ github.sha }} -f .devcontainer/Dockerfile .
29+
30+ - name : Run Trivy image scanner
31+ uses : aquasecurity/trivy-action@0.28.0
32+ with :
33+ image-ref : ' ghcr.io/ona-samples/github-security:${{ github.sha }}'
34+ format : ' sarif'
35+ output : ' trivy-image-results.sarif'
36+ severity : ' CRITICAL,HIGH'
37+
38+ - name : Upload image scan results to GitHub Security tab
39+ uses : github/codeql-action/upload-sarif@v3
40+ if : always()
41+ with :
42+ sarif_file : ' trivy-image-results.sarif'
43+ category : ' trivy-image'
44+
45+ fs-scan :
46+ permissions :
47+ contents : read
48+ security-events : write
49+ actions : read
50+ name : Filesystem Scan
51+ runs-on : ubuntu-latest
52+ steps :
53+ - name : Checkout code
54+ uses : actions/checkout@v4
3555
36- - name : Run Trivy vulnerability scanner
37- uses : aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe
56+ - name : Run Trivy filesystem scanner
57+ uses : aquasecurity/trivy-action@0.28.0
3858 with :
39- image-ref : ' docker.io/my-organization/my-app:${{ github.sha }} '
40- format : ' template '
41- template : ' @/contrib/ sarif.tpl '
42- output : ' trivy-results.sarif'
59+ scan-type : ' fs '
60+ scan-ref : ' . '
61+ format : ' sarif'
62+ output : ' trivy-fs- results.sarif'
4363 severity : ' CRITICAL,HIGH'
4464
45- - name : Upload Trivy scan results to GitHub Security tab
65+ - name : Upload filesystem scan results to GitHub Security tab
4666 uses : github/codeql-action/upload-sarif@v3
67+ if : always()
4768 with :
48- sarif_file : ' trivy-results.sarif'
69+ sarif_file : ' trivy-fs-results.sarif'
70+ category : ' trivy-fs'
0 commit comments