(command: str)
| 9 | ] |
| 10 | |
| 11 | def is_dangerous(command: str) -> bool: |
| 12 | cmd_parts = command.split() |
| 13 | if not cmd_parts: |
| 14 | return False |
| 15 | base_cmd = Path(cmd_parts[0]).name |
| 16 | if base_cmd in DANGEROUS_COMMANDS: |
| 17 | return True |
| 18 | cmd_lower = command.lower() |
| 19 | dangerous_patterns = ["sudo ", "> /dev/", "| sh", "| bash", ":(){:|:&};:"] |
| 20 | return any(p in cmd_lower for p in dangerous_patterns) |
| 21 | |
| 22 | def shell(command: str, yolo: bool = False, timeout: int = 1800) -> str: |
| 23 | """ |