File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -242,8 +242,10 @@ async def main():
242242 max_output_length : int | None = None ,
243243 ) -> dict :
244244 """ Execute shell commands in a bash session."""
245+ import shlex
245246 # Change to working directory before executing
246- prefixed_commands = [f " cd { base_path} && { cmd} " for cmd in commands]
247+ safe_path = shlex.quote(base_path)
248+ prefixed_commands = [f " cd { safe_path} && { cmd} " for cmd in commands]
247249 result = await shell_tool(
248250 commands = prefixed_commands,
249251 timeout_ms = timeout_ms,
Original file line number Diff line number Diff line change 3232import argparse
3333import asyncio
3434import os
35+ import shlex
3536
3637from dotenv import load_dotenv
3738from openai import AsyncOpenAI
@@ -124,7 +125,9 @@ async def shell(
124125 max_output_length: Optional max output length hint
125126 """
126127 # Change to working directory before executing
127- prefixed_commands = [f"cd { base_path } && { cmd } " for cmd in commands ]
128+ # Use shlex.quote to safely handle paths with spaces or special characters
129+ safe_path = shlex .quote (base_path )
130+ prefixed_commands = [f"cd { safe_path } && { cmd } " for cmd in commands ]
128131 result = await shell_tool (
129132 commands = prefixed_commands ,
130133 timeout_ms = timeout_ms ,
You can’t perform that action at this time.
0 commit comments