agentleFS
ivangrynenkoivangrynenko/cursorrules/.cursor/rules/drupal-vulnerable-components.mdc

cursorrules / rules

Cursor rule88 starsChanged 13 months agoMITView on GitHub

Detect and prevent vulnerabilities related to outdated or vulnerable components in Drupal as defined in OWASP Top 10:2021-A06

The file

Show its rules and text

We split this drupal-vulnerable-components.mdc into the rules it gives an agent

16 rules. About 0 are common, 15 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    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
  1. Distinctive:

    Keep Drupal core updated to the latest secure version

    line 48
  2. Distinctive:

    Use security advisories checking in your development workflow

    line 51
  3. Distinctive:

    Use Composer for managing all dependencies

    line 55
  4. Distinctive:

    Add drupal/core-security-advisories as a dev dependency

    line 57
  5. Very specific:

    Use composer outdated to identify outdated packages

    line 59
  6. Distinctive:

    Use modern Drupal APIs rather than deprecated functions

    line 62
  7. Distinctive:

    Update custom code to use current best practices

    line 65
  8. Distinctive:

    Follow the Drupal API deprecation policies

    line 66
  9. Distinctive:

    Use tools like Drupal Check or Upgrade Status module

    line 70
  10. Distinctive:

    Remove unused modules from your codebase

    line 76
  11. Distinctive:

    Prefer well-maintained modules with security teams

    line 77
  12. Distinctive:

    Consider the security impact before adding new dependencies

    line 79
  13. Distinctive:

    Document your dependency management practices

    line 80
  14. Distinctive:

    Check 1: Proper core version requirement

    line 85
  15. Distinctive:

    Check 2: Use of modern APIs

    line 87
  16. Distinctive:

    Check 3: Proper composer usage

    line 89

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
drupal-vulnerable-components.mdc
---
description: Detect and prevent vulnerabilities related to outdated or vulnerable components in Drupal as defined in OWASP Top 10:2021-A06
globs: *.php, *.install, *.module, *.inc, *.theme, *.yml, *.info
alwaysApply: false
---
# Drupal Vulnerable and Outdated Components Standards (OWASP A06:2021)

This rule enforces security best practices to prevent vulnerabilities related to outdated or vulnerable components in Drupal applications, as defined in OWASP Top 10:2021-A06.

## Rule Details

- **Name:** drupal_vulnerable_components

- **Description:** Detect and prevent vulnerabilities related to outdated or vulnerable components in Drupal as defined in OWASP Top 10:2021-A06

## Filters
- file extension pattern: `\\.(php|inc|module|install|info\\.yml|json)$`
- file path pattern: `.*`

## Enforcement Checks
- Conditions:
  - pattern `core:\\s*('|\")8\\.[0-6](mdc:'|\")|core_version_requirement:\\s*('|\")[^9].+('|\")` – Potentially outdated Drupal core version detected. Consider upgrading to the latest secure version of Drupal 9 or 10.
    - Pattern 1: Outdated Drupal core version declaration
  - pattern `drupal_set_message\\(|format_date\\(|drupal_render\\(|entity_load\\(|variable_get\\(|variable_set\\(` – Deprecated function detected. Use modern replacements to ensure compatibility and security updates.
    - Pattern 2: Usage of deprecated functions
  - pattern `jquery\\.min\\.js\\?v=1\\.|jquery-1\\.|jquery-2\\.|ckeditor/|tinymce/|angular\\.js@1\\.` – Potentially vulnerable JavaScript library version detected. Update to the latest secure version.
    - Pattern 3: Known vulnerable libraries referenced
  - pattern `<script\\s+src=['\"]http|<script\\s+src=['\"]//|<link\\s+[^>]*href=['\"]http` – External scripts or stylesheets without Subresource Integrity (SRI) checks detected. Add integrity and crossorigin attributes.
    - Pattern 4: Direct inclusion of external scripts without SRI
  - pattern `module:\\s*('[^']*captcha'|'recaptcha'|'xmlrpc'|'openid'|'php')` – Potentially vulnerable or deprecated module detected. Consider using more secure alternatives.
    - Pattern 5: Use of obsolete or removed modules
  - pattern `\"drupal/[^\"]+\":\\s*\"(~|\\^)?[0-9]\\.[0-9]\\.[0-9]\"` – Hard-coded specific version detected in composer.json. Consider using version ranges to receive security updates.
    - Pattern 6: Hard-coded versions in composer.json
  - pattern `mysql_|split\\(|ereg\\(|eregi\\(|create_function\\(|each\\(` – Deprecated or insecure PHP function detected. Use modern alternatives for better security.
    - Pattern 7: Outdated or insecure PHP API usage
  - pattern `type:\\s*module\\s*\\nname:` – Ensure your module specifies core_version_requirement to prevent installation on unsupported Drupal versions.
    - Pattern 8: Usage of contrib modules without version constraints
  - pattern `composer\\.json` – Consider adding drupal/core-security-advisories as a dev dependency to detect known vulnerable packages.
    - Pattern 9: Missing security advisories handling in composer.json
  - pattern `check_plain\\(|filter_xss\\(|filter_xss_admin\\(` – Legacy text sanitization function detected. Use Html::escape() or Xss::filter() instead.
    - Pattern 10: Direct usage of vulnerable sanitization functions

## Suggestions
- Guidance:
**Drupal Component Security Best Practices:**

1. **Update Management:**
   - Keep Drupal core updated to the latest secure version
   - Subscribe to the Drupal Security Newsletter
   - Implement a regular update schedule (monthly at minimum)
   - Use security advisories checking in your development workflow
   - Implement Composer's security-advisories metadata

2. **Dependency Management:**
   - Use Composer for managing all dependencies
   - Specify version constraints that allow security updates
   - Add drupal/core-security-advisories as a dev dependency
   - Regularly run `composer update --with-dependencies`
   - Use `composer outdated` to identify outdated packages

3. **API Usage:**
   - Use modern Drupal APIs rather than deprecated functions
   - Migrate away from jQuery to modern JavaScript where possible
   - Implement Subresource Integrity (SRI) for external resources
   - Update custom code to use current best practices
   - Follow the Drupal API deprecation policies

4. **Security Monitoring:**
   - Implement automated vulnerability scanning in CI/CD
   - Use tools like Drupal Check or Upgrade Status module
   - Monitor the Drupal security advisories page
   - Implement automated updates for non-critical dependencies
   - Set up alerts for security issues in used components

5. **Module Management:**
   - Remove unused modules from your codebase
   - Prefer well-maintained modules with security teams
   - Implement proper version constraints in module info files
   - Consider the security impact before adding new dependencies
   - Document your dependency management practices

## Validation Checks
- Conditions:
  - pattern `core_version_requirement:\\s*[\"']\\^(8\\.8|8\\.9|9|10)\\.[0-9]+[\"']` – Using proper core version requirements.
    - Check 1: Proper core version requirement
  - pattern `\\\\Drupal::messenger\\(\\)|->messenger\\(\\)|\\\\Drupal::service\\('messenger'\\)` – Using modern message API instead of deprecated functions.
    - Check 2: Use of modern APIs
  - pattern `\"require\":\\s*\\{[^}]*\"drupal/core(-recommended)?\":\\s*\"\\^[0-9]+\\.[0-9]+\"` – Using proper version constraints in Composer.
    - Check 3: Proper composer usage
  - pattern `integrity=[\"'][a-zA-Z0-9\\+/=\\-_]+[\"']\\s+crossorigin=[\"']anonymous[\"']` – Properly implementing Subresource Integrity.
    - Check 4: SRI implementation

## Metadata
- Priority: high
- Version: 1.1
- Tags: security, drupal, dependencies, vulnerable-components, owasp, language:php, framework:drupal, category:security, subcategory:dependencies, standard:owasp-top10, risk:a06-vulnerable-components
## References
- https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/
- https://www.drupal.org/docs/security-in-drupal/staying-up-to-date
- https://www.drupal.org/docs/upgrading-drupal
- https://www.drupal.org/docs/develop/using-composer/managing-dependencies-for-a-drupal-project

 

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.