A composite GitHub Action that performs comprehensive vulnerability scanning using Trivy to detect security issues in dependencies, container images, secrets, and misconfigurations.
- β Filesystem and container image scanning
- β Vulnerability detection (OS packages and libraries)
- β Secret scanning
- β Misconfiguration detection
- β Automatic SARIF upload to GitHub Security tab
- β Configurable severity filtering
- β Directory exclusions
Important: This action uploads results to GitHub's Code Scanning feature, which requires GitHub Advanced Security (GHAS) to be enabled for your repository.
- β Public repositories: GHAS is free and automatically available
β οΈ Private repositories: GHAS requires a paid license
- β Trivy scan runs successfully
- β Vulnerabilities, secrets, and misconfigurations are detected
- β SARIF file is generated
- β Upload to Security tab fails with error:
Advanced Security must be enabled for this repository to use code scanning
- Organization level: Organization Settings β Code security and analysis β Enable GitHub Advanced Security
- Repository level: Repository Settings β Code security and analysis β Enable GitHub Advanced Security
For more information, see GitHub's GHAS documentation.
If you cannot enable GHAS, set upload-sarif: 'false' to skip the upload step:
- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
upload-sarif: "false" # Disable upload when GHAS is not availableThis allows the scan to run and complete without errors. Results won't appear in the Security tab, but you can still view findings in the workflow logs. When GHAS is enabled, simply change to upload-sarif: 'true' or remove the parameter (defaults to true).
jobs:
trivy-scan:
name: Vulnerability Scan
runs-on: linux-amd64-cpu4
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Vulnerability Scan
uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
severity: "HIGH,CRITICAL"jobs:
scan-container:
name: Container Vulnerability Scan
runs-on: linux-amd64-cpu4
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Scan Container Image
uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "image"
scan-ref: "nvcr.io/myorg/myapp:v1.0.0"
severity: "CRITICAL,HIGH"jobs:
comprehensive-scan:
name: Comprehensive Security Scan
runs-on: linux-amd64-cpu4
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Comprehensive Scan
uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
scan-ref: "."
vuln-type: "os,library"
scanners: "vuln,secret,misconfig"
severity: "MEDIUM,HIGH,CRITICAL"
skip-dirs: "vendor,node_modules,target,test/fixtures"
ignore-unfixed: "false"| Input | Description | Required | Default |
|---|---|---|---|
scan-type |
Type of scan (fs or image) |
No | fs |
scan-ref |
Path or image reference to scan | No | . |
vuln-type |
Vulnerability types to check | No | os,library |
scanners |
Scanners to use | No | vuln,secret,misconfig |
severity |
Severity levels to report | No | HIGH,CRITICAL |
skip-dirs |
Directories to skip (comma-separated) | No | vendor,node_modules |
ignore-unfixed |
Ignore unfixed vulnerabilities | No | true |
upload-sarif |
Upload results to GitHub Security (requires GHAS) | No | true |
post-pr-comment |
Post results as PR comment (works without GHAS, needs pull-requests: write) |
No | false |
fail-on-findings |
Fail the workflow if vulnerabilities are found (quality gate). Set to false to only warn. |
No | true |
github-token |
GitHub token for uploading SARIF | No | ${{ github.token }} |
fs- Filesystem scan (scans repository files)image- Container image scan (scans Docker/OCI images)
Combine multiple scanners (comma-separated):
vuln- Vulnerability detectionsecret- Secret detection (API keys, tokens, etc.)misconfig- Misconfiguration detection (IaC, Dockerfiles, etc.)
os- OS package vulnerabilitieslibrary- Application dependency vulnerabilities
CRITICAL- Critical vulnerabilitiesHIGH- High severity vulnerabilitiesMEDIUM- Medium severity vulnerabilitiesLOW- Low severity vulnerabilities
Your workflow job must have the following permissions:
permissions:
actions: read # Required for workflow run metadata
contents: read # Required for checking out code
security-events: write # Required for uploading resultsThe action includes a quality gate feature that fails the workflow if vulnerabilities are detected:
- Enabled by default:
fail-on-findings: 'true' - Enforces security policy: Blocks PRs with vulnerabilities
- Can be disabled: Set
fail-on-findings: 'false'to only warn
- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
severity: "HIGH,CRITICAL"
fail-on-findings: "true" # Fail workflow if vulnerabilities found (default)- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
severity: "HIGH,CRITICAL"
fail-on-findings: "false" # Only warn, don't block workflowQuality Gate Output:
π Trivy Scan Results:
- Total Vulnerabilities: 5
- Critical/High: 5
β Quality Gate: FAILED
Trivy detected 5 vulnerability/vulnerabilities in the scan.
Please review and remediate the issues before merging.
Recommendation: Start with fail-on-findings: 'false' during initial rollout, then enable it once vulnerabilities are remediated.
Scan results are automatically uploaded to GitHub's Security tab under Security > Code scanning alerts.
Note: Uploading results requires GitHub Advanced Security to be enabled. See the Prerequisites section above.
Enable automated PR comments by setting post-pr-comment: true. This works even without GHAS!
- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
post-pr-comment: "true" # Post results to PR- β
pull-requests: writepermission - β
Works with:
pull_requestevents (opened, synchronized, etc.)pushevents to PR branches- Custom PR branch formats (e.g.,
refs/heads/pull-request/123)
- β Does NOT require GHAS
Without GHAS (upload-sarif: false):
## π‘οΈ Vulnerability Scan
π¨ Found **8** vulnerability(ies)
**Severity Breakdown:**
- π΄ Critical/High: 3
- π‘ Medium: 4
- π΅ Low/Info: 1
<details>
<summary>π Top Vulnerabilities</summary>
- **CVE-2024-1234**: High severity vulnerability in package X
- **CVE-2024-5678**: SQL injection in dependency Y
...
</details>
π‘ **Note**: Enable GitHub Advanced Security to see full details in the Security tab.
With GHAS (upload-sarif: true):
## π‘οΈ Vulnerability Scan
π¨ Found **8** vulnerability(ies)
**Severity Breakdown:**
- π΄ Critical/High: 3
- π‘ Medium: 4
- π΅ Low/Info: 1
<details>
<summary>π Top Vulnerabilities</summary>
- **CVE-2024-1234**: High severity vulnerability in package X
- **CVE-2024-5678**: SQL injection in dependency Y
...
</details>
π [View full details in Security tab](https://github.com/owner/repo/security/code-scanning)
name: Daily Security Scan
on:
schedule:
- cron: "0 2 * * *" # Run at 2 AM daily
jobs:
daily-scan:
runs-on: linux-amd64-cpu4
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
severity: "CRITICAL,HIGH"name: PR Security Check
on:
pull_request:
jobs:
pr-scan:
runs-on: linux-amd64-cpu4
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
severity: "HIGH,CRITICAL"
ignore-unfixed: "true"jobs:
build:
runs-on: linux-amd64-cpu4
outputs:
image-tag: ${{ steps.meta.outputs.tags }}
steps:
- uses: actions/checkout@v4
- name: Build image
# ... build steps ...
id: meta
scan:
needs: build
runs-on: linux-amd64-cpu4
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "image"
scan-ref: ${{ needs.build.outputs.image-tag }}jobs:
rust-security:
runs-on: linux-amd64-cpu4
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
scan-ref: "."
severity: "HIGH,CRITICAL"
skip-dirs: "target,vendor"jobs:
secret-scan:
runs-on: linux-amd64-cpu4
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "fs"
scanners: "secret"
severity: "HIGH,CRITICAL"Common directories to skip:
skip-dirs: "vendor,node_modules,target,dist,build,test,docs,.git"- Go:
vendor,go.sum - Rust:
target,Cargo.lock - Node.js:
node_modules,package-lock.json - Python:
venv,.venv,__pycache__ - Java:
target,.m2
Issue: No results are uploaded to GitHub Security.
Solutions:
- Check if Trivy found any vulnerabilities
- Ensure the severity level isn't too strict
- Try with
ignore-unfixed: 'false'
Issue: Scan finds too many vulnerabilities.
Solutions:
- Increase severity threshold:
severity: 'CRITICAL' - Enable
ignore-unfixed: 'true' - Add more directories to
skip-dirs
Issue: Scan takes too long and times out.
Solutions:
- Add more directories to
skip-dirs - Increase job timeout
- Split into multiple scans (e.g., separate secret scan)
Issue: Cannot scan images from private registry.
Solutions:
- Login to the registry before scanning:
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: nvcr.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Scan Image
uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main
with:
scan-type: "image"
scan-ref: "nvcr.io/private/image:tag"uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@v1.0.0uses: NVIDIA/dsx-github-actions/.github/actions/trivy-scan@main- OS package vulnerabilities (if applicable)
- Application dependencies (Go modules, Cargo.toml, package.json, etc.)
- Embedded secrets (API keys, tokens, passwords)
- IaC misconfigurations (Dockerfile, Kubernetes manifests, Terraform, etc.)
- OS package vulnerabilities
- Application dependencies
- Embedded secrets
- Container misconfigurations
Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
Licensed under the Apache License, Version 2.0.