|
| 1 | +rules: |
| 2 | + # .env Rules |
| 3 | + - id: "CONF_DEBUG_ENABLED" |
| 4 | + description: "Debug mode enabled in configuration" |
| 5 | + regex: "(?i)^\\s*DEBUG\\s*=\\s*(true|1|yes)" |
| 6 | + severity: "high" |
| 7 | + confidence: "high" |
| 8 | + category: "config" |
| 9 | + remediation: "Set DEBUG=False in production environments." |
| 10 | + |
| 11 | + - id: "CONF_DATABASE_URL_UNENCRYPTED" |
| 12 | + description: "Plaintext database URL detected" |
| 13 | + regex: "^\\s*DATABASE_URL\\s*=\\s*(postgres|mysql|mongodb)://" |
| 14 | + severity: "high" |
| 15 | + confidence: "high" |
| 16 | + category: "config" |
| 17 | + remediation: "Use encrypted secrets management or mask credentials." |
| 18 | + |
| 19 | + - id: "CONF_ENV_DEV_IN_PROD" |
| 20 | + description: "Development environment setting detected" |
| 21 | + regex: "(?i)^\\s*ENV\\s*=\\s*(dev|development)" |
| 22 | + severity: "medium" |
| 23 | + confidence: "high" |
| 24 | + category: "config" |
| 25 | + remediation: "Ensure this is not a production environment." |
| 26 | + |
| 27 | + # Dockerfile Rules |
| 28 | + - id: "DOCKER_USER_ROOT" |
| 29 | + description: "Container running as root" |
| 30 | + regex: "^\\s*USER\\s+root" |
| 31 | + severity: "high" |
| 32 | + confidence: "high" |
| 33 | + category: "infrastructure" |
| 34 | + remediation: "Create and switch to a non-root user." |
| 35 | + |
| 36 | + - id: "DOCKER_EXPOSE_ALL" |
| 37 | + description: "Exposing service on all interfaces (0.0.0.0)" |
| 38 | + regex: "^\\s*EXPOSE\\s+.*0\\.0\\.0\\.0" |
| 39 | + severity: "medium" |
| 40 | + confidence: "high" |
| 41 | + category: "infrastructure" |
| 42 | + remediation: "Bind to specific interfaces if possible." |
| 43 | + |
| 44 | + - id: "DOCKER_ADD_COPY_ALL" |
| 45 | + description: "Broad COPY instruction (COPY . /)" |
| 46 | + regex: "^\\s*COPY\\s+\\.\\s+/" |
| 47 | + severity: "low" |
| 48 | + confidence: "medium" |
| 49 | + category: "infrastructure" |
| 50 | + remediation: "Use .dockerignore and copy only necessary files." |
| 51 | + |
| 52 | + # Docker Compose Rules (Regex approximation for simple detection, can be refined with yaml parsing) |
| 53 | + - id: "COMPOSE_RESTART_ALWAYS" |
| 54 | + description: "Restart policy set to always" |
| 55 | + regex: "restart:\\s*always" |
| 56 | + severity: "low" |
| 57 | + confidence: "high" |
| 58 | + category: "infrastructure" |
| 59 | + remediation: "Consider 'on-failure' or specific restart policies." |
| 60 | + |
| 61 | + - id: "COMPOSE_PORT_EXPOSURE" |
| 62 | + description: "Port exposed to host (broad range)" |
| 63 | + regex: "\\s*-\\s*[\"']?0\\.0\\.0\\.0:" |
| 64 | + severity: "medium" |
| 65 | + confidence: "high" |
| 66 | + category: "infrastructure" |
| 67 | + remediation: "Bind ports to localhost (127.0.0.1) if external access is not required." |
0 commit comments