cursorrules / rules
Cursor rule88 starsChanged 13 months agoMITView on GitHub
Detect and prevent vulnerabilities related to outdated dependencies and components in Python applications as defined in OWASP Top 10:2021-A06
- Installs packages
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository70 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/accessibility-standards.mdcCursor rule
- .cursor/rules/api-standards.mdcCursor rule
- .cursor/rules/behat-ai-guide.mdcCursor rule
- .cursor/rules/behat-steps.mdcCursor rule
- .cursor/rules/build-optimization.mdcCursor rule
- .cursor/rules/code-generation-standards.mdcCursor rule
- .cursor/rules/confluence-editing-standards.mdcCursor rule
- .cursor/rules/cursor-rules.mdcCursor rule
- .cursor/rules/debugging-standards.mdcCursor rule
- .cursor/rules/docker-compose-standards.mdcCursor rule
- .cursor/rules/drupal-authentication-failures.mdcCursor rule
- .cursor/rules/drupal-broken-access-control.mdcCursor rule
- .cursor/rules/drupal-cryptographic-failures.mdcCursor rule
- .cursor/rules/drupal-database-standards.mdcCursor rule
- .cursor/rules/drupal-file-permissions.mdcCursor rule
- .cursor/rules/drupal-injection.mdcCursor rule
- .cursor/rules/drupal-insecure-design.mdcCursor rule
- .cursor/rules/drupal-integrity-failures.mdcCursor rule
- .cursor/rules/drupal-logging-failures.mdcCursor rule
- .cursor/rules/drupal-security-misconfiguration.mdcCursor rule
- .cursor/rules/drupal-ssrf.mdcCursor rule
- .cursor/rules/drupal-vulnerable-components.mdcCursor rule
- .cursor/rules/generic_bash_style.mdcCursor rule
- .cursor/rules/git-commit-standards.mdcCursor rule
- .cursor/rules/github-actions-standards.mdcCursor rule
- .cursor/rules/improve-cursorrules-efficiency.mdcCursor rule
- .cursor/rules/javascript-broken-access-control.mdcCursor rule
- .cursor/rules/javascript-cryptographic-failures.mdcCursor rule
- .cursor/rules/javascript-identification-authentication-failures.mdcCursor rule
- .cursor/rules/javascript-injection.mdcCursor rule
- .cursor/rules/javascript-insecure-design.mdcCursor rule
- .cursor/rules/javascript-performance.mdcCursor rule
- .cursor/rules/javascript-security-logging-monitoring-failures.mdcCursor rule
- .cursor/rules/javascript-security-misconfiguration.mdcCursor rule
- .cursor/rules/javascript-server-side-request-forgery.mdcCursor rule
- .cursor/rules/javascript-software-data-integrity-failures.mdcCursor rule
- .cursor/rules/javascript-standards.mdcCursor rule
- .cursor/rules/javascript-vulnerable-outdated-components.mdcCursor rule
- .cursor/rules/lagoon-docker-compose-standards.mdcCursor rule
- .cursor/rules/lagoon-yml-standards.mdcCursor rule
- .cursor/rules/multi-agent-coordination.mdcCursor rule
- .cursor/rules/new-pull-request.mdcCursor rule
- .cursor/rules/node-dependencies.mdcCursor rule
- .cursor/rules/php-drupal-best-practices.mdcCursor rule
- .cursor/rules/php-drupal-development-standards.mdcCursor rule
- .cursor/rules/php-memory-optimisation.mdcCursor rule
- .cursor/rules/project-definition-template.mdcCursor rule
- .cursor/rules/pull-request-changelist-instructions.mdcCursor rule
- .cursor/rules/python-authentication-failures.mdcCursor rule
- .cursor/rules/python-broken-access-control.mdcCursor rule
- .cursor/rules/python-cryptographic-failures.mdcCursor rule
- .cursor/rules/python-injection.mdcCursor rule
- .cursor/rules/python-insecure-design.mdcCursor rule
- .cursor/rules/python-integrity-failures.mdcCursor rule
- .cursor/rules/python-logging-monitoring-failures.mdcCursor rule
- .cursor/rules/python-security-misconfiguration.mdcCursor rule
- .cursor/rules/python-ssrf.mdcCursor rule
- .cursor/rules/react-patterns.mdcCursor rule
- The first 60 shown.
The file
We split this python-vulnerable-outdated-components.mdc into the rules it gives an agent
11 rules. About 0 are common, 10 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 88
Always pin dependencies to specific versions
- Very specific: line 89
Use a lockfile (requirements.txt, Pipfile.lock, poetry.lock)
- Distinctive: line 99
Use tools like safety, pip-audit, or dependabot
- Distinctive: line 109
Test thoroughly after updates
- Distinctive: line 128
Use trusted package sources
- Distinctive: line 129
Verify package integrity with hashes
- Distinctive: line 139
Consider security history when selecting packages
- Distinctive: line 147
Use isolated environments for each project
- Distinctive: line 157
Use official base images
- Distinctive: line 198
Use tools like pip-audit to check for supply chain attacks
- Distinctive: line 199
Consider using a private PyPI mirror
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Detect and prevent vulnerabilities related to outdated dependencies and components in Python applications as defined in OWASP Top 10:2021-A06
globs: *.py, *.txt, *.ini, *.cfg, *.yml, *.yaml, *.json, *.toml
alwaysApply: false
---
# Python Vulnerable and Outdated Components Standards (OWASP A06:2021)
This 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.
<rule>
name: python_vulnerable_outdated_components
description: Detect and prevent vulnerabilities related to outdated dependencies and components in Python applications as defined in OWASP Top 10:2021-A06
filters:
- type: file_extension
pattern: "\\.(py|txt|ini|cfg|yml|yaml|json|toml)$"
- type: file_path
pattern: ".*"
actions:
- type: enforce
conditions:
# Pattern 1: Unpinned dependencies in requirements files
- pattern: "^(django|flask|fastapi|requests|cryptography|pyyaml|sqlalchemy|celery|numpy|pandas|pillow|tensorflow|torch|boto3|psycopg2)\\s*$"
file_pattern: "requirements.*\\.txt$|setup\\.py$|pyproject\\.toml$"
message: "Unpinned dependency detected. Always pin dependencies to specific versions to prevent automatic updates to potentially vulnerable versions."
# Pattern 2: Outdated/vulnerable Django versions
- pattern: "django([<>=]=|~=|==)\\s*[\"']?(1\\.|2\\.[0-2]\\.|3\\.[0-2]\\.|4\\.0\\.)[0-9]+[\"']?"
message: "Potentially outdated Django version detected. Consider upgrading to the latest stable version with security updates."
# Pattern 3: Outdated/vulnerable Flask versions
- pattern: "flask([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.[0-3]\\.|2\\.0\\.[0-3])[0-9]*[\"']?"
message: "Potentially outdated Flask version detected. Consider upgrading to the latest stable version with security updates."
# Pattern 4: Outdated/vulnerable Requests versions
- pattern: "requests([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.[0-2][0-5]\\.[0-9]+)[\"']?"
message: "Potentially outdated Requests version detected. Consider upgrading to the latest stable version with security updates."
# Pattern 5: Outdated/vulnerable Cryptography versions
- pattern: "cryptography([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.|3\\.[0-3]\\.|3\\.4\\.[0-7])[0-9]*[\"']?"
message: "Potentially outdated Cryptography version detected. Consider upgrading to the latest stable version with security updates."
# Pattern 6: Outdated/vulnerable PyYAML versions
- pattern: "pyyaml([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.|3\\.|4\\.|5\\.[0-5]\\.[0-9]+)[\"']?"
message: "Potentially outdated PyYAML version detected. Consider upgrading to the latest stable version with security updates."
# Pattern 7: Outdated/vulnerable Pillow versions
- pattern: "pillow([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.|3\\.|4\\.|5\\.|6\\.|7\\.|8\\.[0-3]\\.[0-9]+)[\"']?"
message: "Potentially outdated Pillow version detected. Consider upgrading to the latest stable version with security updates."
# Pattern 8: Direct imports of deprecated modules
- 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"
message: "Use of deprecated or insecure module detected. Consider using more secure alternatives."
# Pattern 9: Use of deprecated functions
- pattern: "\\.set_password\\([^)]*\\)|hashlib\\.md5\\(|hashlib\\.sha1\\(|random\\.random\\(|random\\.randrange\\(|random\\.randint\\("
message: "Use of deprecated or insecure function detected. Consider using more secure alternatives."
# Pattern 10: Insecure dependency loading
- pattern: "__import__\\(|importlib\\.import_module\\(|exec\\(|eval\\("
message: "Dynamic code execution or module loading detected. This can lead to code injection if user input is involved."
# Pattern 11: Outdated TLS/SSL versions
- pattern: "ssl\\.PROTOCOL_TLSv1|ssl\\.PROTOCOL_TLSv1_1|ssl\\.PROTOCOL_SSLv2|ssl\\.PROTOCOL_SSLv3|ssl\\.PROTOCOL_TLSv1_2"
message: "Outdated TLS/SSL protocol version detected. Use ssl.PROTOCOL_TLS_CLIENT or ssl.PROTOCOL_TLS_SERVER instead."
# Pattern 12: Insecure deserialization libraries
- pattern: "import\\s+pickle|import\\s+marshal|import\\s+shelve"
message: "Use of potentially insecure deserialization library detected. Ensure these are not used with untrusted data."
# Pattern 13: Outdated/vulnerable SQLAlchemy versions
- pattern: "sqlalchemy([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.[0-3]\\.[0-9]+)[\"']?"
message: "Potentially outdated SQLAlchemy version detected. Consider upgrading to the latest stable version with security updates."
# Pattern 14: Outdated/vulnerable Celery versions
- pattern: "celery([<>=]=|~=|==)\\s*[\"']?(0\\.|1\\.|2\\.|3\\.|4\\.[0-4]\\.[0-9]+)[\"']?"
message: "Potentially outdated Celery version detected. Consider upgrading to the latest stable version with security updates."
# Pattern 15: Insecure package installation
- 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://"
message: "Insecure pip installation options detected. Avoid using --no-deps, ensure HTTPS for index URLs, and be cautious with --pre and --user flags."
- type: suggest
message: |
**Python Dependency and Component Security Best Practices:**
1. **Dependency Management:**
- Always pin dependencies to specific versions
- Use a lockfile (requirements.txt, Pipfile.lock, poetry.lock)
- Example requirements.txt:
```
Django==4.2.7
requests==2.31.0
cryptography==41.0.5
```
2. **Vulnerability Scanning:**
- Regularly scan dependencies for vulnerabilities
- Use tools like safety, pip-audit, or dependabot
- Example safety check:
```bash
pip install safety
safety check -r requirements.txt
```
3. **Dependency Updates:**
- Establish a regular update schedule
- Automate updates with tools like Renovate or Dependabot
- Test thoroughly after updates
- Example GitHub workflow:
```yaml
name: Dependency Update
on:
schedule:
- cron: '0 0 * * 1' # Weekly on Monday
jobs:
update-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update dependencies
run: |
pip install pip-upgrader
pip-upgrader -p requirements.txt
```
4. **Secure Package Installation:**
- Use trusted package sources
- Verify package integrity with hashes
- Example with pip and hashes:
```
# requirements.txt
Django==4.2.7 --hash=sha256:8e0f1c2c2786b5c0e39fe1afce24c926040fad47c8ea8ad30aaa2c03b76293b8
```
5. **Minimal Dependencies:**
- Limit the number of dependencies
- Regularly audit and remove unused dependencies
- Consider security history when selecting packages
- Example dependency audit:
```bash
pip install pipdeptree
pipdeptree --warn silence | grep -v "^\s"
```
6. **Virtual Environments:**
- Use isolated environments for each project
- Document environment setup
- Example:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
```
7. **Container Security:**
- Use official base images
- Pin image versions
- Scan container images
- Example Dockerfile:
```dockerfile
FROM python:3.11-slim@sha256:1234567890abcdef
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN pip install --no-cache-dir -e .
USER nobody
CMD ["gunicorn", "myapp.wsgi:application"]
```
8. **Compile-time Dependencies:**
- Separate runtime and development dependencies
- Example with pip-tools:
```
# requirements.in
Django>=4.2,<5.0
requests>=2.31.0
# dev-requirements.in
-r requirements.in
pytest>=7.0.0
black>=23.0.0
```
9. **Deprecated API Usage:**
- Stay informed about deprecation notices
- Plan migrations away from deprecated APIs
- Example Django deprecation check:
```bash
python manage.py check --deploy
```
10. **Supply Chain Security:**
- Use tools like pip-audit to check for supply chain attacks
- Consider using a private PyPI mirror
- Example:
```bash
pip install pip-audit
pip-audit
```
- type: validate
conditions:
# Check 1: Pinned dependencies
- pattern: "^[a-zA-Z0-9_-]+==\\d+\\.\\d+\\.\\d+"
file_pattern: "requirements.*\\.txt$"
message: "Dependencies are properly pinned to specific versions."
# Check 2: Use of dependency scanning tools
- pattern: "safety|pip-audit|pyup|dependabot|renovate"
file_pattern: "\\.github/workflows/.*\\.ya?ml$|\\.gitlab-ci\\.ya?ml$|tox\\.ini$|setup\\.py$|pyproject\\.toml$"
message: "Dependency scanning tools are being used."
# Check 3: Modern TLS usage
- pattern: "ssl\\.PROTOCOL_TLS_CLIENT|ssl\\.PROTOCOL_TLS_SERVER|ssl\\.create_default_context\\(\\)"
message: "Using secure TLS protocol versions."
# Check 4: Secure random generation
- pattern: "secrets\\.token_|secrets\\.choice|cryptography\\.hazmat"
message: "Using secure random generation methods."
metadata:
priority: high
version: 1.0
tags:
- security
- python
- dependencies
- supply-chain
- owasp
- language:python
- framework:django
- framework:flask
- framework:fastapi
- category:security
- subcategory:dependencies
- standard:owasp-top10
- risk:a06-vulnerable-outdated-components
references:
- "https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"
- "https://cheatsheetseries.owasp.org/cheatsheets/Vulnerable_Dependency_Management_Cheat_Sheet.html"
- "https://pypi.org/project/safety/"
- "https://pypi.org/project/pip-audit/"
- "https://github.com/pyupio/safety-db"
- "https://github.com/pypa/advisory-database"
- "https://python-security.readthedocs.io/packages.html"
</rule>Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

