Skip to content

Commit 77c11d0

Browse files
author
hubert.siwik
committed
feat: Add Trivy scanner to the pipeline
1 parent 1ef072c commit 77c11d0

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.github/workflows/cron.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# In your scan workflow, set TRIVY_SKIP_DB_UPDATE=true.
2+
name: Update the trivy cache
3+
4+
on:
5+
schedule:
6+
- cron: '0 0 * * *' # Run daily at midnight UTC
7+
workflow_dispatch: # Allow manual triggering
8+
9+
jobs:
10+
update-trivy-db:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Get current date
14+
id: date
15+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
16+
17+
- name: Download and extract the vulnerability DB
18+
run: |
19+
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db
20+
oras pull ghcr.io/aquasecurity/trivy-db:2
21+
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db
22+
rm db.tar.gz
23+
24+
- name: Cache DBs
25+
uses: actions/cache/save@v4
26+
with:
27+
path: ${{ github.workspace }}/.cache/trivy
28+
key: cache-trivy-${{ steps.date.outputs.date }}

.github/workflows/verifyimage.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ jobs:
6060
load: true
6161
push: false
6262

63+
- name: Scan ${{ matrix.target }}
64+
uses: aquasecurity/trivy-action@0.27.0
65+
with:
66+
image-ref: "${REPO}:${{ matrix.target }}"
67+
format: 'table'
68+
exit-code: '1'
69+
ignore-unfixed: true
70+
vuln-type: 'os,library'
71+
severity: 'CRITICAL,HIGH,MEDIUM'
72+
env:
73+
TRIVY_SKIP_DB_UPDATE: true
74+
6375
- name: Run ${{ matrix.target }}
6476
run: |
6577
echo "Starting container ${{ matrix.target }}"

0 commit comments

Comments
 (0)