(command: str)
| 483 | |
| 484 | |
| 485 | def run_bash(command: str) -> str: |
| 486 | dangerous = ["rm -rf /", "sudo", "shutdown", "reboot", "> /dev/"] |
| 487 | if any(d in command for d in dangerous): |
| 488 | return "Error: Dangerous command blocked" |
| 489 | try: |
| 490 | r = subprocess.run( |
| 491 | command, |
| 492 | shell=True, |
| 493 | cwd=WORKDIR, |
| 494 | capture_output=True, |
| 495 | text=True, |
| 496 | timeout=120, |
| 497 | ) |
| 498 | out = (r.stdout + r.stderr).strip() |
| 499 | return out[:50000] if out else "(no output)" |
| 500 | except subprocess.TimeoutExpired: |
| 501 | return "Error: Timeout (120s)" |
| 502 | |
| 503 | |
| 504 | def run_read(path: str, limit: int = None) -> str: |
no test coverage detected