-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (73 loc) · 2.35 KB
/
trivy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: trivy
on:
push:
branches:
- 2/edge
pull_request:
workflow_call:
inputs:
branch:
type: string
default: ''
jobs:
build:
uses: ./.github/workflows/build.yaml
with:
branch: ${{ inputs.branch }}
scan:
name: Trivy scan and sbom generation
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Download rock file
uses: actions/download-artifact@v4
with:
name: charmed_opensearch_rock_amd64
path: .
- name: Install rockcraft (for skopeo)
run: |
sudo snap install rockcraft --classic --edge
- name: Get Artifact Name
id: artifact
run: |
BASE_ARTIFACT=$(make help | grep 'Artifact: ')
echo "base_artifact_name=${BASE_ARTIFACT#'Artifact: '}" >> $GITHUB_OUTPUT
- name: Import locally
run: |
# Unpack artifact
sudo rockcraft.skopeo --insecure-policy copy \
docker-archive:charmed_opensearch_rock_amd64 \
docker-daemon:trivy/charmed_opensearch_rock_amd64:test
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'trivy/charmed_opensearch_rock_amd64:test'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'MEDIUM,HIGH,CRITICAL'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'
ref: ${{ inputs.branch }}
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
uses: aquasecurity/[email protected]
with:
scan-type: 'image'
format: 'spdx-json'
output: 'dependency-results.sbom.json'
image-ref: 'trivy/charmed_opensearch_rock_amd64:test'
github-pat: ${{ secrets.GITHUB_TOKEN }}
severity: "MEDIUM,HIGH,CRITICAL"
scanners: "vuln"
- name: Upload trivy report as a Github artifact
uses: actions/upload-artifact@v4
with:
name: trivy-sbom-report
path: '${{ github.workspace }}/dependency-results.sbom.json'
retention-days: 90