Add Trivy vulnerability scanning workflow and documentation

Co-authored-by: TimInTech <129355283+TimInTech@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]andTimInTech committed 2025-11-23 11:52:24 +00:00
1 parent 26046e137c
commit b5e329ad2f
3 files changed
+126 -3

No files matched your search

+45 -3
View File
@@ -7,13 +7,55 @@ Repository checks and automation baselines.
- `Sanity Checks` — runs `shellcheck` and `shfmt` on all tracked shell scripts.
- `Link Check` — validates Markdown links with `lychee`.
- `Release Drafter` — prepares changelog drafts for tagged releases.
- `Trivy Vulnerability Scan` — scans for vulnerabilities, secrets, and
misconfigurations using Trivy. Reports are saved to
`.audit/trivy-report.json` and `.audit/trivy-report.txt`.
## Manual Metrics
- Use `gh run list --limit 20 --json databaseId,createdAt,status,durationMs > .audit/ci_runs.json` to snapshot recent CI execution history.
- Add additional JSON or Markdown reports to this directory as new checks are introduced.
- Use `gh run list --limit 20 --json databaseId,createdAt,status,durationMs >
.audit/ci_runs.json` to snapshot recent CI execution history.
- Add additional JSON or Markdown reports to this directory as new checks are
introduced.
## Vulnerability Scanning
The repository uses Trivy for automated vulnerability scanning:
- **Scan Scope**: Filesystem scan covering Bash scripts, dependencies,
secrets, and misconfigurations
- **Severity Levels**: CRITICAL, HIGH, MEDIUM, LOW
- **Scan Types**:
- Vulnerability detection
- Secret scanning
- Misconfiguration detection
- **Schedule**: Runs on every push to main, pull requests, and weekly on
Mondays
- **Reports**:
- `trivy-report.json` — Machine-readable JSON format
- `trivy-report.txt` — Human-readable table format
- SARIF results uploaded to GitHub Security tab
To run Trivy scan locally:
```bash
# Install Trivy (if not already installed)
# See https://aquasecurity.github.io/trivy/latest/getting-started/installation/
# Run scan
trivy fs --severity CRITICAL,HIGH,MEDIUM,LOW --scanners vuln,secret,misconfig .
# Generate JSON report
trivy fs --severity CRITICAL,HIGH,MEDIUM,LOW --scanners vuln,secret,misconfig \
--format json --output .audit/trivy-report.json .
# Generate text report
trivy fs --severity CRITICAL,HIGH,MEDIUM,LOW --scanners vuln,secret,misconfig \
--format table --output .audit/trivy-report.txt .
```
## Security Controls
- Security contacts and disclosure process live in `SECURITY.md`.
- Enable GitHub secret scanning, vulnerability alerts, and push protection in repository settings to complete the baseline.
- Enable GitHub secret scanning, vulnerability alerts, and push protection in
repository settings to complete the baseline.
+76
View File
@@ -0,0 +1,76 @@
name: Trivy Vulnerability Scan
on:
push:
branches: [main]
pull_request:
schedule:
# Run weekly on Mondays at 00:00 UTC
- cron: '0 0 * * 1'
workflow_dispatch:
permissions:
contents: read
security-events: write
jobs:
trivy-scan:
name: Trivy Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in fs mode
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
scanners: 'vuln,secret,misconfig'
- name: Upload Trivy results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
- name: Run Trivy vulnerability scanner for JSON report
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'json'
output: '.audit/trivy-report.json'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
scanners: 'vuln,secret,misconfig'
- name: Run Trivy vulnerability scanner for human-readable report
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
output: '.audit/trivy-report.txt'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
scanners: 'vuln,secret,misconfig'
- name: Upload Trivy reports as artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: trivy-reports
path: |
.audit/trivy-report.json
.audit/trivy-report.txt
trivy-results.sarif
- name: Commit Trivy reports to repository
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .audit/trivy-report.json .audit/trivy-report.txt || true
git diff --staged --quiet || git commit -m "chore: Update Trivy vulnerability scan reports"
git push || echo "No changes to push"
+5
View File
@@ -14,6 +14,11 @@ __pycache__/
.DS_Store
Thumbs.db
# Trivy scan reports (committed via workflow)
.audit/trivy-report.json
.audit/trivy-report.txt
trivy-results.sarif
# Local test artifacts
.bin/
out.json