fix(exec): preserve bwrap workspace masking

This commit is contained in:
Xubin Ren
2026-07-27 00:31:00 +08:00
parent 22e61003f9
commit cf6ca13b6d
5 changed files with 80 additions and 9 deletions
+24
View File
@@ -387,6 +387,30 @@ def test_exec_bind_roots_do_not_widen_guard_without_bwrap(tmp_path):
assert "path outside working dir" in blocked
def test_exec_bwrap_bind_parent_does_not_widen_workspace_guard(tmp_path, monkeypatch):
workspace = tmp_path / "workspace"
workspace.mkdir()
secret = tmp_path / "config.json"
secret.write_text("secret")
monkeypatch.setattr("nanobot.agent.tools.shell._IS_WINDOWS", False)
tool = ExecTool(
working_dir=str(workspace),
restrict_to_workspace=True,
sandbox="bwrap",
sandbox_ro_binds=[str(tmp_path)],
)
blocked = tool._guard_command(
f"cat {secret}",
str(workspace),
restrict_to_workspace=True,
workspace_root=str(workspace),
)
assert blocked is not None
assert "path outside working dir" in blocked
# --- format command blocking -----------------------------------------------