Skip to content

Commit 948cf7c

Browse files
authored
Merge pull request #152 from puppetlabs/cdpe-7069/download-trivy-db-separately-puppet-dev-tools
(CDPE-7069) Start caching trivy DBs in separate workflow
2 parents 9044ac5 + 3886c42 commit 948cf7c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# https://github.com/aquasecurity/trivy-action?tab=readme-ov-file#updating-caches-in-the-default-branch
2+
# This workflow is needed to get around rate limiting on ghcr. This will update the trivy DBs in the
3+
# github cache to allow the trivy scans themselves to run without pulling the DB. This will allow the
4+
# scans to run without running into rate limit issues. This workflow could run into those issues when
5+
# downloading the cache, but as long as it succeeds more often than it fails, we will have our bases
6+
# covered.
7+
name: Update Trivy DB Caches
8+
9+
on:
10+
workflow_dispatch:
11+
schedule:
12+
- cron: '17 2 * * *' # Daily at random time (2:17am UTC)
13+
14+
jobs:
15+
update-caches:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Setup oras
19+
uses: oras-project/setup-oras@v1
20+
21+
- name: Get current date
22+
id: date
23+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
24+
25+
- name: Download and extract the vulnerability DB
26+
run: |
27+
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db
28+
oras pull ghcr.io/aquasecurity/trivy-db:2
29+
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db
30+
rm db.tar.gz
31+
32+
- name: Download and extract the Java DB
33+
run: |
34+
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db
35+
oras pull ghcr.io/aquasecurity/trivy-java-db:1
36+
tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db
37+
rm javadb.tar.gz
38+
39+
- name: Cache DBs
40+
uses: actions/cache/save@v4
41+
with:
42+
path: ${{ github.workspace }}/.cache/trivy
43+
key: cache-trivy-${{ steps.date.outputs.date }}

0 commit comments

Comments
 (0)