Merge pull request #15 from TimInTech/copilot/set-up-vulnerability-scan

Add Trivy vulnerability scanning workflow
This commit is contained in:
==TIM.©.B == authored and GitHub committed 2025-12-14 17:13:27 +01:00
commit 5e62830768
3 files changed
+117 -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, weekly on Mondays,
and manual workflow dispatch
- **Reports**:
- `trivy-report.json` — Machine-readable JSON format (workflow artifact)
- `trivy-report.txt` — Human-readable table format (workflow artifact)
- 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.
+67
View File
@@ -0,0 +1,67 @@
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@0.28.0
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@0.28.0
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@0.28.0
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
+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