Check if command matches any forbidden pattern. Returns (True, error_message) if forbidden pattern found, None otherwise.
(command: str)
| 131 | |
| 132 | |
| 133 | def check_forbidden_pattern(command: str) -> tuple[bool, str] | None: |
| 134 | """ |
| 135 | Check if command matches any forbidden pattern. |
| 136 | |
| 137 | Returns (True, error_message) if forbidden pattern found, None otherwise. |
| 138 | """ |
| 139 | for pattern, error_msg in FORBIDDEN_PATTERNS: |
| 140 | if re.search(pattern, command): |
| 141 | return (True, error_msg) |
| 142 | return None |
| 143 | |
| 144 | |
| 145 | def check_forbidden_env_vars(command: str) -> tuple[bool, str, str] | None: |