Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mini-swe-agent
9 changes: 7 additions & 2 deletions tests/tools/test_transcription_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,13 @@ def __exit__(self_inner, exc_type, exc, tb):
return _TempDir()

def fake_run(cmd, *args, **kwargs):
if isinstance(cmd, list):
output_path = cmd[-1]
# After shell-injection hardening, both ffmpeg prep and the
# local STT command arrive as lists (shlex.split). Distinguish
# them by checking whether the binary looks like ffmpeg.
cmd_list = cmd if isinstance(cmd, list) else [cmd]
is_ffmpeg = "ffmpeg" in cmd_list[0]
if is_ffmpeg:
output_path = cmd_list[-1]
with open(output_path, "wb") as handle:
handle.write(b"RIFF....WAVEfmt ")
return subprocess.CompletedProcess(cmd, 0, stdout="", stderr="")
Expand Down
5 changes: 4 additions & 1 deletion tools/environments/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ def execute(self, command: str, cwd: str = "", *,
exec_command = f"cd {work_dir} && {exec_command}"
work_dir = "/"

assert self._inner.container_id, "Container not started"
# FIX: use explicit check instead of assert — assertions are stripped
# by python -O, which would silently allow commands on a None container.
if not self._inner.container_id:
raise RuntimeError("Container not started")
cmd = [self._inner.config.executable, "exec"]
if effective_stdin is not None:
cmd.append("-i")
Expand Down
4 changes: 3 additions & 1 deletion tools/transcription_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ def _transcribe_local_command(file_path: str, model_name: str) -> Dict[str, Any]
language=shlex.quote(language),
model=shlex.quote(normalized_model),
)
subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
# SECURITY: avoid shell=True — shlex.split preserves quoted args from
# shlex.quote() above while eliminating shell injection surface.
subprocess.run(shlex.split(command), shell=False, check=True, capture_output=True, text=True)

txt_files = sorted(Path(output_dir).glob("*.txt"))
if not txt_files:
Expand Down
Loading