Automated CVE Response Workflows
Automated CVE Response Workflows
Implement automated workflows for CVE detection and response:
# .github/workflows/cve-response.yml
name: Automated CVE Response
on:
schedule:
- cron: '0 */6 * * *' # Every 6 hours
workflow_dispatch:
jobs:
scan-and-respond:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install -r requirements.txt
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
- name: Scan all images
id: scan
run: |
python scripts/scan_all_images.py > scan_results.json
- name: Analyze CVEs
id: analyze
run: |
python scripts/analyze_cves.py scan_results.json > cve_analysis.json
# Check for critical CVEs
CRITICAL_COUNT=$(jq '.summary.critical_count' cve_analysis.json)
echo "critical_count=$CRITICAL_COUNT" >> $GITHUB_OUTPUT
# Check for exploitable CVEs
EXPLOITABLE=$(jq '.summary.exploitable_count' cve_analysis.json)
echo "exploitable_count=$EXPLOITABLE" >> $GITHUB_OUTPUT
- name: Generate patches
if: steps.analyze.outputs.critical_count > 0
run: |
python scripts/generate_patches.py cve_analysis.json
- name: Create pull requests
if: steps.analyze.outputs.critical_count > 0
uses: peter-evans/create-pull-request@v5
with:
commit-message: 'fix: automated CVE remediation'
title: '[Security] Automated CVE fixes'
body: |
## Automated CVE Remediation
This PR contains automated fixes for detected CVEs:
- Critical CVEs: ${{ steps.analyze.outputs.critical_count }}
- Exploitable CVEs: ${{ steps.analyze.outputs.exploitable_count }}
### Changes
- Updated base images to patched versions
- Upgraded vulnerable dependencies
- Applied security configurations
Please review carefully before merging.
branch: automated-cve-fixes
labels: security, automated
- name: Send alerts
if: steps.analyze.outputs.exploitable_count > 0
run: |
python scripts/send_security_alerts.py cve_analysis.json
- name: Update security dashboard
if: always()
run: |
python scripts/update_dashboard.py cve_analysis.json