-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(code-scanning): Update Trivy starter workflows #2430
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: trivy | ||
name: Trivy IaC Scan | ||
|
||
on: | ||
push: | ||
|
@@ -29,17 +29,15 @@ jobs: | |
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build an image from Dockerfile | ||
run: | | ||
docker build -t docker.io/my-organization/my-app:${{ github.sha }} . | ||
|
||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe | ||
- name: Run Trivy vulnerability scanner in IaC mode | ||
uses: aquasecurity/[email protected] | ||
with: | ||
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}' | ||
format: 'template' | ||
template: '@/contrib/sarif.tpl' | ||
scan-type: 'config' | ||
hide-progress: false | ||
format: 'sarif' | ||
output: 'trivy-results.sarif' | ||
exit-code: '1' | ||
ignore-unfixed: true | ||
severity: 'CRITICAL,HIGH' | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||
# This workflow uses actions that are not certified by GitHub. | ||||||
# They are provided by a third-party and are governed by | ||||||
# separate terms of service, privacy policy, and support | ||||||
# documentation. | ||||||
|
||||||
name: Trivy Repo Vulnerability Scan | ||||||
|
||||||
on: | ||||||
push: | ||||||
branches: [ $default-branch, $protected-branches ] | ||||||
pull_request: | ||||||
# The branches below must be a subset of the branches above | ||||||
branches: [ $default-branch ] | ||||||
schedule: | ||||||
- cron: $cron-weekly | ||||||
|
||||||
permissions: | ||||||
contents: read | ||||||
|
||||||
jobs: | ||||||
build: | ||||||
permissions: | ||||||
contents: read # for actions/checkout to fetch code | ||||||
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | ||||||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||||||
name: Build | ||||||
runs-on: "ubuntu-20.04" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have a reason not to use the current version of ubuntu? 20.04 EOL is <1 year away
Suggested change
|
||||||
steps: | ||||||
- name: Checkout code | ||||||
uses: actions/checkout@v3 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is stale -- the other file already uses v4
Suggested change
|
||||||
|
||||||
- name: Run Trivy vulnerability scanner in repo mode | ||||||
uses: aquasecurity/[email protected] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There have been 4 minor releases since this PR was authored...
Suggested change
|
||||||
with: | ||||||
scan-type: 'fs' | ||||||
format: 'sarif' | ||||||
output: 'trivy-results.sarif' | ||||||
severity: 'CRITICAL,HIGH' | ||||||
|
||||||
- name: Upload Trivy scan results to GitHub Security tab | ||||||
uses: github/codeql-action/upload-sarif@v2 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
with: | ||||||
sarif_file: 'trivy-results.sarif' |
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.
There have been 4 minor releases since this PR was authored...
(Note that the
runs-on
field probably should be bumped for this file as well... but that line isn't within reach of comments atm)