fix(exec): confine selected shells behind the sandbox launcher
Co-authored-by: Tenable Research <152317477+tenbbughunters@users.noreply.github.com>
This commit is contained in:
1 parent
c8dba74fc5
commit
4dd3fbecb6
5 files changed
+212
-21
No files matched your search
@@ -224,11 +224,12 @@ async def test_direct_search_uses_configured_path(tmp_path, monkeypatch):
|
||||
@pytest.mark.parametrize("backend", ["bwrap", "seatbelt"])
|
||||
def test_direct_search_preserves_sandbox_and_arguments(tmp_path, monkeypatch, backend):
|
||||
monkeypatch.setattr("nanobot.agent.tools.shell._IS_WINDOWS", False)
|
||||
monkeypatch.setattr("nanobot.agent.tools.shell.shutil.which", lambda name, **_kwargs: f"/usr/bin/{name}" if "/" not in name else name)
|
||||
args = ["rg", "-F", "hello | $HOME; 'world'", "."]
|
||||
prepared = RgTool(working_dir=str(tmp_path), sandbox=backend)._prepare_command(args)
|
||||
assert isinstance(prepared, _PreparedCommand)
|
||||
assert isinstance(prepared.command, list)
|
||||
assert prepared.command[0] == ("bwrap" if backend == "bwrap" else "/usr/bin/sandbox-exec")
|
||||
assert prepared.command[0] == ("/usr/bin/bwrap" if backend == "bwrap" else "/usr/bin/sandbox-exec")
|
||||
assert prepared.command[-2] == "-c"
|
||||
inner_command = prepared.command[-1].split("\n")[-1]
|
||||
assert shlex.split(inner_command) == args
|
||||
Reference in new issue
Block a user