Skip to content
Open
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
57 changes: 57 additions & 0 deletions .github/workflows/trivy-fs-scanning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Trivy FS scanning

on:
schedule:
- cron: '0 6 * * 0' # Every Sunday at 6:00 AM UTC
workflow_dispatch:
inputs:
branch:
description: 'Branch to scan'
required: true
default: 'notebooks-v2'
type: choice
options:
- notebooks-v1
- notebooks-v2

permissions:
actions: read
security-events: write

jobs:
build:
if: github.event_name == 'workflow_dispatch' || ( github.event_name == 'schedule' && github.repository == 'kubeflow/notebooks' )
name: Trivy FS scan
runs-on: ubuntu-latest
strategy:
matrix:
branch: ${{ github.event_name == 'workflow_dispatch' && fromJSON(format('["{0}"]', github.event.inputs.branch)) || fromJSON('["notebooks-v1", "notebooks-v2"]') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}

- name: Run Trivy vulnerability scanner in fs mode
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
scanners: 'vuln,secret,misconfig'
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
exit-code: 0
output: 'trivy-fs-scan-results-${{ matrix.branch }}.sarif'

- name: Add branch metadata to SARIF
run: |
# Modify ruleId to include branch information for identification
jq '.runs[0].results[] |= (.ruleId = "trivy-fs-${{ matrix.branch }}-" + .ruleId)' \
trivy-fs-scan-results-${{ matrix.branch }}.sarif > trivy-fs-scan-results-${{ matrix.branch }}-processed.sarif
mv trivy-fs-scan-results-${{ matrix.branch }}-processed.sarif trivy-fs-scan-results-${{ matrix.branch }}.sarif

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-fs-scan-results-${{ matrix.branch }}.sarif'