|
| 1 | +--- |
| 2 | +description: Security Checklist before pushing or releasing |
| 3 | +--- |
| 4 | + |
| 5 | +# Security Checklist |
| 6 | + |
| 7 | +Run this checklist before pushing code or creating releases to prevent sensitive data leaks. |
| 8 | + |
| 9 | +## 🚨 Critical Checks |
| 10 | + |
| 11 | +### 1. Check for Sensitive Files |
| 12 | +Run these commands to verify no secrets are being tracked: |
| 13 | + |
| 14 | +```bash |
| 15 | +# Check for environment files |
| 16 | +git ls-files .env *.env |
| 17 | + |
| 18 | +# Check for keys and certificates |
| 19 | +git ls-files "*.key" "*.pem" "*.p12" "*.pfx" "id_rsa*" |
| 20 | + |
| 21 | +# Check for other sensitive data folders |
| 22 | +git ls-files "release/" "dist/" "node_modules/" |
| 23 | +``` |
| 24 | +✅ **Expected Output:** Should be empty. |
| 25 | + |
| 26 | +### 2. Verify .gitignore |
| 27 | +Ensure `.gitignore` contains at least: |
| 28 | + |
| 29 | +```gitignore |
| 30 | +# Security |
| 31 | +.env |
| 32 | +*.env |
| 33 | +*.pem |
| 34 | +*.key |
| 35 | +*.p12 |
| 36 | +*.pfx |
| 37 | +*.keystore |
| 38 | +
|
| 39 | +# Build Artifacts |
| 40 | +node_modules |
| 41 | +dist |
| 42 | +release |
| 43 | +build |
| 44 | +``` |
| 45 | + |
| 46 | +### 3. Scan for Keywords |
| 47 | +Search your codebase for potential leaked keys (excluding lockfiles): |
| 48 | + |
| 49 | +```bash |
| 50 | +grep -r "KEY" . --exclude-dir={node_modules,dist,release,.git} --exclude=package-lock.json |
| 51 | +grep -r "SECRET" . --exclude-dir={node_modules,dist,release,.git} --exclude=package-lock.json |
| 52 | +grep -r "PASSWORD" . --exclude-dir={node_modules,dist,release,.git} --exclude=package-lock.json |
| 53 | +``` |
| 54 | + |
| 55 | +## 🛡️ Remediation |
| 56 | +If you find you have accidentally committed a secret: |
| 57 | + |
| 58 | +1. **Remove from history immediately:** |
| 59 | + ```bash |
| 60 | + git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch YOUR_FILE' --prune-empty --tag-name-filter cat -- --all |
| 61 | + ``` |
| 62 | +2. **Force push:** |
| 63 | + ```bash |
| 64 | + git push origin main --force |
| 65 | + ``` |
| 66 | +3. **Rotate the leaked key:** Assume the key is compromised and generate a new one immediately. |
0 commit comments