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

Add Trivy scan for release branches #205

Merged
merged 4 commits into from
Nov 15, 2024
Merged
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
28 changes: 26 additions & 2 deletions .github/workflows/trivy.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
name: Trivy

on:
pull_request:
schedule:
- cron: '0 10 * * *'

jobs:
list-branches-to-scan:
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.branches.outputs.branches }}
steps:
- name: Checking out repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: List branches to scan
id: branches
run: |
# regex matches branches like
# origin/1.28
# origin/v1.1
# origin/release-1.30
# origin/master
# origin/main
BRANCHES=$(git branch -r | grep -E '^ origin\/(((v|release-)?[0-9]+.[0-9]+)|(master|main))$' | \
sed -e 's#^ origin/##' | jq -R -s -c 'split("\n")[:-1]')
maci3jka marked this conversation as resolved.
Show resolved Hide resolved
echo "branches=$(echo $BRANCHES)" >> $GITHUB_OUTPUT
scan:
runs-on: ubuntu-latest
needs: list-branches-to-scan
strategy:
matrix:
branch: [master]
branch: ${{ fromJson(needs.list-branches-to-scan.outputs.branches) }}
permissions:
security-events: write
steps:
- name: Checking out repo
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@0.28.0
with:
Expand All @@ -26,6 +48,8 @@ jobs:
format: "sarif"
output: "output.sarif"
severity: "MEDIUM,HIGH,CRITICAL"
env:
TRIVY_DB_REPOSITORY: "public.ecr.aws/aquasecurity/trivy-db"
- name: Get commit sha
run: |
SHA="$(git rev-parse HEAD)"
Expand Down
Loading