Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions code-scanning/tfsec.yml

This file was deleted.

18 changes: 8 additions & 10 deletions code-scanning/trivy.yml → code-scanning/trivy-iac-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# separate terms of service, privacy policy, and support
# documentation.

name: trivy
name: Trivy IaC Scan

on:
push:
Expand All @@ -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]
Copy link
Contributor

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...

Suggested change
uses: aquasecurity/trivy-action@0.20.0
uses: aquasecurity/trivy-action@0.24.0

(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)

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
Expand Down
43 changes: 43 additions & 0 deletions code-scanning/trivy-vulnerability-scan.yml
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"
Copy link
Contributor

Choose a reason for hiding this comment

The 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
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"

steps:
- name: Checkout code
uses: actions/checkout@v3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is stale -- the other file already uses v4

Suggested change
uses: actions/checkout@v3
uses: actions/checkout@v4


- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/[email protected]
Copy link
Contributor

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...

Suggested change
uses: aquasecurity/trivy-action@0.20.0
uses: aquasecurity/trivy-action@0.24.0

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3

with:
sarif_file: 'trivy-results.sarif'
Loading