[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EQ9WEZMB03K1PHXFY0ACCS":3,"skill-same:01M6EQ9WEZMB03K1PHXFY0ACCS":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":34,"frontMatter":35,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":39,"repositoryHtmlUrl":40,"repositoryHomepageUrl":41,"ownerHtmlUrl":42,"ownerBlogUrl":6,"ownerDescription":43,"updatedAt":44,"install":45,"resources":58},"01M6EQ9WEZMB03K1PHXFY0ACCS","secret-scanner",null,"Detect accidentally committed secrets, credentials, and sensitive information in code.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fcuriouslearner\u002Fsecret-scanner\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[24,25,26,27,28,29,30],"scanner","secret scanner","code","credentials","secrets","detect","information","2026-11-10 10:12:30",false,"---\nname: secret-scanner\ndescription: Detect accidentally committed secrets, credentials, and sensitive information in code.\n---\n\n# Secret Scanner Skill\n\nDetect accidentally committed secrets, credentials, and sensitive information in code.\n\n## Instructions\n\nYou are a secret detection expert. When invoked:\n\n1. **Scan for Secrets**:\n   - API keys and tokens\n   - Passwords and credentials\n   - Private keys and certificates\n   - Database connection strings\n   - OAuth tokens and secrets\n   - Cloud provider credentials (AWS, GCP, Azure)\n   - Encryption keys\n\n2. **Pattern Detection**:\n   - Regex-based secret detection\n   - Entropy analysis for high-randomness strings\n   - Known secret patterns (AWS keys, GitHub tokens, etc.)\n   - Custom secret patterns\n   - File type analysis (.env, config files)\n   - Comment analysis (TODO: remove this key)\n\n3. **Contextual Analysis**:\n   - Distinguish real secrets from examples\u002Ftest data\n   - Check if secrets are in version control history\n   - Identify false positives\n   - Determine secret exposure scope\n   - Check if secrets are still active\n\n4. **Risk Assessment**:\n   - Classify severity (Critical, High, Medium, Low)\n   - Determine potential impact\n   - Check if secret has been exposed publicly\n   - Assess exploitability\n   - Identify affected systems\n\n5. **Generate Report**: Create comprehensive secret exposure report with remediation steps\n\n## Secret Types and Patterns\n\n### Cloud Provider Credentials\n\n#### AWS\n```regex\n# AWS Access Key ID\nAKIA[0-9A-Z]{16}\n\n# AWS Secret Access Key\n[0-9a-zA-Z\u002F+=]{40}\n\n# AWS Session Token\n[A-Za-z0-9\u002F+=]{200,}\n```\n\n#### Google Cloud\n```regex\n# GCP API Key\nAIza[0-9A-Za-z-_]{35}\n\n# GCP Service Account\n\"type\": \"service_account\"\n```\n\n#### Azure\n```regex\n# Azure Storage Key\n[a-zA-Z0-9+\u002F]{88}==\n\n# Azure Client Secret\n[0-9a-zA-Z-_~]{34,}\n```\n\n### Version Control Tokens\n\n#### GitHub\n```regex\n# GitHub Personal Access Token\nghp_[0-9a-zA-Z]{36}\n\n# GitHub OAuth Token\ngho_[0-9a-zA-Z]{36}\n\n# GitHub App Token\n(ghu|ghs)_[0-9a-zA-Z]{36}\n```\n\n#### GitLab\n```regex\nglpat-[0-9a-zA-Z-_]{20}\n```\n\n### Database Credentials\n```regex\n# MongoDB Connection String\nmongodb(\\+srv)?:\u002F\u002F[^\\s]+\n\n# PostgreSQL Connection String\npostgres(ql)?:\u002F\u002F[^\\s]+\n\n# MySQL Connection String\nmysql:\u002F\u002F[^\\s]+\n\n# Generic DB Password\n(password|pwd|pass)\\s*[:=]\\s*['\"][^'\"]+['\"]\n```\n\n### API Keys and Tokens\n```regex\n# Generic API Key\napi[_-]?key\\s*[:=]\\s*['\"][^'\"]+['\"]\n\n# Stripe\nsk_live_[0-9a-zA-Z]{24,}\n\n# Slack\nxox[baprs]-[0-9a-zA-Z-]{10,}\n\n# Twilio\nSK[0-9a-fA-F]{32}\n\n# SendGrid\nSG\\.[0-9A-Za-z\\-_]{22}\\.[0-9A-Za-z\\-_]{43}\n```\n\n### Private Keys\n```regex\n-----BEGIN (RSA|DSA|EC|OPENSSH|PGP) PRIVATE KEY-----\n```\n\n### JWT Tokens\n```regex\neyJ[A-Za-z0-9-_=]+\\.eyJ[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+\u002F=]*\n```\n\n## Usage Examples\n\n```\n@secret-scanner\n@secret-scanner --severity high\n@secret-scanner --git-history\n@secret-scanner src\u002F\n@secret-scanner --include-env-files\n@secret-scanner --entropy-check\n@secret-scanner --report\n```\n\n## Scanning Commands\n\n### Using git-secrets\n```bash\n# Install git-secrets\nbrew install git-secrets  # macOS\n# or\ngit clone https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fgit-secrets.git\n\n# Initialize\ngit secrets --install\ngit secrets --register-aws\n\n# Scan repository\ngit secrets --scan\ngit secrets --scan-history\n\n# Add custom patterns\ngit secrets --add 'api[_-]?key\\s*[:=]\\s*['\"'\"'][^'\"'\"']+['\"'\"']'\ngit secrets --add 'password\\s*[:=]\\s*['\"'\"'][^'\"'\"']+['\"'\"']'\n```\n\n### Using truffleHog\n```bash\n# Install\npip install truffleHog\n\n# Scan repository\ntrufflehog git file:\u002F\u002F. --json\n\n# Scan remote repository\ntrufflehog git https:\u002F\u002Fgithub.com\u002Fuser\u002Frepo.git\n\n# Scan with high entropy only\ntrufflehog git file:\u002F\u002F. --entropy-only\n\n# Scan specific branch\ntrufflehog git file:\u002F\u002F. --branch main\n```\n\n### Using gitleaks\n```bash\n# Install\nbrew install gitleaks  # macOS\n\n# Scan repository\ngitleaks detect --source . --verbose\n\n# Scan with report\ngitleaks detect --source . --report-format json --report-path report.json\n\n# Scan uncommitted files\ngitleaks protect --staged\n\n# Scan git history\ngitleaks detect --source . --log-opts \"--all\"\n```\n\n### Using detect-secrets\n```bash\n# Install\npip install detect-secrets\n\n# Create baseline\ndetect-secrets scan > .secrets.baseline\n\n# Audit baseline\ndetect-secrets audit .secrets.baseline\n\n# Scan for new secrets\ndetect-secrets scan --baseline .secrets.baseline\n```\n\n### Using custom grep patterns\n```bash\n# Scan for AWS keys\ngrep -r \"AKIA[0-9A-Z]\\{16\\}\" .\n\n# Scan for private keys\ngrep -r \"BEGIN.*PRIVATE KEY\" .\n\n# Scan for passwords\ngrep -ri \"password\\s*=\\s*['\\\"]\" . --include=\"*.js\" --include=\"*.py\"\n\n# High entropy strings\ngrep -r \"[a-zA-Z0-9]\\{32,\\}\" .\n```\n\n## Secret Scanner Report Format\n\n```markdown\n# Secret Scanner Report\n\n**Repository**: my-application\n**Scan Date**: 2024-01-15 14:30:00 UTC\n**Branch**: main\n**Commits Scanned**: 1,234\n**Files Scanned**: 456\n\n---\n\n## Executive Summary\n\n? **CRITICAL SECURITY ISSUE DETECTED**\n\n**Total Secrets Found**: 12\n- Critical: 4\n- High: 3\n- Medium: 3\n- Low: 2\n\n**Immediate Actions Required**: 4 secrets need rotation NOW\n\n---\n\n## Critical Secrets (4)\n\n### ? AWS Access Key Exposed\n**Severity**: Critical\n**File**: src\u002Fconfig\u002Faws.js\n**Line**: 12\n**Commit**: a3f5c2b (2024-01-10)\n**Age**: 5 days\n\n**Secret Found**:\n```javascript\nconst AWS_ACCESS_KEY_ID = 'AKIAIOSFODNN7EXAMPLE';\nconst AWS_SECRET_ACCESS_KEY = 'wJalrXUtnFEMI\u002FK7MDENG\u002FbPxRfiCYEXAMPLEKEY';\n```\n\n**Pattern Match**: AWS Access Key ID pattern\n**Entropy Score**: 4.2 (High)\n\n**Risk Assessment**:\n- **Impact**: CRITICAL - Full AWS account access\n- **Scope**: All AWS resources in the account\n- **Exploitability**: HIGH - Key is in public repository\n- **Data at Risk**: Production databases, S3 buckets, EC2 instances\n\n**Exposure**:\n- ✅ Committed to repository: Yes\n- ✅ Pushed to remote: Yes\n- ✅ In public repository: Yes\n- ⚠️  Visible in GitHub: Since 2024-01-10\n- ⚠️  Present in 5 commits\n\n**Immediate Actions**:\n1. ✅ ROTATE CREDENTIALS IMMEDIATELY\n2. ✅ Revoke exposed keys in AWS Console\n3. ✅ Check AWS CloudTrail for unauthorized access\n4. ✅ Review all AWS resources for tampering\n5. ✅ Enable AWS GuardDuty alerts\n6. ✅ Implement MFA on root account\n\n**Remediation**:\n```bash\n# 1. Revoke key immediately via AWS Console or CLI\naws iam delete-access-key --access-key-id AKIAIOSFODNN7EXAMPLE\n\n# 2. Create new key\naws iam create-access-key --user-name production-user\n\n# 3. Update environment variables (DO NOT COMMIT)\nexport AWS_ACCESS_KEY_ID=\"new-key-id\"\nexport AWS_SECRET_ACCESS_KEY=\"new-secret-key\"\n\n# 4. Remove from git history\ngit filter-branch --force --index-filter \\\n  \"git rm --cached --ignore-unmatch src\u002Fconfig\u002Faws.js\" \\\n  --prune-empty --tag-name-filter cat -- --all\n\n# Or use BFG Repo Cleaner\nbfg --replace-text passwords.txt\n```\n\n**Prevention**:\n```javascript\n\u002F\u002F NEVER do this:\nconst AWS_ACCESS_KEY_ID = 'AKIAIOSFODNN7EXAMPLE';\n\n\u002F\u002F ALWAYS do this:\nconst AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;\n\n\u002F\u002F Add to .gitignore:\n.env\n.env.local\n.env.production\ncredentials.json\naws-config.json\n```\n\n**Git History Cleanup Required**: YES\n**Priority**: P0 - Fix immediately\n\n---\n\n### ? Database Password in Connection String\n**Severity**: Critical\n**File**: config\u002Fdatabase.yml\n**Line**: 8\n**Commit**: f9e2a1d (2024-01-05)\n\n**Secret Found**:\n```yaml\nproduction:\n  url: postgresql:\u002F\u002Fadmin:SuperSecret123!@prod-db.example.com:5432\u002Fappdb\n```\n\n**Pattern Match**: PostgreSQL connection string with password\n**Entropy Score**: 3.8 (High)\n\n**Risk Assessment**:\n- **Impact**: CRITICAL - Production database access\n- **Scope**: All production data\n- **Exploitability**: HIGH\n- **Data at Risk**: User data, financial records, PII\n\n**Immediate Actions**:\n1. ✅ Change database password immediately\n2. ✅ Review database access logs for unauthorized queries\n3. ✅ Check for data exfiltration\n4. ✅ Update application configuration\n5. ✅ Implement database firewall rules\n\n**Remediation**:\n```yaml\n# Use environment variables\nproduction:\n  url: \u003C%= ENV['DATABASE_URL'] %>\n\n# Or use secrets manager\nproduction:\n  url: \u003C%= SecretsManager.get('database_url') %>\n```\n\n**Priority**: P0 - Fix immediately\n\n---\n\n### ? Private SSH Key Committed\n**Severity**: Critical\n**File**: deploy\u002Fkeys\u002Fid_rsa\n**Line**: 1-27\n**Commit**: b4c7e3a (2023-12-20)\n\n**Secret Found**:\n```\n-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA1234567890...\n[REDACTED]\n-----END RSA PRIVATE KEY-----\n```\n\n**Pattern Match**: RSA Private Key\n**Age**: 26 days\n\n**Risk Assessment**:\n- **Impact**: CRITICAL - Server access\n- **Scope**: All servers using this key\n- **Exploitability**: HIGH\n\n**Immediate Actions**:\n1. ✅ Revoke key from all servers immediately\n2. ✅ Generate new SSH key pair\n3. ✅ Update authorized_keys on all servers\n4. ✅ Check server logs for unauthorized access\n5. ✅ Rotate any secrets on accessed servers\n\n**Remediation**:\n```bash\n# 1. Remove key from servers\nssh user@server \"sed -i '\u002Fssh-rsa AAAA...\u002Fd' ~\u002F.ssh\u002Fauthorized_keys\"\n\n# 2. Generate new key (DO NOT COMMIT)\nssh-keygen -t ed25519 -C \"deployment@example.com\"\n\n# 3. Add to .gitignore\n*.pem\n*.key\nid_rsa\nid_rsa.pub\n*.ppk\n```\n\n**Priority**: P0 - Fix immediately\n\n---\n\n### ? Stripe Secret Key\n**Severity**: Critical\n**File**: src\u002Fpayments\u002Fstripe.js\n**Line**: 5\n**Commit**: d8f1a2c (2024-01-12)\n\n**Secret Found**:\n```javascript\nconst stripe = require('stripe')('sk_live_51Abc123XYZ...');\n```\n\n**Pattern Match**: Stripe Live Secret Key\n**Entropy Score**: 4.1 (High)\n\n**Risk Assessment**:\n- **Impact**: CRITICAL - Payment processing access\n- **Scope**: All customer payments, refunds, financial data\n- **Exploitability**: HIGH\n- **Financial Risk**: Unlimited charges, refunds, data theft\n\n**Immediate Actions**:\n1. ✅ Revoke API key in Stripe Dashboard immediately\n2. ✅ Generate new secret key\n3. ✅ Review recent charges and transactions\n4. ✅ Check for unauthorized refunds or transfers\n5. ✅ Enable Stripe fraud detection\n6. ✅ Notify security team\n\n**Remediation**:\n```javascript\n\u002F\u002F NEVER do this:\nconst stripe = require('stripe')('sk_live_51Abc123XYZ...');\n\n\u002F\u002F ALWAYS do this:\nconst stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);\n```\n\n**Priority**: P0 - Fix immediately\n\n---\n\n## High Severity Secrets (3)\n\n### ? GitHub Personal Access Token\n**Severity**: High\n**File**: .github\u002Fworkflows\u002Fdeploy.yml\n**Line**: 23\n**Commit**: e3b9c4f (2024-01-14)\n\n**Secret Found**:\n```yaml\nenv:\n  GITHUB_TOKEN: ghp_1234567890abcdefghijklmnopqrstuvwx\n```\n\n**Pattern Match**: GitHub Personal Access Token\n**Scope**: Repository access, potentially org-wide\n\n**Immediate Actions**:\n1. Revoke token in GitHub settings\n2. Generate new token with minimal scopes\n3. Use GitHub Actions secrets instead\n\n**Remediation**:\n```yaml\n# Use built-in GITHUB_TOKEN (automatically available)\nenv:\n  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n\n# Or store in repository secrets\nenv:\n  CUSTOM_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}\n```\n\n**Priority**: P1 - Fix within 24 hours\n\n---\n\n### ? SendGrid API Key\n**Severity**: High\n**File**: src\u002Femail\u002Fsender.js\n**Line**: 8\n\n**Secret Found**:\n```javascript\nconst apiKey = 'SG.1234567890abcdefgh.ijklmnopqrstuvwxyz1234567890abcdefgh';\n```\n\n**Risk**: Unauthorized email sending, quota exhaustion\n**Action**: Rotate key, use environment variable\n\n**Priority**: P1 - Fix within 24 hours\n\n---\n\n### ? JWT Secret Key\n**Severity**: High\n**File**: src\u002Fauth\u002Fconfig.js\n**Line**: 15\n\n**Secret Found**:\n```javascript\nconst JWT_SECRET = 'my-super-secret-jwt-key-123';\n```\n\n**Risk**: Token forgery, authentication bypass\n**Action**: Generate strong secret, store securely\n\n**Remediation**:\n```javascript\n\u002F\u002F Generate strong secret\nconst crypto = require('crypto');\nconst secret = crypto.randomBytes(64).toString('hex');\n\n\u002F\u002F Use environment variable\nconst JWT_SECRET = process.env.JWT_SECRET;\n\n\u002F\u002F Validation\nif (!JWT_SECRET || JWT_SECRET.length \u003C 32) {\n  throw new Error('JWT_SECRET must be at least 32 characters');\n}\n```\n\n**Priority**: P1 - Fix within 24 hours\n\n---\n\n## Medium Severity Secrets (3)\n\n### ? Hardcoded API Endpoint with Key\n**Severity**: Medium\n**File**: src\u002Fapi\u002Fclient.js\n**Line**: 12\n\n**Secret Found**:\n```javascript\nconst API_URL = 'https:\u002F\u002Fapi.example.com?key=abc123def456';\n```\n\n**Risk**: API quota abuse, service disruption\n**Action**: Move to environment variable\n\n**Priority**: P2 - Fix within 7 days\n\n---\n\n## Low Severity Secrets (2)\n\n### ? Development Database Password\n**Severity**: Low\n**File**: docker-compose.yml\n**Line**: 18\n\n**Secret Found**:\n```yaml\nPOSTGRES_PASSWORD: devpassword123\n```\n\n**Risk**: Low (development only)\n**Note**: Still use environment variables for consistency\n\n**Priority**: P3 - Fix in next sprint\n\n---\n\n## False Positives (5)\n\n### Example API Key in Documentation\n**File**: README.md\n**Line**: 45\n```markdown\nExample: api_key=\"your-api-key-here\"\n```\n**Reason**: Example\u002Fplaceholder text\n**Action**: None (consider adding comment to prevent future flags)\n\n---\n\n## Git History Analysis\n\n**Total Commits Analyzed**: 1,234\n**Commits with Secrets**: 8\n**Branches Affected**: main, develop, feature\u002Fpayment\n\n**Historical Secret Exposure**:\n```\nCommit: a3f5c2b - AWS keys (2024-01-10)\nCommit: f9e2a1d - DB password (2024-01-05)\nCommit: b4c7e3a - SSH key (2023-12-20)\nCommit: d8f1a2c - Stripe key (2024-01-12)\n```\n\n**Recommendation**: Rewrite git history to remove secrets\n\n---\n\n## Files Requiring Cleanup\n\n### Immediate Removal Required\n- src\u002Fconfig\u002Faws.js (AWS credentials)\n- config\u002Fdatabase.yml (DB password)\n- deploy\u002Fkeys\u002Fid_rsa (Private key)\n- src\u002Fpayments\u002Fstripe.js (Stripe key)\n\n### Should Be Gitignored\n- .env*\n- *.pem\n- *.key\n- credentials.json\n- secrets.yml\n- config\u002Fproduction\u002F*\n\n---\n\n## Remediation Checklist\n\n### Immediate (Critical - 0-24 hours)\n- [ ] Rotate all exposed AWS credentials\n- [ ] Change database passwords\n- [ ] Revoke and regenerate SSH keys\n- [ ] Rotate Stripe API keys\n- [ ] Review CloudTrail\u002Faccess logs for unauthorized activity\n- [ ] Check for data breaches\n\n### Short-term (High - 24-48 hours)\n- [ ] Rotate GitHub tokens\n- [ ] Regenerate SendGrid API keys\n- [ ] Generate new JWT secret\n- [ ] Remove secrets from git history\n- [ ] Force push cleaned repository\n\n### Medium-term (7 days)\n- [ ] Implement secrets management solution\n- [ ] Set up pre-commit hooks\n- [ ] Add .gitignore rules\n- [ ] Train team on secret handling\n- [ ] Document secrets policy\n\n### Long-term (Ongoing)\n- [ ] Regular secret scanning (automated)\n- [ ] Quarterly security audits\n- [ ] Secret rotation policy (90 days)\n- [ ] Monitor for exposed secrets\n\n---\n\n## Git History Cleanup\n\n### Using BFG Repo Cleaner (Recommended)\n```bash\n# 1. Clone fresh copy\ngit clone --mirror https:\u002F\u002Fgithub.com\u002Fuser\u002Frepo.git\n\n# 2. Create file with secrets to remove\ncat > secrets.txt \u003C\u003C EOF\nAKIAIOSFODNN7EXAMPLE\nSuperSecret123!\nsk_live_51Abc123XYZ\nghp_1234567890abcdefghijklmnopqrstuvwx\nEOF\n\n# 3. Run BFG\nbfg --replace-text secrets.txt repo.git\n\n# 4. Clean up\ncd repo.git\ngit reflog expire --expire=now --all\ngit gc --prune=now --aggressive\n\n# 5. Force push\ngit push --force\n```\n\n### Using git-filter-repo\n```bash\n# Install\npip install git-filter-repo\n\n# Remove specific files\ngit filter-repo --path src\u002Fconfig\u002Faws.js --invert-paths\n\n# Remove secrets by pattern\ngit filter-repo --replace-text secrets.txt\n```\n\n### Warning Team\n```\n⚠️  IMPORTANT: After history rewrite\n1. All team members must delete local clones\n2. Clone repository fresh\n3. DO NOT merge old branches\n4. Update all CI\u002FCD pipelines\n```\n\n---\n\n## Prevention Strategy\n\n### 1. Pre-commit Hooks\n```bash\n# .husky\u002Fpre-commit\n#!\u002Fbin\u002Fsh\ngitleaks protect --staged --verbose --redact\n```\n\n### 2. Update .gitignore\n```gitignore\n# Secrets\n.env\n.env.*\n!.env.example\n*.pem\n*.key\n*.ppk\n*_rsa\n*_dsa\ncredentials.json\nsecrets.yml\nsecrets.yaml\nconfig\u002Fcredentials\u002F*\naws-config.json\n\n# OS Files\n.DS_Store\nThumbs.db\n```\n\n### 3. Environment Template\n```bash\n# .env.example (commit this)\nDATABASE_URL=postgresql:\u002F\u002Fuser:password@localhost:5432\u002Fdbname\nAWS_ACCESS_KEY_ID=your_access_key_here\nAWS_SECRET_ACCESS_KEY=your_secret_key_here\nSTRIPE_SECRET_KEY=sk_test_your_key_here\n\n# .env (DO NOT COMMIT - add to .gitignore)\nDATABASE_URL=postgresql:\u002F\u002Fadmin:RealPassword@prod.db.com:5432\u002Fprod\nAWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE\n```\n\n### 4. Code Review Checklist\n- [ ] No hardcoded credentials\n- [ ] All secrets in environment variables\n- [ ] .env files not committed\n- [ ] Secret scanner run and passed\n- [ ] No TODO comments about removing secrets\n\n### 5. Secrets Management Solutions\n\n**HashiCorp Vault**\n```javascript\nconst vault = require('node-vault');\nconst client = vault({ endpoint: process.env.VAULT_ADDR });\n\nasync function getSecret(path) {\n  const result = await client.read(path);\n  return result.data;\n}\n\nconst dbPassword = await getSecret('secret\u002Fdatabase\u002Fpassword');\n```\n\n**AWS Secrets Manager**\n```javascript\nconst AWS = require('aws-sdk');\nconst secretsManager = new AWS.SecretsManager();\n\nasync function getSecret(secretName) {\n  const data = await secretsManager.getSecretValue({\n    SecretId: secretName\n  }).promise();\n  return JSON.parse(data.SecretString);\n}\n```\n\n**Doppler**\n```bash\n# Install Doppler CLI\ndoppler setup\n\n# Run app with secrets\ndoppler run -- node app.js\n```\n\n---\n\n## CI\u002FCD Integration\n\n### GitHub Actions\n```yaml\nname: Secret Scanning\non: [push, pull_request]\n\njobs:\n  scan:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v3\n        with:\n          fetch-depth: 0\n\n      - name: Gitleaks\n        uses: gitleaks\u002Fgitleaks-action@v2\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n\n      - name: TruffleHog\n        uses: trufflesecurity\u002Ftrufflehog@main\n        with:\n          path: .\u002F\n          base: main\n```\n\n---\n\n## Best Practices\n\n### Secret Handling\n- ✅ Never commit secrets to version control\n- ✅ Use environment variables\n- ✅ Use secrets management systems\n- ✅ Rotate secrets regularly (90 days)\n- ✅ Use different secrets for dev\u002Fstaging\u002Fprod\n- ✅ Implement principle of least privilege\n- ✅ Audit secret access\n- ✅ Encrypt secrets at rest\n\n### Development Workflow\n- ✅ Use .env.example templates\n- ✅ Document required environment variables\n- ✅ Validate environment on startup\n- ✅ Never log secrets\n- ✅ Redact secrets in error messages\n- ✅ Use short-lived tokens when possible\n\n### Code Review\n- ✅ Run secret scanner before committing\n- ✅ Review all config files carefully\n- ✅ Check for TODO comments about secrets\n- ✅ Verify .gitignore is comprehensive\n- ✅ Double-check before public repository\n\n---\n\n## Incident Response Plan\n\nIf secrets are exposed:\n\n### 1. Immediate Actions (0-1 hour)\n- Stop the breach (revoke credentials)\n- Assess scope (what was exposed, for how long)\n- Check for unauthorized access\n- Notify security team\n\n### 2. Short-term Actions (1-24 hours)\n- Rotate all affected credentials\n- Review logs for abuse\n- Remove secrets from git history\n- Force push cleaned repository\n- Notify affected parties if data breach\n\n### 3. Long-term Actions (1-7 days)\n- Post-mortem analysis\n- Update security procedures\n- Implement additional controls\n- Train team on lessons learned\n- Monitor for long-term impact\n\n---\n\n## Summary\n\n**Secrets Found**: 12\n**Critical**: 4 (require immediate rotation)\n**High**: 3 (rotate within 24h)\n**Medium**: 3 (fix within 7 days)\n**Low**: 2 (fix next sprint)\n\n**Estimated Remediation Time**: 4-6 hours\n**Git History Cleanup**: Required\n**Team Training**: Recommended\n\n**Overall Risk**: ? CRITICAL - Immediate action required\n```\n\n## Notes\n\n- Scan repository before every public release\n- Implement automated scanning in CI\u002FCD\n- Regular secret rotation is critical\n- Train developers on secure secret handling\n- Use secrets management tools for production\n- Never commit .env files\n- Review git history for secrets before open-sourcing\n- Establish incident response plan for exposed secrets\n- Monitor for secrets in issues, pull requests, and discussions\n- Remember: Once committed, assume secret is compromised\n","# Secret Scanner Skill\n\nDetect accidentally committed secrets, credentials, and sensitive information in code.\n\n## Instructions\n\nYou are a secret detection expert. When invoked:\n\n1. **Scan for Secrets**:\n   - API keys and tokens\n   - Passwords and credentials\n   - Private keys and certificates\n   - Database connection strings\n   - OAuth tokens and secrets\n   - Cloud provider credentials (AWS, GCP, Azure)\n   - Encryption keys\n\n2. **Pattern Detection**:\n   - Regex-based secret detection\n   - Entropy analysis for high-randomness strings\n   - Known secret patterns (AWS keys, GitHub tokens, etc.)\n   - Custom secret patterns\n   - File type analysis (.env, config files)\n   - Comment analysis (TODO: remove this key)\n\n3. **Contextual Analysis**:\n   - Distinguish real secrets from examples\u002Ftest data\n   - Check if secrets are in version control history\n   - Identify false positives\n   - Determine secret exposure scope\n   - Check if secrets are still active\n\n4. **Risk Assessment**:\n   - Classify severity (Critical, High, Medium, Low)\n   - Determine potential impact\n   - Check if secret has been exposed publicly\n   - Assess exploitability\n   - Identify affected systems\n\n5. **Generate Report**: Create comprehensive secret exposure report with remediation steps\n\n## Secret Types and Patterns\n\n### Cloud Provider Credentials\n\n#### AWS\n```regex\n# AWS Access Key ID\nAKIA[0-9A-Z]{16}\n\n# AWS Secret Access Key\n[0-9a-zA-Z\u002F+=]{40}\n\n# AWS Session Token\n[A-Za-z0-9\u002F+=]{200,}\n```\n\n#### Google Cloud\n```regex\n# GCP API Key\nAIza[0-9A-Za-z-_]{35}\n\n# GCP Service Account\n\"type\": \"service_account\"\n```\n\n#### Azure\n```regex\n# Azure Storage Key\n[a-zA-Z0-9+\u002F]{88}==\n\n# Azure Client Secret\n[0-9a-zA-Z-_~]{34,}\n```\n\n### Version Control Tokens\n\n#### GitHub\n```regex\n# GitHub Personal Access Token\nghp_[0-9a-zA-Z]{36}\n\n# GitHub OAuth Token\ngho_[0-9a-zA-Z]{36}\n\n# GitHub App Token\n(ghu|ghs)_[0-9a-zA-Z]{36}\n```\n\n#### GitLab\n```regex\nglpat-[0-9a-zA-Z-_]{20}\n```\n\n### Database Credentials\n```regex\n# MongoDB Connection String\nmongodb(\\+srv)?:\u002F\u002F[^\\s]+\n\n# PostgreSQL Connection String\npostgres(ql)?:\u002F\u002F[^\\s]+\n\n# MySQL Connection String\nmysql:\u002F\u002F[^\\s]+\n\n# Generic DB Password\n(password|pwd|pass)\\s*[:=]\\s*['\"][^'\"]+['\"]\n```\n\n### API Keys and Tokens\n```regex\n# Generic API Key\napi[_-]?key\\s*[:=]\\s*['\"][^'\"]+['\"]\n\n# Stripe\nsk_live_[0-9a-zA-Z]{24,}\n\n# Slack\nxox[baprs]-[0-9a-zA-Z-]{10,}\n\n# Twilio\nSK[0-9a-fA-F]{32}\n\n# SendGrid\nSG\\.[0-9A-Za-z\\-_]{22}\\.[0-9A-Za-z\\-_]{43}\n```\n\n### Private Keys\n```regex\n-----BEGIN (RSA|DSA|EC|OPENSSH|PGP) PRIVATE KEY-----\n```\n\n### JWT Tokens\n```regex\neyJ[A-Za-z0-9-_=]+\\.eyJ[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+\u002F=]*\n```\n\n## Usage Examples\n\n```\n@secret-scanner\n@secret-scanner --severity high\n@secret-scanner --git-history\n@secret-scanner src\u002F\n@secret-scanner --include-env-files\n@secret-scanner --entropy-check\n@secret-scanner --report\n```\n\n## Scanning Commands\n\n### Using git-secrets\n```bash\n# Install git-secrets\nbrew install git-secrets  # macOS\n# or\ngit clone https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fgit-secrets.git\n\n# Initialize\ngit secrets --install\ngit secrets --register-aws\n\n# Scan repository\ngit secrets --scan\ngit secrets --scan-history\n\n# Add custom patterns\ngit secrets --add 'api[_-]?key\\s*[:=]\\s*['\"'\"'][^'\"'\"']+['\"'\"']'\ngit secrets --add 'password\\s*[:=]\\s*['\"'\"'][^'\"'\"']+['\"'\"']'\n```\n\n### Using truffleHog\n```bash\n# Install\npip install truffleHog\n\n# Scan repository\ntrufflehog git file:\u002F\u002F. --json\n\n# Scan remote repository\ntrufflehog git https:\u002F\u002Fgithub.com\u002Fuser\u002Frepo.git\n\n# Scan with high entropy only\ntrufflehog git file:\u002F\u002F. --entropy-only\n\n# Scan specific branch\ntrufflehog git file:\u002F\u002F. --branch main\n```\n\n### Using gitleaks\n```bash\n# Install\nbrew install gitleaks  # macOS\n\n# Scan repository\ngitleaks detect --source . --verbose\n\n# Scan with report\ngitleaks detect --source . --report-format json --report-path report.json\n\n# Scan uncommitted files\ngitleaks protect --staged\n\n# Scan git history\ngitleaks detect --source . --log-opts \"--all\"\n```\n\n### Using detect-secrets\n```bash\n# Install\npip install detect-secrets\n\n# Create baseline\ndetect-secrets scan > .secrets.baseline\n\n# Audit baseline\ndetect-secrets audit .secrets.baseline\n\n# Scan for new secrets\ndetect-secrets scan --baseline .secrets.baseline\n```\n\n### Using custom grep patterns\n```bash\n# Scan for AWS keys\ngrep -r \"AKIA[0-9A-Z]\\{16\\}\" .\n\n# Scan for private keys\ngrep -r \"BEGIN.*PRIVATE KEY\" .\n\n# Scan for passwords\ngrep -ri \"password\\s*=\\s*['\\\"]\" . --include=\"*.js\" --include=\"*.py\"\n\n# High entropy strings\ngrep -r \"[a-zA-Z0-9]\\{32,\\}\" .\n```\n\n## Secret Scanner Report Format\n\n```markdown\n# Secret Scanner Report\n\n**Repository**: my-application\n**Scan Date**: 2024-01-15 14:30:00 UTC\n**Branch**: main\n**Commits Scanned**: 1,234\n**Files Scanned**: 456\n\n---\n\n## Executive Summary\n\n? **CRITICAL SECURITY ISSUE DETECTED**\n\n**Total Secrets Found**: 12\n- Critical: 4\n- High: 3\n- Medium: 3\n- Low: 2\n\n**Immediate Actions Required**: 4 secrets need rotation NOW\n\n---\n\n## Critical Secrets (4)\n\n### ? AWS Access Key Exposed\n**Severity**: Critical\n**File**: src\u002Fconfig\u002Faws.js\n**Line**: 12\n**Commit**: a3f5c2b (2024-01-10)\n**Age**: 5 days\n\n**Secret Found**:\n```javascript\nconst AWS_ACCESS_KEY_ID = 'AKIAIOSFODNN7EXAMPLE';\nconst AWS_SECRET_ACCESS_KEY = 'wJalrXUtnFEMI\u002FK7MDENG\u002FbPxRfiCYEXAMPLEKEY';\n```\n\n**Pattern Match**: AWS Access Key ID pattern\n**Entropy Score**: 4.2 (High)\n\n**Risk Assessment**:\n- **Impact**: CRITICAL - Full AWS account access\n- **Scope**: All AWS resources in the account\n- **Exploitability**: HIGH - Key is in public repository\n- **Data at Risk**: Production databases, S3 buckets, EC2 instances\n\n**Exposure**:\n- ✅ Committed to repository: Yes\n- ✅ Pushed to remote: Yes\n- ✅ In public repository: Yes\n- ⚠️  Visible in GitHub: Since 2024-01-10\n- ⚠️  Present in 5 commits\n\n**Immediate Actions**:\n1. ✅ ROTATE CREDENTIALS IMMEDIATELY\n2. ✅ Revoke exposed keys in AWS Console\n3. ✅ Check AWS CloudTrail for unauthorized access\n4. ✅ Review all AWS resources for tampering\n5. ✅ Enable AWS GuardDuty alerts\n6. ✅ Implement MFA on root account\n\n**Remediation**:\n```bash\n# 1. Revoke key immediately via AWS Console or CLI\naws iam delete-access-key --access-key-id AKIAIOSFODNN7EXAMPLE\n\n# 2. Create new key\naws iam create-access-key --user-name production-user\n\n# 3. Update environment variables (DO NOT COMMIT)\nexport AWS_ACCESS_KEY_ID=\"new-key-id\"\nexport AWS_SECRET_ACCESS_KEY=\"new-secret-key\"\n\n# 4. Remove from git history\ngit filter-branch --force --index-filter \\\n  \"git rm --cached --ignore-unmatch src\u002Fconfig\u002Faws.js\" \\\n  --prune-empty --tag-name-filter cat -- --all\n\n# Or use BFG Repo Cleaner\nbfg --replace-text passwords.txt\n```\n\n**Prevention**:\n```javascript\n\u002F\u002F NEVER do this:\nconst AWS_ACCESS_KEY_ID = 'AKIAIOSFODNN7EXAMPLE';\n\n\u002F\u002F ALWAYS do this:\nconst AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;\n\n\u002F\u002F Add to .gitignore:\n.env\n.env.local\n.env.production\ncredentials.json\naws-config.json\n```\n\n**Git History Cleanup Required**: YES\n**Priority**: P0 - Fix immediately\n\n---\n\n### ? Database Password in Connection String\n**Severity**: Critical\n**File**: config\u002Fdatabase.yml\n**Line**: 8\n**Commit**: f9e2a1d (2024-01-05)\n\n**Secret Found**:\n```yaml\nproduction:\n  url: postgresql:\u002F\u002Fadmin:SuperSecret123!@prod-db.example.com:5432\u002Fappdb\n```\n\n**Pattern Match**: PostgreSQL connection string with password\n**Entropy Score**: 3.8 (High)\n\n**Risk Assessment**:\n- **Impact**: CRITICAL - Production database access\n- **Scope**: All production data\n- **Exploitability**: HIGH\n- **Data at Risk**: User data, financial records, PII\n\n**Immediate Actions**:\n1. ✅ Change database password immediately\n2. ✅ Review database access logs for unauthorized queries\n3. ✅ Check for data exfiltration\n4. ✅ Update application configuration\n5. ✅ Implement database firewall rules\n\n**Remediation**:\n```yaml\n# Use environment variables\nproduction:\n  url: \u003C%= ENV['DATABASE_URL'] %>\n\n# Or use secrets manager\nproduction:\n  url: \u003C%= SecretsManager.get('database_url') %>\n```\n\n**Priority**: P0 - Fix immediately\n\n---\n\n### ? Private SSH Key Committed\n**Severity**: Critical\n**File**: deploy\u002Fkeys\u002Fid_rsa\n**Line**: 1-27\n**Commit**: b4c7e3a (2023-12-20)\n\n**Secret Found**:\n```\n-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA1234567890...\n[REDACTED]\n-----END RSA PRIVATE KEY-----\n```\n\n**Pattern Match**: RSA Private Key\n**Age**: 26 days\n\n**Risk Assessment**:\n- **Impact**: CRITICAL - Server access\n- **Scope**: All servers using this key\n- **Exploitability**: HIGH\n\n**Immediate Actions**:\n1. ✅ Revoke key from all servers immediately\n2. ✅ Generate new SSH key pair\n3. ✅ Update authorized_keys on all servers\n4. ✅ Check server logs for unauthorized access\n5. ✅ Rotate any secrets on accessed servers\n\n**Remediation**:\n```bash\n# 1. Remove key from servers\nssh user@server \"sed -i '\u002Fssh-rsa AAAA...\u002Fd' ~\u002F.ssh\u002Fauthorized_keys\"\n\n# 2. Generate new key (DO NOT COMMIT)\nssh-keygen -t ed25519 -C \"deployment@example.com\"\n\n# 3. Add to .gitignore\n*.pem\n*.key\nid_rsa\nid_rsa.pub\n*.ppk\n```\n\n**Priority**: P0 - Fix immediately\n\n---\n\n### ? Stripe Secret Key\n**Severity**: Critical\n**File**: src\u002Fpayments\u002Fstripe.js\n**Line**: 5\n**Commit**: d8f1a2c (2024-01-12)\n\n**Secret Found**:\n```javascript\nconst stripe = require('stripe')('sk_live_51Abc123XYZ...');\n```\n\n**Pattern Match**: Stripe Live Secret Key\n**Entropy Score**: 4.1 (High)\n\n**Risk Assessment**:\n- **Impact**: CRITICAL - Payment processing access\n- **Scope**: All customer payments, refunds, financial data\n- **Exploitability**: HIGH\n- **Financial Risk**: Unlimited charges, refunds, data theft\n\n**Immediate Actions**:\n1. ✅ Revoke API key in Stripe Dashboard immediately\n2. ✅ Generate new secret key\n3. ✅ Review recent charges and transactions\n4. ✅ Check for unauthorized refunds or transfers\n5. ✅ Enable Stripe fraud detection\n6. ✅ Notify security team\n\n**Remediation**:\n```javascript\n\u002F\u002F NEVER do this:\nconst stripe = require('stripe')('sk_live_51Abc123XYZ...');\n\n\u002F\u002F ALWAYS do this:\nconst stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);\n```\n\n**Priority**: P0 - Fix immediately\n\n---\n\n## High Severity Secrets (3)\n\n### ? GitHub Personal Access Token\n**Severity**: High\n**File**: .github\u002Fworkflows\u002Fdeploy.yml\n**Line**: 23\n**Commit**: e3b9c4f (2024-01-14)\n\n**Secret Found**:\n```yaml\nenv:\n  GITHUB_TOKEN: ghp_1234567890abcdefghijklmnopqrstuvwx\n```\n\n**Pattern Match**: GitHub Personal Access Token\n**Scope**: Repository access, potentially org-wide\n\n**Immediate Actions**:\n1. Revoke token in GitHub settings\n2. Generate new token with minimal scopes\n3. Use GitHub Actions secrets instead\n\n**Remediation**:\n```yaml\n# Use built-in GITHUB_TOKEN (automatically available)\nenv:\n  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n\n# Or store in repository secrets\nenv:\n  CUSTOM_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}\n```\n\n**Priority**: P1 - Fix within 24 hours\n\n---\n\n### ? SendGrid API Key\n**Severity**: High\n**File**: src\u002Femail\u002Fsender.js\n**Line**: 8\n\n**Secret Found**:\n```javascript\nconst apiKey = 'SG.1234567890abcdefgh.ijklmnopqrstuvwxyz1234567890abcdefgh';\n```\n\n**Risk**: Unauthorized email sending, quota exhaustion\n**Action**: Rotate key, use environment variable\n\n**Priority**: P1 - Fix within 24 hours\n\n---\n\n### ? JWT Secret Key\n**Severity**: High\n**File**: src\u002Fauth\u002Fconfig.js\n**Line**: 15\n\n**Secret Found**:\n```javascript\nconst JWT_SECRET = 'my-super-secret-jwt-key-123';\n```\n\n**Risk**: Token forgery, authentication bypass\n**Action**: Generate strong secret, store securely\n\n**Remediation**:\n```javascript\n\u002F\u002F Generate strong secret\nconst crypto = require('crypto');\nconst secret = crypto.randomBytes(64).toString('hex');\n\n\u002F\u002F Use environment variable\nconst JWT_SECRET = process.env.JWT_SECRET;\n\n\u002F\u002F Validation\nif (!JWT_SECRET || JWT_SECRET.length \u003C 32) {\n  throw new Error('JWT_SECRET must be at least 32 characters');\n}\n```\n\n**Priority**: P1 - Fix within 24 hours\n\n---\n\n## Medium Severity Secrets (3)\n\n### ? Hardcoded API Endpoint with Key\n**Severity**: Medium\n**File**: src\u002Fapi\u002Fclient.js\n**Line**: 12\n\n**Secret Found**:\n```javascript\nconst API_URL = 'https:\u002F\u002Fapi.example.com?key=abc123def456';\n```\n\n**Risk**: API quota abuse, service disruption\n**Action**: Move to environment variable\n\n**Priority**: P2 - Fix within 7 days\n\n---\n\n## Low Severity Secrets (2)\n\n### ? Development Database Password\n**Severity**: Low\n**File**: docker-compose.yml\n**Line**: 18\n\n**Secret Found**:\n```yaml\nPOSTGRES_PASSWORD: devpassword123\n```\n\n**Risk**: Low (development only)\n**Note**: Still use environment variables for consistency\n\n**Priority**: P3 - Fix in next sprint\n\n---\n\n## False Positives (5)\n\n### Example API Key in Documentation\n**File**: README.md\n**Line**: 45\n```markdown\nExample: api_key=\"your-api-key-here\"\n```\n**Reason**: Example\u002Fplaceholder text\n**Action**: None (consider adding comment to prevent future flags)\n\n---\n\n## Git History Analysis\n\n**Total Commits Analyzed**: 1,234\n**Commits with Secrets**: 8\n**Branches Affected**: main, develop, feature\u002Fpayment\n\n**Historical Secret Exposure**:\n```\nCommit: a3f5c2b - AWS keys (2024-01-10)\nCommit: f9e2a1d - DB password (2024-01-05)\nCommit: b4c7e3a - SSH key (2023-12-20)\nCommit: d8f1a2c - Stripe key (2024-01-12)\n```\n\n**Recommendation**: Rewrite git history to remove secrets\n\n---\n\n## Files Requiring Cleanup\n\n### Immediate Removal Required\n- src\u002Fconfig\u002Faws.js (AWS credentials)\n- config\u002Fdatabase.yml (DB password)\n- deploy\u002Fkeys\u002Fid_rsa (Private key)\n- src\u002Fpayments\u002Fstripe.js (Stripe key)\n\n### Should Be Gitignored\n- .env*\n- *.pem\n- *.key\n- credentials.json\n- secrets.yml\n- config\u002Fproduction\u002F*\n\n---\n\n## Remediation Checklist\n\n### Immediate (Critical - 0-24 hours)\n- [ ] Rotate all exposed AWS credentials\n- [ ] Change database passwords\n- [ ] Revoke and regenerate SSH keys\n- [ ] Rotate Stripe API keys\n- [ ] Review CloudTrail\u002Faccess logs for unauthorized activity\n- [ ] Check for data breaches\n\n### Short-term (High - 24-48 hours)\n- [ ] Rotate GitHub tokens\n- [ ] Regenerate SendGrid API keys\n- [ ] Generate new JWT secret\n- [ ] Remove secrets from git history\n- [ ] Force push cleaned repository\n\n### Medium-term (7 days)\n- [ ] Implement secrets management solution\n- [ ] Set up pre-commit hooks\n- [ ] Add .gitignore rules\n- [ ] Train team on secret handling\n- [ ] Document secrets policy\n\n### Long-term (Ongoing)\n- [ ] Regular secret scanning (automated)\n- [ ] Quarterly security audits\n- [ ] Secret rotation policy (90 days)\n- [ ] Monitor for exposed secrets\n\n---\n\n## Git History Cleanup\n\n### Using BFG Repo Cleaner (Recommended)\n```bash\n# 1. Clone fresh copy\ngit clone --mirror https:\u002F\u002Fgithub.com\u002Fuser\u002Frepo.git\n\n# 2. Create file with secrets to remove\ncat > secrets.txt \u003C\u003C EOF\nAKIAIOSFODNN7EXAMPLE\nSuperSecret123!\nsk_live_51Abc123XYZ\nghp_1234567890abcdefghijklmnopqrstuvwx\nEOF\n\n# 3. Run BFG\nbfg --replace-text secrets.txt repo.git\n\n# 4. Clean up\ncd repo.git\ngit reflog expire --expire=now --all\ngit gc --prune=now --aggressive\n\n# 5. Force push\ngit push --force\n```\n\n### Using git-filter-repo\n```bash\n# Install\npip install git-filter-repo\n\n# Remove specific files\ngit filter-repo --path src\u002Fconfig\u002Faws.js --invert-paths\n\n# Remove secrets by pattern\ngit filter-repo --replace-text secrets.txt\n```\n\n### Warning Team\n```\n⚠️  IMPORTANT: After history rewrite\n1. All team members must delete local clones\n2. Clone repository fresh\n3. DO NOT merge old branches\n4. Update all CI\u002FCD pipelines\n```\n\n---\n\n## Prevention Strategy\n\n### 1. Pre-commit Hooks\n```bash\n# .husky\u002Fpre-commit\n#!\u002Fbin\u002Fsh\ngitleaks protect --staged --verbose --redact\n```\n\n### 2. Update .gitignore\n```gitignore\n# Secrets\n.env\n.env.*\n!.env.example\n*.pem\n*.key\n*.ppk\n*_rsa\n*_dsa\ncredentials.json\nsecrets.yml\nsecrets.yaml\nconfig\u002Fcredentials\u002F*\naws-config.json\n\n# OS Files\n.DS_Store\nThumbs.db\n```\n\n### 3. Environment Template\n```bash\n# .env.example (commit this)\nDATABASE_URL=postgresql:\u002F\u002Fuser:password@localhost:5432\u002Fdbname\nAWS_ACCESS_KEY_ID=your_access_key_here\nAWS_SECRET_ACCESS_KEY=your_secret_key_here\nSTRIPE_SECRET_KEY=sk_test_your_key_here\n\n# .env (DO NOT COMMIT - add to .gitignore)\nDATABASE_URL=postgresql:\u002F\u002Fadmin:RealPassword@prod.db.com:5432\u002Fprod\nAWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE\n```\n\n### 4. Code Review Checklist\n- [ ] No hardcoded credentials\n- [ ] All secrets in environment variables\n- [ ] .env files not committed\n- [ ] Secret scanner run and passed\n- [ ] No TODO comments about removing secrets\n\n### 5. Secrets Management Solutions\n\n**HashiCorp Vault**\n```javascript\nconst vault = require('node-vault');\nconst client = vault({ endpoint: process.env.VAULT_ADDR });\n\nasync function getSecret(path) {\n  const result = await client.read(path);\n  return result.data;\n}\n\nconst dbPassword = await getSecret('secret\u002Fdatabase\u002Fpassword');\n```\n\n**AWS Secrets Manager**\n```javascript\nconst AWS = require('aws-sdk');\nconst secretsManager = new AWS.SecretsManager();\n\nasync function getSecret(secretName) {\n  const data = await secretsManager.getSecretValue({\n    SecretId: secretName\n  }).promise();\n  return JSON.parse(data.SecretString);\n}\n```\n\n**Doppler**\n```bash\n# Install Doppler CLI\ndoppler setup\n\n# Run app with secrets\ndoppler run -- node app.js\n```\n\n---\n\n## CI\u002FCD Integration\n\n### GitHub Actions\n```yaml\nname: Secret Scanning\non: [push, pull_request]\n\njobs:\n  scan:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v3\n        with:\n          fetch-depth: 0\n\n      - name: Gitleaks\n        uses: gitleaks\u002Fgitleaks-action@v2\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n\n      - name: TruffleHog\n        uses: trufflesecurity\u002Ftrufflehog@main\n        with:\n          path: .\u002F\n          base: main\n```\n\n---\n\n## Best Practices\n\n### Secret Handling\n- ✅ Never commit secrets to version control\n- ✅ Use environment variables\n- ✅ Use secrets management systems\n- ✅ Rotate secrets regularly (90 days)\n- ✅ Use different secrets for dev\u002Fstaging\u002Fprod\n- ✅ Implement principle of least privilege\n- ✅ Audit secret access\n- ✅ Encrypt secrets at rest\n\n### Development Workflow\n- ✅ Use .env.example templates\n- ✅ Document required environment variables\n- ✅ Validate environment on startup\n- ✅ Never log secrets\n- ✅ Redact secrets in error messages\n- ✅ Use short-lived tokens when possible\n\n### Code Review\n- ✅ Run secret scanner before committing\n- ✅ Review all config files carefully\n- ✅ Check for TODO comments about secrets\n- ✅ Verify .gitignore is comprehensive\n- ✅ Double-check before public repository\n\n---\n\n## Incident Response Plan\n\nIf secrets are exposed:\n\n### 1. Immediate Actions (0-1 hour)\n- Stop the breach (revoke credentials)\n- Assess scope (what was exposed, for how long)\n- Check for unauthorized access\n- Notify security team\n\n### 2. Short-term Actions (1-24 hours)\n- Rotate all affected credentials\n- Review logs for abuse\n- Remove secrets from git history\n- Force push cleaned repository\n- Notify affected parties if data breach\n\n### 3. Long-term Actions (1-7 days)\n- Post-mortem analysis\n- Update security procedures\n- Implement additional controls\n- Train team on lessons learned\n- Monitor for long-term impact\n\n---\n\n## Summary\n\n**Secrets Found**: 12\n**Critical**: 4 (require immediate rotation)\n**High**: 3 (rotate within 24h)\n**Medium**: 3 (fix within 7 days)\n**Low**: 2 (fix next sprint)\n\n**Estimated Remediation Time**: 4-6 hours\n**Git History Cleanup**: Required\n**Team Training**: Recommended\n\n**Overall Risk**: ? CRITICAL - Immediate action required\n```\n\n## Notes\n\n- Scan repository before every public release\n- Implement automated scanning in CI\u002FCD\n- Regular secret rotation is critical\n- Train developers on secure secret handling\n- Use secrets management tools for production\n- Never commit .env files\n- Review git history for secrets before open-sourcing\n- Establish incident response plan for exposed secrets\n- Monitor for secrets in issues, pull requests, and discussions\n- Remember: Once committed, assume secret is compromised\n",{"name":5,"description":7},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Faiskillstore\u002Fmarketplace\u002Fcuriouslearner\u002Fsecret-scanner",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill secret-scanner",{"tool":51,"command":52},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill secret-scanner",{"tool":54,"command":55},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill secret-scanner","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fcuriouslearner\u002Fsecret-scanner\u002FSKILL.md",true,[59],{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"skill-report.json","REFERENCE","参考文档",8772,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fcuriouslearner\u002Fsecret-scanner\u002Fskill-report.json",[66,80,90,99,105,112],{"skillNo":67,"name":68,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":76,"publishedAt":31},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[71],{"categoryNo":72,"categoryName":73,"taxonomyType":74,"taxonomyTypeDesc":75},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[77,78,79],"model","model hierarchy","model hierarchy skill",{"skillNo":81,"name":82,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":86,"publishedAt":31},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[85],{"categoryNo":72,"categoryName":73,"taxonomyType":74,"taxonomyTypeDesc":75},[87,88,89],"MCP","zoom","zoom mcp",{"skillNo":91,"name":92,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":31},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[96,97,98,88],"sdk","zoom apps sdk","apps",{"skillNo":100,"name":101,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":31},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[101],{"skillNo":106,"name":107,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":111,"publishedAt":31},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[110],{"categoryNo":72,"categoryName":73,"taxonomyType":74,"taxonomyTypeDesc":75},[107],{"skillNo":113,"name":114,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":31},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[114]]