cursorrules / rules
Cursor rule88 starsChanged 13 months agoMITView on GitHub
Drupal file permissions security standards
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-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/python-vulnerable-outdated-components.mdcCursor rule
- .cursor/rules/react-patterns.mdcCursor rule
- The first 60 shown.
The file
We split this drupal-file-permissions.mdc into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
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
- Very specific: line 57
Create a script at /app/scripts/custom/fix-drupal-permissions.sh:
- Distinctive: line 99
Never set 777 permissions on any Drupal files or directories
- Distinctive: line 101
Use Drupal's private file system for sensitive uploads
- Distinctive: line 103
Consider using file encryption for highly sensitive data
≈ “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: Drupal file permissions security standards
globs: *.dockerfile, *.sh, docker-compose.yml, Dockerfile
---
# Drupal File Permissions Security
Standards for securing Drupal file permissions in Docker environments and production servers, ensuring proper security while maintaining functionality.
## Rule Details
- **Name:** drupal_file_permissions
- **Description:** Enforce secure file permissions for Drupal sites/default directory and critical files
## Filters
- file extension pattern: `\\.(dockerfile|sh|yml)$`
- file name: `^Dockerfile$|^docker-compose\\.yml$`
- content: `(?i)chmod|chown|drupal|settings\\.php|services\\.yml`
## Enforcement Checks
- Conditions:
- pattern `chmod\\s+(?!755)\\d+\\s+[^\\n]*sites\\/default(?![^\\n]*files)` – sites/default directory should have 755 permissions (read-only for group/others)
- pattern `chmod\\s+(?!444)\\d+\\s+[^\\n]*settings\\.php` – settings.php should have 444 permissions (read-only for everyone)
- pattern `chmod\\s+(?!444)\\d+\\s+[^\\n]*services\\.yml` – services.yml should have 444 permissions (read-only for everyone)
- pattern `chmod\\s+(?!755)\\d+\\s+[^\\n]*sites\\/default\\/files` – sites/default/files directory should have 755 permissions with proper ownership
- pattern `chown\\s+(?!www-data:www-data)[^\\s]+\\s+[^\\n]*sites\\/default\\/files` – sites/default/files should be owned by the web server user (www-data:www-data)
## Suggestions
- Guidance:
## Drupal File Permissions Security Best Practices
### 1. Critical File Permissions
- **sites/default directory**: 755 (drwxr-xr-x)
- **settings.php**: 444 (r--r--r--)
- **services.yml**: 444 (r--r--r--)
- **settings.local.php**: 444 (r--r--r--)
- **sites/default/files**: 755 (drwxr-xr-x)
- **sites/default/files/** (contents): 644 (rw-r--r--) for files, 755 (drwxr-xr-x) for directories
### 2. Ownership Configuration
- **Web root**: application user (varies by environment)
- **sites/default/files**: web server user (www-data:www-data)
### 3. Implementation in Dockerfile
```dockerfile
# Set proper permissions for Drupal
RUN mkdir -p /app/${WEBROOT}/sites/default/files && \
chown www-data:www-data /app/${WEBROOT}/sites/default/files && \
chmod 755 /app/${WEBROOT}/sites/default && \
chmod 444 /app/${WEBROOT}/sites/default/settings.php && \
chmod 444 /app/${WEBROOT}/sites/default/services.yml && \
find /app/${WEBROOT}/sites/default/files -type d -exec chmod 755 {} \\; && \
find /app/${WEBROOT}/sites/default/files -type f -exec chmod 644 {} \\;
```
### 4. Permission Fix Script
Create a script at `/app/scripts/custom/fix-drupal-permissions.sh`:
```bash
#!/bin/bash
# Exit on error
set -e
WEBROOT=${WEBROOT:-web}
echo "Setting Drupal file permissions..."
# Ensure directories exist
mkdir -p /app/${WEBROOT}/sites/default/files
# Set ownership
chown www-data:www-data /app/${WEBROOT}/sites/default/files
# Set directory permissions
chmod 755 /app/${WEBROOT}/sites/default
chmod 755 /app/${WEBROOT}/sites/default/files
find /app/${WEBROOT}/sites/default/files -type d -exec chmod 755 {} \;
# Set file permissions
chmod 444 /app/${WEBROOT}/sites/default/settings.php
[ -f /app/${WEBROOT}/sites/default/services.yml ] && chmod 444 /app/${WEBROOT}/sites/default/services.yml
[ -f /app/${WEBROOT}/sites/default/settings.local.php ] && chmod 444 /app/${WEBROOT}/sites/default/settings.local.php
find /app/${WEBROOT}/sites/default/files -type f -exec chmod 644 {} \;
echo "Drupal file permissions set successfully."
```
### 5. Verify Permissions
```bash
# Check file permissions
ahoy cli "ls -la /app/${WEBROOT}/sites/default"
ahoy cli "ls -la /app/${WEBROOT}/sites/default/files"
# Check Drupal status
ahoy drush status-report | grep -i "protected"
```
### 6. Security Considerations
- Never set 777 permissions on any Drupal files or directories
- Temporary files should be stored in private file system when possible
- Use Drupal's private file system for sensitive uploads
- Implement file access controls through Drupal's permission system
- Consider using file encryption for highly sensitive data
## Metadata
- Priority: high
- Version: 1.2
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.

