The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): process scan skips other uids' gateways unless root
Teknium93257fd31575
diff --git a/tests/hermes_cli/test_gateway_proc_fallback.py b/tests/hermes_cli/test_gateway_proc_fallback.pyindex 3507c828eb9..cdaf636dc35 100644--- a/tests/hermes_cli/test_gateway_proc_fallback.py+++ b/tests/hermes_cli/test_gateway_proc_fallback.py@@ -114,6 +114,22 @@ class TestProcFallback:mock_ps.assert_not_called() # /proc dir existed, so ps not called[email protected]("linux", "macos")[email protected](("euid", "expected"), [(1000, [111]), (0, [111, 222])])+def test_other_users_gateways_are_not_ours_unless_root(euid, expected):+ """A non-root caller never counts (or signals) another uid's gateway; root keeps the host-wide scan."""+ owners = {111: 1000, 222: 2000}+ ps_out = f"111 {_GATEWAY_CMD}\n222 {_GATEWAY_CMD}\n"+ with (+ patch("os.path.isdir", side_effect=lambda p: p != "/proc"),+ patch("os.geteuid", return_value=euid), # windows-footgun: ok — POSIX-only test (platforms marker)+ patch("hermes_cli.gateway_migrate_guards._pid_uid", side_effect=owners.get),+ patch("hermes_cli.gateway._get_ancestor_pids", return_value=set()),+ patch("subprocess.run", return_value=MagicMock(returncode=0, stdout=ps_out, stderr="")),+ ):+ assert gateway_mod._scan_gateway_pids(set(), all_profiles=True) == expected++@pytest.mark.platforms("linux")class TestPsFallbackBsdCompat:"""The ps fallback must use flags BSD/macOS ps accepts (#73626, #74075).