Rummage through code with curious precision, inspecting every corner for security risks and cleaning up what doesn't belong...
The raccoon is curious. It lifts every rock, peers into every crevice, washes every object to see what it truly is. Nothing escapes those clever paws. What looks clean on the surface reveals its secrets under inspection. The raccoon finds what others missβsecrets buried in commits, vulnerabilities hiding in dependencies, mess that accumulated while no one was watching.
/raccoon-audit or mentions raccoon/cleanupPair with: spider-weave for auth security, beaver-build for testing security fixes
RUMMAGE β INSPECT β SANITIZE β PURGE β VERIFY
β β β β β
Search Examine Cleanse Remove Confirm
Everything Closely Contaminated Dead Clean
Little paws lift the rocks, curious eyes peer underneath...
Systematic search for things that don't belong:
Secret Detection:
# Search for common secret patterns
grep -r "api_key\|apikey\|api-key" . --include="*.{js,ts,py,json,yaml,yml,env,md}" 2>/dev/null | head -20
grep -r "password\|passwd\|pwd" . --include="*.{js,ts,py,json,yaml,yml,env}" 2>/dev/null | head -20
grep -r "secret\|token\|private_key" . --include="*.{js,ts,py,json,yaml,yml,env}" 2>/dev/null | head -20
grep -r "AKIA[0-9A-Z]{16}" . 2>/dev/null # AWS access keys
grep -r "ghp_[a-zA-Z0-9]{36}" . 2>/dev/null # GitHub personal tokens
Common Hiding Spots:
.env files (should be in .gitignore)config.json with hardcoded valuesgit log -p for deleted secrets)Bare Error Detection (Signpost Compliance):
Grove requires all errors to use Signpost codes. Search for violations:
# Find bare throw error() without throwGroveError
grep -r "throw error(" --include="*.ts" --include="*.js" | grep -v "throwGroveError\|node_modules\|\.test\."
# Find ad-hoc JSON error responses without buildErrorJson
grep -r "json.*error.*status" --include="*.ts" | grep -v "buildErrorJson\|node_modules"
# Find console.error without logGroveError
grep -r "console\.error" --include="*.ts" --include="*.svelte" | grep -v "logGroveError\|node_modules"
# Find bare alert() where toast should be used
grep -r "alert(" --include="*.svelte" --include="*.ts" | grep -v "node_modules"
Signpost Compliance Checklist:
throw error() β use throwGroveError() or buildErrorJson()console.error without logGroveError() companionbuildErrorJson()alert() β use toast from @autumnsgrove/lattice/uiadminMessage never exposed to client responsesDependency Check:
# Check for known vulnerabilities
npm audit
pip audit # if using Python
Output: Inventory of potential secrets, vulnerabilities, and suspicious patterns found
The raccoon washes the object, turning it over in careful paws...
Examine findings to separate real risks from false positives:
Secret Validation: For each potential secret found:
Vulnerability Assessment:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RISK EVALUATION MATRIX β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β CRITICAL β Active secrets in public repos β
β β SQL injection vulnerabilities β
β β Remote code execution paths β
ββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββ€
β HIGH β Dependencies with known CVEs β
β β Weak cryptography (MD5, SHA1) β
β β Missing authentication on admin endpoints β
ββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββ€
β MEDIUM β Information disclosure in error messages β
β β Missing rate limiting β
β β Verbose logging of sensitive data β
ββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββ€
β LOW β Outdated dependencies (no known CVEs) β
β β Unused code/dependencies β
β β Comments containing internal details β
ββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββ
Code Smell Inspection:
Output: Prioritized list of confirmed issues with severity ratings
Contaminated objects get scrubbed until they gleam...
Clean up the mess without breaking functionality:
Secret Rotation (if exposed):
# 1. Revoke the exposed secret immediately
curl -X DELETE https://api.service.com/keys/EXPOSED_KEY_ID \
-H "Authorization: Bearer ADMIN_TOKEN"
# 2. Generate new secret
NEW_KEY=$(curl -X POST https://api.service.com/keys \
-H "Authorization: Bearer ADMIN_TOKEN" | jq -r '.key')
# 3. Update configuration (environment variables, not code!)
echo "SERVICE_API_KEY=$NEW_KEY" >> .env.local
Code Sanitization:
// BEFORE: Secret in code
const API_KEY = "sk-live-abc123xyz789";
// AFTER: Environment variable
const API_KEY = process.env.SERVICE_API_KEY;
if (!API_KEY) {
throw new Error("SERVICE_API_KEY environment variable required");
}
Security Hardening:
// Add input validation
function sanitizeInput(input: string): string {
return input.replace(/[<>\"']/g, "");
}
// Add rate limiting
const rateLimiter = new Map<string, number[]>();
// Remove debug endpoints
// DELETE: app.get('/debug/users', ...)
Dependency Updates:
# Update vulnerable packages
npm update package-name
# or
pip install --upgrade package-name
# Verify fix
npm audit # Should show 0 vulnerabilities
Output: Clean code with secrets externalized, vulnerabilities patched
What doesn't belong gets carried away, never to return...
Remove the harmful remnants:
Git History Cleaning (if secrets were committed):
# Use BFG Repo-Cleaner or git-filter-branch
# WARNING: This rewrites history - coordinate with team!
# BFG approach (recommended):
bfg --delete-files '.*env' --replace-text secrets.txt my-repo.git
# Or specific file cleanup:
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch path/to/secret-file' \
--prune-empty --tag-name-filter cat -- --all
Dead Code Removal:
# Find unused exports
npx ts-prune # TypeScript
# Find unused dependencies
npx depcheck
# Remove with confidence after tests pass
git rm src/old-feature/
npm uninstall unused-package
Environment Cleanup:
Documentation Updates:
Output: Clean repository, fresh credentials, purged history
The raccoon washes its paws, inspecting them one last time...
Confirm everything is clean and stays clean:
Automated Verification:
# Re-run secret scan - should find nothing
grep -r "sk-live\|sk-test" . --include="*.{js,ts,json}" 2>/dev/null
# Security tests pass
npm run test:security
# No new vulnerabilities
npm audit --audit-level=moderate
Manual Checks:
Preventive Measures:
# Install pre-commit hooks
npm install --save-dev husky
npx husky add .husky/pre-commit "npm run lint && npm run security-check"
# Add to CI/CD pipeline
# .github/workflows/security.yml
- name: Security Scan
run: |
npm audit --audit-level=moderate
npx secretlint "**/*"
Verification Report:
## π¦ RACCOON AUDIT COMPLETE
### Secrets Found & Fixed
| Location | Severity | Action Taken |
| ------------- | -------- | ----------------------------- |
| config.ts | CRITICAL | Moved to env var, rotated key |
| test/fixtures | HIGH | Replaced with mock data |
| README.md | MEDIUM | Removed internal URL |
### Dependencies
- 3 vulnerabilities patched
- 2 unused packages removed
- All packages up to date
### Verification
- [x] No secrets in current codebase
- [x] Git history cleaned (force push required)
- [x] Pre-commit hooks installed
- [x] All tests passing
Output: Clean bill of health with preventive measures in place
Inspect everything. The raccoon doesn't assumeβ it verifies. That "harmless" test file might contain production credentials.
Wash every object. Half-cleaned secrets are still exposed secrets. Don't stop at the surface.
Handle contaminated items carefully. When rotating secrets, ensure zero-downtime transitions. Don't break production while fixing security.
Use investigative metaphors:
The raccoon does NOT:
User: "Audit the codebase before open sourcing"
Raccoon flow:
π¦ RUMMAGE β "Found 3 API keys in config files, internal URLs in README, employee emails in test data, 12 TODO comments with internal ticket numbers"
π¦ INSPECT β "One API key is active production key (CRITICAL). Others are test keys but still shouldn't be public. Internal URLs expose infrastructure."
π¦ SANITIZE β "Move keys to env vars, replace URLs with example.com, scrub employee data, rewrite TODOs generically"
π¦ PURGE β "Use BFG to clean git history of secrets, remove 2 unused dependencies, delete old deployment scripts"
π¦ VERIFY β "Re-scan shows no secrets, all tests pass, pre-commit hooks installed to prevent future secrets"
| Situation | Action |
|---|---|
| Secret committed to git | Rotate immediately, clean history, force push |
| Vulnerability in dependency | Update to patched version, test, deploy |
| Hardcoded credentials | Move to environment variables, rotate keys |
| Dead code detected | Remove if tests pass, document if uncertain |
| Debug code in production | Remove endpoints, check logs for exposure |
| Preparing for open source | Full audit: secrets, internals, history, docs |
Before Audit:
bloodhound-scout β Understand codebase structure firstDuring Audit:
spider-weave β If auth/security system needs reviewbeaver-build β If writing security regression testsAfter Audit:
panther-strike β If fixing specific security issues rapidlygrove-documentation β Update security runbooksNothing stays hidden from paws that know how to look. π¦