Cursor rule
.cursor/rules/python-vulnerable-outdated-components.mdcDetect and prevent vulnerabilities related to outdated dependencies and components in Python applications as defined in OWASP Top 10:2021-A06
Cursor rules
Quality
72/100
Scores the file, not the repository.Length
935 words
0 headings · 10 code blocksRepository
86
— · pushed 280 days agoLast changed
3 days ago
First indexed 3 days ago.123456 # Python Vulnerable and Outdated Components Standards (OWASP A06:2021)78This rule enforces security best practices to prevent vulnerabilities related to outdated dependencies and components in Python applications, as defined in OWASP Top 10:2021-A06.910<rule>11name: python_vulnerable_outdated_components12description: Detect and prevent vulnerabilities related to outdated dependencies and components in Python applications as defined in OWASP Top 10:2021-A0613filters:14 - type: file_extension15 pattern: "\\.(py|txt|ini|cfg|yml|yaml|json|toml)$"16 - type: file_path17 pattern: ".*"1819actions:20 - type: enforce21 conditions:22 # Pattern 1: Unpinned dependencies in requirements files23 - pattern: "^(django|flask|fastapi|requests|cryptography|pyyaml|sqlalchemy|celery|numpy|pandas|pillow|tensorflow|torch|boto3|psycopg2)\\s*$"24 file_pattern: "requirements.*\\.txt$|setup\\.py$|pyproject\\.toml$"25 message: "Unpinned dependency detected. Always pin dependencies to specific versions to prevent automatic updates to potentially vulnerable versions."2627 # Pattern 2: Outdated/vulnerable Django versions28 - pattern: "django([<>=]=|~=|==)\\s*[\"']?(1\\.|2\\.[0-2]\\.|3\\.[0-2]\\.|4\\.0\\.)[0-9]+[\"']?"29 message: "Potentially outdated Django version detected. Consider upgrading to the latest stable version with security updates."3031 # Pattern 3: Outdated/vulnerable Flask versions32 - pattern: "flask([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.[0-3]\\.|2\\.0\\.[0-3])[0-9]*[\"']?"33 message: "Potentially outdated Flask version detected. Consider upgrading to the latest stable version with security updates."3435 # Pattern 4: Outdated/vulnerable Requests versions36 - pattern: "requests([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.[0-2][0-5]\\.[0-9]+)[\"']?"37 message: "Potentially outdated Requests version detected. Consider upgrading to the latest stable version with security updates."3839 # Pattern 5: Outdated/vulnerable Cryptography versions40 - pattern: "cryptography([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.|3\\.[0-3]\\.|3\\.4\\.[0-7])[0-9]*[\"']?"41 message: "Potentially outdated Cryptography version detected. Consider upgrading to the latest stable version with security updates."4243 # Pattern 6: Outdated/vulnerable PyYAML versions44 - pattern: "pyyaml([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.|3\\.|4\\.|5\\.[0-5]\\.[0-9]+)[\"']?"45 message: "Potentially outdated PyYAML version detected. Consider upgrading to the latest stable version with security updates."4647 # Pattern 7: Outdated/vulnerable Pillow versions48 - pattern: "pillow([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.|3\\.|4\\.|5\\.|6\\.|7\\.|8\\.[0-3]\\.[0-9]+)[\"']?"49 message: "Potentially outdated Pillow version detected. Consider upgrading to the latest stable version with security updates."5051 # Pattern 8: Direct imports of deprecated modules52 - pattern: "from\\s+xml\\.etree\\.ElementTree\\s+import\\s+.*parse|from\\s+urllib2\\s+import|from\\s+urllib\\s+import\\s+urlopen|import\\s+cgi|import\\s+imp"53 message: "Use of deprecated or insecure module detected. Consider using more secure alternatives."5455 # Pattern 9: Use of deprecated functions56 - pattern: "\\.set_password\\([^)]*\\)|hashlib\\.md5\\(|hashlib\\.sha1\\(|random\\.random\\(|random\\.randrange\\(|random\\.randint\\("57 message: "Use of deprecated or insecure function detected. Consider using more secure alternatives."5859 # Pattern 10: Insecure dependency loading60 - pattern: "__import__\\(|importlib\\.import_module\\(|exec\\(|eval\\("61 message: "Dynamic code execution or module loading detected. This can lead to code injection if user input is involved."6263 # Pattern 11: Outdated TLS/SSL versions64 - pattern: "ssl\\.PROTOCOL_TLSv1|ssl\\.PROTOCOL_TLSv1_1|ssl\\.PROTOCOL_SSLv2|ssl\\.PROTOCOL_SSLv3|ssl\\.PROTOCOL_TLSv1_2"65 message: "Outdated TLS/SSL protocol version detected. Use ssl.PROTOCOL_TLS_CLIENT or ssl.PROTOCOL_TLS_SERVER instead."6667 # Pattern 12: Insecure deserialization libraries68 - pattern: "import\\s+pickle|import\\s+marshal|import\\s+shelve"69 message: "Use of potentially insecure deserialization library detected. Ensure these are not used with untrusted data."7071 # Pattern 13: Outdated/vulnerable SQLAlchemy versions72 - pattern: "sqlalchemy([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.[0-3]\\.[0-9]+)[\"']?"73 message: "Potentially outdated SQLAlchemy version detected. Consider upgrading to the latest stable version with security updates."7475 # Pattern 14: Outdated/vulnerable Celery versions76 - pattern: "celery([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.|3\\.|4\\.[0-4]\\.[0-9]+)[\"']?"77 message: "Potentially outdated Celery version detected. Consider upgrading to the latest stable version with security updates."7879 # Pattern 15: Insecure package installation80 - pattern: "pip\\s+install\\s+.*--no-deps|pip\\s+install\\s+.*--user|pip\\s+install\\s+.*--pre|pip\\s+install\\s+.*--index-url\\s+http://"81 message: "Insecure pip installation options detected. Avoid using --no-deps, ensure HTTPS for index URLs, and be cautious with --pre and --user flags."8283 - type: suggest84 message: |85 **Python Dependency and Component Security Best Practices:**8687 1. **Dependency Management:**88 - Always pin dependencies to specific versions89 - Use a lockfile (requirements.txt, Pipfile.lock, poetry.lock)90 - Example requirements.txt:91```92 Django==4.2.793 requests==2.31.094 cryptography==41.0.595```9697 2. **Vulnerability Scanning:**98 - Regularly scan dependencies for vulnerabilities99 - Use tools like safety, pip-audit, or dependabot100 - Example safety check:101```bash102 pip install safety103 safety check -r requirements.txt104```105106 3. **Dependency Updates:**107 - Establish a regular update schedule108 - Automate updates with tools like Renovate or Dependabot109 - Test thoroughly after updates110 - Example GitHub workflow:111```yaml112 name: Dependency Update113 on:114 schedule:115 - cron: '0 0 * * 1' # Weekly on Monday116 jobs:117 update-deps:118 runs-on: ubuntu-latest119 steps:120 - uses: actions/checkout@v3121 - name: Update dependencies122 run: |123 pip install pip-upgrader124 pip-upgrader -p requirements.txt125```126127 4. **Secure Package Installation:**128 - Use trusted package sources129 - Verify package integrity with hashes130 - Example with pip and hashes:131```132 # requirements.txt133 Django==4.2.7 --hash=sha256:8e0f1c2c2786b5c0e39fe1afce24c926040fad47c8ea8ad30aaa2c03b76293b8134```135136 5. **Minimal Dependencies:**137 - Limit the number of dependencies138 - Regularly audit and remove unused dependencies139 - Consider security history when selecting packages140 - Example dependency audit:141```bash142 pip install pipdeptree143 pipdeptree --warn silence | grep -v "^\s"144```145146 6. **Virtual Environments:**147 - Use isolated environments for each project148 - Document environment setup149 - Example:150```bash151 python -m venv venv152 source venv/bin/activate # On Windows: venv\Scripts\activate153 pip install -r requirements.txt154```155156 7. **Container Security:**157 - Use official base images158 - Pin image versions159 - Scan container images160 - Example Dockerfile:161```dockerfile162 FROM python:3.11-slim@sha256:1234567890abcdef163164 WORKDIR /app165 COPY requirements.txt .166 RUN pip install --no-cache-dir -r requirements.txt167168 COPY . .169 RUN pip install --no-cache-dir -e .170171 USER nobody172 CMD ["gunicorn", "myapp.wsgi:application"]173```174175 8. **Compile-time Dependencies:**176 - Separate runtime and development dependencies177 - Example with pip-tools:178```179 # requirements.in180 Django>=4.2,<5.0181 requests>=2.31.0182183 # dev-requirements.in184 -r requirements.in185 pytest>=7.0.0186 black>=23.0.0187```188189 9. **Deprecated API Usage:**190 - Stay informed about deprecation notices191 - Plan migrations away from deprecated APIs192 - Example Django deprecation check:193```bash194 python manage.py check --deploy195```196197 10. **Supply Chain Security:**198 - Use tools like pip-audit to check for supply chain attacks199 - Consider using a private PyPI mirror200 - Example:201```bash202 pip install pip-audit203 pip-audit204```205206 - type: validate207 conditions:208 # Check 1: Pinned dependencies209 - pattern: "^[a-zA-Z0-9_-]+==\\d+\\.\\d+\\.\\d+"210 file_pattern: "requirements.*\\.txt$"211 message: "Dependencies are properly pinned to specific versions."212213 # Check 2: Use of dependency scanning tools214 - pattern: "safety|pip-audit|pyup|dependabot|renovate"215 file_pattern: "\\.github/workflows/.*\\.ya?ml$|\\.gitlab-ci\\.ya?ml$|tox\\.ini$|setup\\.py$|pyproject\\.toml$"216 message: "Dependency scanning tools are being used."217218 # Check 3: Modern TLS usage219 - pattern: "ssl\\.PROTOCOL_TLS_CLIENT|ssl\\.PROTOCOL_TLS_SERVER|ssl\\.create_default_context\\(\\)"220 message: "Using secure TLS protocol versions."221222 # Check 4: Secure random generation223 - pattern: "secrets\\.token_|secrets\\.choice|cryptography\\.hazmat"224 message: "Using secure random generation methods."225226metadata:227 priority: high228 version: 1.0229 tags:230 - security231 - python232 - dependencies233 - supply-chain234 - owasp235 - language:python236 - framework:django237 - framework:flask238 - framework:fastapi239 - category:security240 - subcategory:dependencies241 - standard:owasp-top10242 - risk:a06-vulnerable-outdated-components243 references:244 - "https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"245 - "https://cheatsheetseries.owasp.org/cheatsheets/Vulnerable_Dependency_Management_Cheat_Sheet.html"246 - "https://pypi.org/project/safety/"247 - "https://pypi.org/project/pip-audit/"248 - "https://github.com/pyupio/safety-db"249 - "https://github.com/pypa/advisory-database"250 - "https://python-security.readthedocs.io/packages.html"251</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 |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 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/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 | |
| skillrecordings/egghead-next.cursor/rules/project-update-user-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/proto.mdc · 126 | Cursor rules | buildlint-formatstylearch+3 | 96/100 | 3 days ago |
