diff --git a/CHANGELOG.md b/CHANGELOG.md index 126949442..94b408313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +- Fixed `shell=True` subprocess usage in `cli_coverage_steps.py` by replacing + with `shlex.split()` and `shell=False` for defense-in-depth command injection + prevention, consistent with the existing pattern in + `cli_plan_context_commands_steps.py`. (#734) - Added BuiltinAdapter class and MCP automatic resource slot creation. BuiltinAdapter wraps register_file_tools/register_git_tools/register_subplan_tool into a unified adapter interface. McpAdapter.infer_resource_slots() analyzes diff --git a/features/steps/cli_coverage_steps.py b/features/steps/cli_coverage_steps.py index 10a7081ed..2354879f6 100644 --- a/features/steps/cli_coverage_steps.py +++ b/features/steps/cli_coverage_steps.py @@ -1,5 +1,6 @@ """Step definitions for CLI coverage tests.""" +import shlex import subprocess import sys from contextlib import redirect_stdout @@ -39,9 +40,8 @@ def step_run_shell_command(context, command): else: command = python_cmd + command[len("cleveragents") :] - # Use shell=True to handle quoted arguments correctly result = subprocess.run( - command, capture_output=True, text=True, timeout=120, cwd=cwd, shell=True + shlex.split(command), capture_output=True, text=True, timeout=120, cwd=cwd ) context.exit_code = result.returncode context.output = result.stdout + result.stderr