From 7b38d3c81453868cd284b0bf8cd35e124bc8b1af Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:51:56 +0800 Subject: [PATCH] test(exec): capture nonstandard sandbox launcher behavior --- tests/tools/test_sandbox_launcher_compat.py | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/tools/test_sandbox_launcher_compat.py diff --git a/tests/tools/test_sandbox_launcher_compat.py b/tests/tools/test_sandbox_launcher_compat.py new file mode 100644 index 000000000..1f84a3493 --- /dev/null +++ b/tests/tools/test_sandbox_launcher_compat.py @@ -0,0 +1,29 @@ +"""Regression coverage for nonstandard sandbox launcher installations.""" + +import os + +from nanobot.agent.tools.shell import ExecTool + + +async def test_nonstandard_bwrap_is_not_silently_run_without_sandbox(tmp_path, monkeypatch): + workspace = tmp_path / "workspace" + workspace.mkdir() + extra_bin = tmp_path / "extra-bin" + extra_bin.mkdir() + default_bin = tmp_path / "system-bin" + default_bin.mkdir() + launcher = extra_bin / "bwrap" + launcher.write_text("#!/bin/sh\nprintf launched > \"$1\"\n") + launcher.chmod(0o700) + marker = workspace / "command-ran" + + monkeypatch.setattr("nanobot.agent.tools.shell._IS_WINDOWS", False) + monkeypatch.setattr(os, "defpath", str(default_bin)) + monkeypatch.setenv("PATH", str(extra_bin)) + monkeypatch.setattr("nanobot.agent.tools.sandbox.get_media_dir", lambda: workspace) + tool = ExecTool(working_dir=str(workspace), sandbox="bwrap") + + result = await tool.execute(command="printf ran > command-ran") + + assert "sandbox launcher not found: bwrap" in result + assert not marker.exists()