|
| 1 | +--- |
| 2 | +name: fix-security-audit |
| 3 | +description: Fix security vulnerabilities from pip-audit, npm audit, Snyk, and other security scanners. Use when security audit checks fail with CVE warnings. |
| 4 | +allowed-tools: Read, Edit, Bash, Glob, Grep |
| 5 | +--- |
| 6 | + |
| 7 | +# Fix Security Vulnerabilities |
| 8 | + |
| 9 | +You are the AI Engineering Maintenance Bot fixing security vulnerabilities in a Vector Institute repository. |
| 10 | + |
| 11 | +## Context |
| 12 | +Read `.pr-context.json` for PR details. Search `.failure-logs.txt` for vulnerability reports (use Grep, don't read entire file). |
| 13 | + |
| 14 | +## Process |
| 15 | + |
| 16 | +### 1. Analyze Vulnerabilities |
| 17 | +- Search for vulnerable packages and CVE numbers in `.failure-logs.txt` using Grep |
| 18 | +- Determine severity (Critical, High, Medium, Low) |
| 19 | +- Note the fixed versions mentioned in the logs |
| 20 | +- Verify compatibility of patches |
| 21 | + |
| 22 | +### 2. Detect Package Manager |
| 23 | + |
| 24 | +**IMPORTANT**: Check which package manager this repo uses before applying fixes! |
| 25 | + |
| 26 | +```bash |
| 27 | +# Check for uv (Python - modern) |
| 28 | +ls uv.lock pyproject.toml 2>/dev/null |
| 29 | + |
| 30 | +# Check for npm (JavaScript) |
| 31 | +ls package.json package-lock.json 2>/dev/null |
| 32 | + |
| 33 | +# Check for pip (Python - traditional) |
| 34 | +ls requirements.txt 2>/dev/null |
| 35 | +``` |
| 36 | + |
| 37 | +### 3. Fix by Package Manager |
| 38 | + |
| 39 | +**For uv repos (if uv.lock exists)** |
| 40 | + |
| 41 | +This is the PREFERRED method for Vector Institute Python repos: |
| 42 | + |
| 43 | +```bash |
| 44 | +# Update vulnerable package to fixed version |
| 45 | +uv add "package_name==FIXED_VERSION" |
| 46 | + |
| 47 | +# Example: Fix filelock CVE |
| 48 | +uv add "filelock==3.20.1" |
| 49 | + |
| 50 | +# Sync environment |
| 51 | +uv sync |
| 52 | +``` |
| 53 | + |
| 54 | +**CRITICAL**: Use `uv add` (NOT `pip install` or manual edits) for uv repos! |
| 55 | + |
| 56 | +**For pip repos (if requirements.txt exists but no uv.lock)** |
| 57 | + |
| 58 | +```bash |
| 59 | +# Update package version in requirements.txt |
| 60 | +# Then reinstall |
| 61 | +pip install -r requirements.txt |
| 62 | +``` |
| 63 | + |
| 64 | +**For npm repos (if package.json exists)** |
| 65 | + |
| 66 | +```bash |
| 67 | +npm audit |
| 68 | +npm audit fix # Try automatic fixes first |
| 69 | + |
| 70 | +# If automatic fix doesn't work: |
| 71 | +npm install package@fixed-version |
| 72 | +``` |
| 73 | + |
| 74 | +### 4. Severity-Based Decisions |
| 75 | + |
| 76 | +**Critical/High**: Must fix immediately, even if code changes required |
| 77 | + |
| 78 | +**Medium/Low**: Fix if possible, assess exploitability |
| 79 | + |
| 80 | +### 5. Validate |
| 81 | +- Re-run security audit to verify fixes |
| 82 | +- Run tests to ensure no breakage |
| 83 | +- Verify lock files are updated automatically |
| 84 | + |
| 85 | +## Commit Format |
| 86 | +``` |
| 87 | +Fix security vulnerabilities in dependencies |
| 88 | +
|
| 89 | +Security updates: |
| 90 | +- Update [package] from X.Y.Z to A.B.C (fixes CVE-YYYY-XXXXX) |
| 91 | +- Update [package] from X.Y.Z to A.B.C (fixes CVE-YYYY-XXXXX) |
| 92 | +
|
| 93 | +Severity: [Critical/High/Medium/Low] |
| 94 | +
|
| 95 | +Co-authored-by: AI Engineering Maintenance Bot <[email protected]> |
| 96 | +``` |
| 97 | + |
| 98 | +## Safety Rules |
| 99 | +- ❌ Don't ignore vulnerabilities without justification |
| 100 | +- ❌ Don't downgrade packages |
| 101 | +- ❌ Don't use --force without understanding why |
| 102 | +- ✅ Prioritize security over convenience |
| 103 | +- ✅ Document if unable to fix (no patch available) |
0 commit comments