Skip to content

Commit a931976

Browse files
Merge pull request #15 from Rootless-Ghost/alert-autofix-232
Potential fix for code scanning alert no. 2: Uncontrolled command line
2 parents 60d4fd7 + 732e679 commit a931976

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

core/executor.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,26 @@ def _build_command(command: str, executor_type: str) -> list[str] | None:
294294
if executor_type == "cmd":
295295
if system == "windows":
296296
return ["cmd.exe", "/c", command]
297-
# Fall back to sh on non-Windows
298-
return ["sh", "-c", command]
297+
# Fall back to direct execution on non-Windows (avoid shell -c)
298+
try:
299+
argv = shlex.split(command, posix=True)
300+
except ValueError:
301+
return None
302+
return argv or None
299303

300304
if executor_type == "bash":
301-
return ["bash", "-c", command]
305+
try:
306+
argv = shlex.split(command, posix=True)
307+
except ValueError:
308+
return None
309+
return argv or None
302310

303311
if executor_type == "sh":
304-
return ["sh", "-c", command]
312+
try:
313+
argv = shlex.split(command, posix=True)
314+
except ValueError:
315+
return None
316+
return argv or None
305317

306318
return None
307319

0 commit comments

Comments
 (0)