-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: pull trivy DB from public AWS ECR #84
Merged
+6
−0
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1bcc694
ci: schedule and cache daily Trivy DB download
DavSanchez f2cec20
ci: disable DB download from Trivy action as already cached
DavSanchez 1f03e76
ci: callable workflow
DavSanchez bb741a1
ci: pull trivy DB from public AWS ECR
DavSanchez cf26b08
ci: do not schedule DB downloads
DavSanchez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Update Trivy Cache | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' # Update daily at 00:00 - before scheduled trivy scan | ||
workflow_dispatch: # Allow manual triggering | ||
|
||
jobs: | ||
update-trivy-db: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Setup oras | ||
uses: oras-project/setup-oras@v1 | ||
|
||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Download and extract the vulnerability DB | ||
run: | | ||
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db | ||
# try GHCR, fallback to ECR | ||
{ oras pull ghcr.io/aquasecurity/trivy-db:2 } || { oras pull public.ecr.aws/aquasecurity/trivy-db:2 } | ||
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db | ||
rm db.tar.gz | ||
|
||
# Also recommended by trivy docs for non-java projects as jars could be embedded in unexpected places | ||
- name: Download and extract the Java DB | ||
run: | | ||
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db | ||
# try GHCR, fallback to ECR | ||
{ oras pull ghcr.io/aquasecurity/trivy-java-db:1 } || { oras pull public.ecr.aws/aquasecurity/trivy-java-db:1 } | ||
tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db | ||
rm javadb.tar.gz | ||
|
||
- name: Cache DBs | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ${{ github.workspace }}/.cache/trivy | ||
key: cache-trivy-${{ steps.date.outputs.date }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,10 @@ jobs: | |
severity: 'HIGH,CRITICAL' | ||
skip-dirs: "${{ inputs.skip-dirs }}" | ||
skip-files: "${{ inputs.skip-files }}" | ||
env: | ||
# dbs are downloaded async in download_trivy_db.yml | ||
TRIVY_SKIP_DB_UPDATE: true | ||
TRIVY_SKIP_JAVA_DB_UPDATE: true | ||
|
||
- name: Run Trivy vulnerability scanner sarif output | ||
uses: aquasecurity/[email protected] | ||
|
@@ -47,6 +51,10 @@ jobs: | |
output: 'trivy-results.sarif' | ||
skip-dirs: "${{ inputs.skip-dirs }}" | ||
skip-files: "${{ inputs.skip-files }}" | ||
env: | ||
# dbs are downloaded async in download_trivy_db.yml | ||
TRIVY_SKIP_DB_UPDATE: true | ||
TRIVY_SKIP_JAVA_DB_UPDATE: true | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v3 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want to make it reusable you should add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 If we make this reusable, we we'll also need to open 20+ PRs for all the repositories using them, right? I guess we cannot have a cross-repo cache...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these PRs need to be open as well to reference this one, yes 🫠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 1f03e76