subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def clone(owner: str, repo: str, branch: str | None, workdir: Path): target = workdir / f"{owner}__{repo}" if target.exists(): subprocess.run(["rm", "-rf", str(target)], check=True) cmd = ["git", "clone", "--depth=1"] if branch: cmd += ["--branch", branch]- Confidence
- 91% confidence
- Finding
- The script unconditionally deletes an existing target directory under the workdir before cloning, which can destroy prior contents without confirmation or safety checks. In an agent context that may be triggered repeatedly or with shared workspace state, this can cause unintended data loss and disrupt other tasks.
