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

Trivy dependency scanner v.final #88

Merged
merged 6 commits into from
Dec 9, 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
70 changes: 70 additions & 0 deletions .github/workflows/Trivy-Reviewdog-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: build
on:
push:
branches:
- main
pull_request:

jobs:
trivy-repo-scan:
name: Trivy Repo Scan & Upload to Security Tab
runs-on: ubuntu-20.04
permissions:
contents: write
security-events: write


steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'

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

reviewdog-pr-check:
name: Trivy PR Check
runs-on: ubuntu-latest
needs: trivy-repo-scan

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Changed Files
id: changed-files
run: |
git fetch origin main
git diff --name-only origin/main > changed-files.txt

- name: Print Changed Files
run: |
echo "Changed files:"
cat changed-files.txt

- name: Run Trivy on Changed Files
if: success()
run: |
mkdir trivy-results
while read -r file; do
echo "Scanning $file..."
trivy fs --quiet --severity HIGH,CRITICAL --format json --output trivy-results/$(basename $file).json "$file" || true
done < changed-files.txt

- name: Run Reviewdog
uses: reviewdog/action-trivy@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
trivy_command: fs
trivy_target: ./trivy-results
reporter: github-pr-review
level: error
Loading