Cursor rule
.cursor/rules/secret-detection.mdcCursor rules
Quality
34/100
Scores the file, not the repository.Length
882 words
1 headings · 0 code blocksRepository
86
— · pushed 280 days agoLast changed
3 days ago
First indexed 3 days ago.1# Secret Detection and Warning Rule23This rule helps identify potential secrets, credentials, and sensitive data in code files to prevent accidental exposure or leakage. It provides warnings when secrets are detected and suggests best practices for secure secret management.45<rule>6name: secret_detection_warning7description: Detect and warn about potential secrets and sensitive data in code files8filters:9 - type: file_extension10 pattern: "\\.(php|js|py|ts|jsx|tsx|java|rb|go|cs|c|cpp|h|hpp|ini|conf|yaml|yml|json|xml|properties|env|config|sh|bash|zsh)$"11 - type: file_path12 pattern: ".*"13 exclude: "(node_modules|vendor|bower_components|.git|.yarn|dist|build|out|\\.bundle|cache)"1415actions:16 - type: enforce17 conditions:18 # Generic API Keys, Tokens, and Credentials19 - pattern: "(?i)(api[_-]?key|apikey|api[_-]?secret|apisecret|app[_-]?key|appkey|app[_-]?secret|access[_-]?key|accesskey|access[_-]?token|auth[_-]?key|authkey|client[_-]?secret|consumer[_-]?key|consumer[_-]?secret|oauth[_-]?token|token)[\\s]*[=:]\\s*['\\\"](\\w|[\\-]){16,}['\\\"]"20 message: "Potential API key or secret detected. Consider using environment variables or a secure secrets manager instead of hardcoding sensitive values."2122 # AWS Keys and Tokens23 - pattern: "(?i)(aws[_-]?access[_-]?key|aws[_-]?secret[_-]?key|aws[_-]?account[_-]?id)[\\s]*[=:]\\s*['\\\"](\\w|[\\-]){16,}['\\\"]"24 message: "Potential AWS key detected. AWS credentials should be stored securely using AWS SDK credential providers, environment variables, or a secrets manager."2526 # Google Cloud and Firebase27 - pattern: "(?i)(google[_-]?api[_-]?key|google[_-]?cloud[_-]?key|firebase[_-]?api[_-]?key)[\\s]*[=:]\\s*['\\\"](\\w|[\\-]){16,}['\\\"]"28 message: "Potential Google Cloud or Firebase key detected. Use environment variables or a secure secrets manager to store these credentials."2930 # Azure and Microsoft31 - pattern: "(?i)(azure[_-]?key|azure[_-]?connection[_-]?string|microsoft[_-]?key)[\\s]*[=:]\\s*['\\\"](\\w|[\\-]){16,}['\\\"]"32 message: "Potential Azure or Microsoft key detected. Use Azure Key Vault, environment variables, or a secure secrets manager instead of hardcoding credentials."3334 # Database Connection Strings and Credentials35 - pattern: "(?i)(jdbc:|mongodb[\\+]?://|postgres://|mysql://|database[_-]?url|connection[_-]?string)[^\\n]{10,}(password|pwd)[^\\n]{3,}"36 message: "Potential database connection string with credentials detected. Use environment variables or a secure configuration manager for database connections."3738 # Database Credentials39 - pattern: "(?i)(db[_-]?password|mysql[_-]?password|postgres[_-]?password|mongo[_-]?password|database[_-]?password)[\\s]*[=:]\\s*['\\\"][^\\s]{3,}['\\\"]"40 message: "Potential database password detected. Store database credentials in environment variables or use a secure configuration manager."4142 # Private Keys and Certificates43 - pattern: "(?i)-----(BEGIN|END) (RSA |DSA |EC )?(PRIVATE KEY|CERTIFICATE)-----"44 message: "Private key or certificate material detected. Never include these directly in code - store them securely and reference them from protected locations."4546 # SSH Keys47 - pattern: "(?i)ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}"48 message: "SSH key detected. SSH keys should be managed securely and never included directly in code files."4950 # Passwords51 - pattern: "(?i)(password|passwd|pwd|secret)[\\s]*[=:]\\s*['\\\"][^\\s]{3,}['\\\"]"52 message: "Potential password detected. Never hardcode passwords in code files. Use environment variables or a secure secrets manager."5354 # OAuth Tokens55 - pattern: "(?i)(bearer|oauth|access[_-]?token)[\\s]*[=:]\\s*['\\\"][\\w\\d\\-_.]{30,}['\\\"]"56 message: "Potential OAuth token detected. Store tokens securely and consider implementing proper token rotation."5758 # JWT Tokens59 - pattern: "(?i)ey[a-zA-Z0-9]{20,}\\.ey[a-zA-Z0-9\\-_]{20,}\\.[a-zA-Z0-9\\-_]{20,}"60 message: "JWT token detected. Never hardcode JWT tokens directly in your code."6162 # GitHub Tokens63 - pattern: "(?i)gh[pousr]_[a-zA-Z0-9]{20,}"64 message: "GitHub token detected. GitHub tokens should be stored securely in environment variables or a secrets manager."6566 # Slack Tokens67 - pattern: "(?i)(xox[pbar]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})"68 message: "Slack token detected. Store Slack tokens securely using environment variables or a secrets manager."6970 # Stripe API Keys71 - pattern: "(?i)(sk|pk)_(test|live)_[0-9a-zA-Z]{24,}"72 message: "Stripe API key detected. Store Stripe keys securely in environment variables or a secrets manager."7374 # Generic Encryption Keys75 - pattern: "(?i)(encryption[_-]?key|cipher[_-]?key|aes[_-]?key)[\\s]*[=:]\\s*['\\\"][\\w\\d\\-_.]{16,}['\\\"]"76 message: "Potential encryption key detected. Encryption keys should be managed securely and never hardcoded."7778 # .env or config files with credentials79 - pattern: "(?i)(DB_PASSWORD|API_KEY|SECRET_KEY|ADMIN_PASSWORD)[\\s]*=[\\s]*['\"]?[\\w\\d\\-_.]{3,}['\"]?"80 message: "Environment variable with credential detected. Make sure .env files are included in .gitignore and .cursorignore."8182 # IP Addresses (if they appear with credentials)83 - pattern: "(?i)(username|password|login|credential)[^\\n]{3,}(?:\\d{1,3}\\.){3}\\d{1,3}"84 message: "IP address detected near potential credentials. Consider using DNS names and storing connection details securely."8586 - type: suggest87 message: |88 **Secure Secret Management Best Practices:**8990 1. **Never hardcode secrets in source code**91 - Secrets in code can be exposed via version control, logs, or screenshots92 - Code is often shared, backed up, and stored in multiple locations9394 2. **Use environment variables for configuration**95 - Load secrets from environment variables at runtime96 - Use libraries like dotenv, but ensure .env files are in .gitignore97 - Example: `API_KEY=os.environ.get("API_KEY")`9899 3. **Implement secret rotation**100 - Regularly rotate credentials and keys101 - Use short-lived tokens when possible102 - Implement proper secret lifecycle management103104 4. **Use secrets management solutions**105 - AWS Secrets Manager, Azure Key Vault, HashiCorp Vault106 - Platform-specific solutions like Kubernetes Secrets107 - These provide encryption, access control, and audit trails108109 5. **Implement access controls**110 - Limit who can access secrets111 - Use the principle of least privilege112 - Implement proper authentication for secret access113114 6. **Use .gitignore and .cursorignore**115 - Add patterns for files that might contain secrets116 - Example patterns: `.env`, `*.key`, `*secret*`, `*.pem`117 - Verify these files are not committed to version control118119 7. **Consider using secure by default libraries**120 - Libraries that separate configuration from code121 - Frameworks with built-in secrets management122 - Encryption libraries with secure defaults123124 8. **Implement detection tools**125 - Use pre-commit hooks to prevent secret leakage126 - Implement scanning in CI/CD pipelines127 - Consider tools like git-secrets, trufflehog, or detect-secrets128129 9. **Audit and monitor**130 - Regularly audit code for leaked secrets131 - Monitor for unauthorized access to secrets132 - Implement alerts for potential compromises133134 10. **Educate your team**135 - Train developers on secure secret management136 - Establish clear procedures for handling secrets137 - Create a response plan for leaked credentials138139 - type: validate140 conditions:141 - pattern: "(?i)import\\s+os\\s*;?\\s*.*\\s+os\\.environ(\\.get)?"142 message: "Environment variable usage detected, which is a good practice for managing secrets."143144 - pattern: "(?i)process\\.env\\."145 message: "Environment variable usage in JavaScript detected, which is a good practice for managing secrets."146147 - pattern: "(?i)dotenv"148 message: "Dotenv library usage detected, which can help with environment variable management."149150 - pattern: "(?i)(secret[s]?[_-]?manager|key[_-]?vault|hashicorp|vault)"151 message: "Secret management solution reference detected, which is a best practice for handling secrets."152153metadata:154 priority: high155 version: 1.0156 tags:157 - category:security158 - subcategory:secrets159 - subcategory:sensitive-data160 - language:all161 - priority:critical162 references:163 - "https://owasp.org/www-community/vulnerabilities/Hardcoded_credentials"164 - "https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html"165 - "https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning"166 - "https://cloud.google.com/secret-manager/docs/best-practices"167 - "https://aws.amazon.com/blogs/security/how-to-use-aws-secrets-manager-securely-store-rotate-deploy-database-credentials/"168</rule>
Also in ivangrynenko/cursorrules
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| ivangrynenko/cursorrules.cursor/rules/accessibility-standards.mdc · 86 | Cursor rules | ui | 44/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/api-standards.mdc · 86 | Cursor rules | api | 44/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-steps.mdc · 86 | Cursor rules | lint-formatstyleperformanceagent-behaviour | 42/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/build-optimization.mdc · 86 | Cursor rules | build | 48/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/confluence-editing-standards.mdc · 86 | Cursor rules | stylearchsecuritydeployment | 60/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/debugging-standards.mdc · 86 | Cursor rules | no sections | 30/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/docker-compose-standards.mdc · 86 | Cursor rules | style | 62/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-broken-access-control.mdc · 86 | Cursor rules | stylesecurity | 52/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-cryptographic-failures.mdc · 86 | Cursor rules | security | 48/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-database-standards.mdc · 86 | Cursor rules | database | 30/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-injection.mdc · 86 | Cursor rules | securitydo-not | 55/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-insecure-design.mdc · 86 | Cursor rules | security | 48/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-integrity-failures.mdc · 86 | Cursor rules | style | 60/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-logging-failures.mdc · 86 | Cursor rules | security | 48/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-security-misconfiguration.mdc · 86 | Cursor rules | security | 48/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-vulnerable-components.mdc · 86 | Cursor rules | stylesecurity | 67/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/git-commit-standards.mdc · 86 | Cursor rules | git | 44/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/github-actions-standards.mdc · 86 | Cursor rules | no sections | 44/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/improve-cursorrules-efficiency.mdc · 86 | Cursor rules | no sections | 34/100 | 3 days ago | |
| ivangrynenko/cursorrules.cursor/rules/javascript-cryptographic-failures.mdc · 86 | Cursor rules | security | 40/100 | 3 days ago |
Diff against .cursor/rules/accessibility-standards.mdc Diff against .cursor/rules/api-standards.mdc Diff against .cursor/rules/behat-steps.mdc Diff against .cursor/rules/build-optimization.mdc Diff against .cursor/rules/confluence-editing-standards.mdc Diff against .cursor/rules/debugging-standards.mdc Diff against .cursor/rules/docker-compose-standards.mdc Diff against .cursor/rules/drupal-broken-access-control.mdc Diff against .cursor/rules/drupal-cryptographic-failures.mdc Diff against .cursor/rules/drupal-database-standards.mdc Diff against .cursor/rules/drupal-injection.mdc Diff against .cursor/rules/drupal-insecure-design.mdc Diff against .cursor/rules/drupal-integrity-failures.mdc Diff against .cursor/rules/drupal-logging-failures.mdc Diff against .cursor/rules/drupal-security-misconfiguration.mdc Diff against .cursor/rules/drupal-vulnerable-components.mdc Diff against .cursor/rules/git-commit-standards.mdc Diff against .cursor/rules/github-actions-standards.mdc Diff against .cursor/rules/improve-cursorrules-efficiency.mdc Diff against .cursor/rules/javascript-cryptographic-failures.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-user-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 3 days ago | |
| nerds-odd-e/doughnut.cursor/rules/cli.mdc · 49 | Cursor rules | setupbuildteststyle+4 | 96/100 | 3 days ago | |
| skillrecordings/egghead-next.cursor/rules/gh-task-plan.mdc · 1.4k | Cursor rules | teststylearchtypes+2 | 96/100 | 3 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 3 days ago |
