subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run(cmd: list[str], cwd: Path | None = None, desc: str = "") -> int: print(f"\n>>> {desc or ' '.join(cmd)}") result = subprocess.run(cmd, cwd=str(cwd) if cwd else None) if result.returncode != 0: print(f"[ERROR] Command failed (exit {result.returncode}): {' '.join(cmd)}") return result.returncode- Confidence
- 95% confidence
- Finding
- result = subprocess.run(cmd, cwd=str(cwd) if cwd else None)
