Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix: guard quoted home paths in shell tool
Re-bin9d0db072a381
diff --git a/nanobot/agent/tools/shell.py b/nanobot/agent/tools/shell.pyindex 4726e3cea..b65093081 100644--- a/nanobot/agent/tools/shell.py+++ b/nanobot/agent/tools/shell.py@@ -155,6 +155,6 @@ class ExecTool(Tool):@staticmethoddef _extract_absolute_paths(command: str) -> list[str]:win_paths = re.findall(r"[A-Za-z]:\\[^\s\"'|><;]+", command) # Windows: C:\...- posix_paths = re.findall(r"(?:^|[\s|>])(/[^\s\"'>]+)", command) # POSIX: /absolute only- home_paths = re.findall(r"(?:^|[\s|>])(~[^\s\"'>;|<]*)", command) # POSIX/Windows home shortcut: ~+ posix_paths = re.findall(r"(?:^|[\s|>'\"])(/[^\s\"'>;|<]+)", command) # POSIX: /absolute only+ home_paths = re.findall(r"(?:^|[\s|>'\"])(~[^\s\"'>;|<]*)", command) # POSIX/Windows home shortcut: ~return win_paths + posix_paths + home_pathsdiff --git a/tests/test_tool_validation.py b/tests/test_tool_validation.pyindex cf648bf4d..e67acbfcf 100644--- a/tests/test_tool_validation.py+++ b/tests/test_tool_validation.py@@ -115,12 +115,25 @@ def test_exec_extract_absolute_paths_captures_home_paths() -> None:assert "~/out.txt" in paths+def test_exec_extract_absolute_paths_captures_quoted_paths() -> None:+ cmd = 'cat "/tmp/data.txt" "~/.nanobot/config.json"'+ paths = ExecTool._extract_absolute_paths(cmd)+ assert "/tmp/data.txt" in paths+ assert "~/.nanobot/config.json" in paths++def test_exec_guard_blocks_home_path_outside_workspace(tmp_path) -> None:tool = ExecTool(restrict_to_workspace=True)error = tool._guard_command("cat ~/.nanobot/config.json", str(tmp_path))assert error == "Error: Command blocked by safety guard (path outside working dir)"+def test_exec_guard_blocks_quoted_home_path_outside_workspace(tmp_path) -> None:+ tool = ExecTool(restrict_to_workspace=True)+ error = tool._guard_command('cat "~/.nanobot/config.json"', str(tmp_path))+ assert error == "Error: Command blocked by safety guard (path outside working dir)"++# --- cast_params tests ---