-
Notifications
You must be signed in to change notification settings - Fork 22
67 lines (59 loc) · 2.77 KB
/
trivy-all.yml
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
name: Trivy Analysis (indy_node:latest)
on:
schedule:
# run every Wednesday at 23:20
- cron: '20 23 * * 3'
workflow_dispatch:
jobs:
workflow_setup:
name: Setup variables
runs-on: ubuntu-latest
outputs:
repo_owner: ${{ steps.repo_owner.outputs.lowercase }}
steps:
- name: Lowercase repo owner
id: repo_owner
run: echo "lowercase=$(echo ${{ github.repository_owner }} | tr \"[:upper:]\" \"[:lower:]\")" >> $GITHUB_OUTPUT
shell: bash
trivy_analysis:
name: Trivy Analysis of Indy Node Images
runs-on: "ubuntu-20.04"
needs: workflow_setup
strategy:
matrix:
os_version: [ debian10, debian11, ubuntu16, ubuntu18, ubuntu20 ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: indy-node-version
id: indy-node-version
shell: bash
run: |
export nodeVersion=$(sed "s/~/-/" <<<$(grep -oP "indy-node=\"?\d+.\d+.\d+((~|.)?rc\d+)?\"?" build/Dockerfile.${{ matrix.os_version }} | grep -oP "\d+.\d+.\d+((~|.|-)?rc\d+)?"))
echo "::debug::IndyNode Version is ${nodeVersion}"
echo "::group::DEBUG"
echo "IndyNode Version is ${nodeVersion}"
echo "::endgroup::"
echo "nodeVersion=${nodeVersion}">> $GITHUB_OUTPUT
- name: Run Trivy on indy_node${{ steps.indy-node-version.outputs.nodeVersion }}:${{ matrix.os_version }}
uses: aquasecurity/trivy-action@master
with:
image-ref: 'ghcr.io/${{ needs.workflow_setup.outputs.repo_owner }}/indy-node-container/indy_node:${{ steps.indy-node-version.outputs.nodeVersion }}-${{ matrix.os_version }}-main'
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-indy-node-${{ steps.indy-node-version.outputs.nodeVersion }}-${{ matrix.os_version }}.sarif'
ignore-unfixed: true
severity: 'CRITICAL,HIGH'
- name: Patch tool name for ${{ matrix.os_version }} scan
run: |
sed -i 's/"name": "Trivy",/"name": "Trivy${{ matrix.os_version }}Latest",/g' trivy-indy-node-${{ steps.indy-node-version.outputs.nodeVersion }}-${{ matrix.os_version }}.sarif
- name: 'Safe trivy-indy-node-${{ matrix.os_version }}.sarif'
uses: actions/upload-artifact@v4
with:
name: trivy-indy-node-${{ steps.indy-node-version.outputs.nodeVersion }}-${{ matrix.os_version }}.sarif
path: trivy-indy-node-${{ steps.indy-node-version.outputs.nodeVersion }}-${{ matrix.os_version }}.sarif
retention-days: 8
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-indy-node-${{ steps.indy-node-version.outputs.nodeVersion }}-${{ matrix.os_version }}.sarif'