The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tests): live-system guard lets docker-exec gateway starts through
Tekniumc20766eea7d7
diff --git a/tests/conftest.py b/tests/conftest.pyindex bac63348691..ab0f42c7420 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1561,9 +1561,14 @@ def _live_system_guard(request, monkeypatch):# suffix), restarts the live gateway, and the survivors squat the# webhook port. 2026-09-03: 39 such orphans lived 6 days after a# sibling refactor moved the spawn seam and left tests patching the- # facade. The canonical matcher, never an argv substring.+ # facade. The canonical matcher, never an argv substring. Commands addressed to a+ # container (``docker exec … <cmd>``) run inside that container: a gateway+ # started there cannot reach the host's unit, home or ports, and the Docker+ # harness reaps the container. Only host-side spawns are the hazard.from gateway.status import _gateway_command_subcommand- if not lookalike_ok and _gateway_command_subcommand(cmd_str) in ("run", "start", "restart"):+ argv = cmd if isinstance(cmd, (list, tuple)) else _shlex.split(cmd_str)+ in_container = len(argv) > 1 and str(argv[0]).rsplit("/", 1)[-1] == "docker" and argv[1] == "exec"+ if not lookalike_ok and not in_container and _gateway_command_subcommand(cmd_str) in ("run", "start", "restart"):raise RuntimeError(f"tests/conftest.py live-system guard: blocked "f"subprocess.{name}({cmd!r}) — this would spawn a REAL "diff --git a/tests/test_live_system_guard_self_test.py b/tests/test_live_system_guard_self_test.pyindex 448389ea73a..afd18152b53 100644--- a/tests/test_live_system_guard_self_test.py+++ b/tests/test_live_system_guard_self_test.py@@ -165,6 +165,17 @@ def test_subprocess_run_setsid_systemctl_blocked():subprocess.run(["setsid", "systemctl", "kill", "hermes-gateway"])+def test_host_gateway_start_blocked_but_container_exec_allowed():+ """A host-side ``hermes gateway start`` spawns a real runtime; the same words addressed to+ a container via ``docker exec`` stay inside it and are the Docker harness's business."""+ with pytest.raises(RuntimeError, match="REAL hermes gateway runtime"):+ subprocess.run(["hermes", "-p", "p", "gateway", "start"])+ argv = ["docker", "exec", "-u", "hermes", "hermes-test-x", "sh", "-c", "hermes -p p gateway start"]+ # Past the guard the call reaches the real subprocess.run; a missing binary is fine here.+ with pytest.raises(FileNotFoundError):+ subprocess.run(argv, env={"PATH": "/nonexistent"})++def test_subprocess_run_string_shell_true_blocked():with pytest.raises(RuntimeError, match="live-system guard"):subprocess.run(