fix: forward Steam maintenance navigation

This commit is contained in:
Kurt Himebauch committed 2026-10-28 17:50:58 -04:00
1 parent 2229dbc0a8
commit 48ad5506b6
7 files changed
+92 -2

No files matched your search

@@ -1050,6 +1050,17 @@ def handle(agent_dir, req):
request_timeout(req, 15))
if kind == "steam-selection":
return steam_selection(agent_dir, request_timeout(req, 5))
if kind == "steam-url":
url = req.get("url")
if not isinstance(url, str) or not re.fullmatch(
r"steam://(?:open/downloads|nav/library|uninstall/[1-9][0-9]{0,9})", url):
raise AgentError("INVALID_REQUEST", "Steam navigation URL is not supported")
try:
subprocess.Popen(["steam", url], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, start_new_session=True)
except OSError as e:
raise AgentError("STEAM_UNAVAILABLE", "%s: %s" % (url, e))
return {"launched": True}
if kind == "quit":
return quit_game(agent_dir, req.get("appId"), request_timeout(req, 15))
if kind == "vr":
+16
View File
@@ -196,6 +196,22 @@ class AgentTest(unittest.TestCase):
answer = self.ask({"kind": "vr", "action": "status"})
self.assertEqual("UNAVAILABLE", answer["error"]["code"])
def test_steam_url_uses_client_argv_for_supported_navigation(self):
with patch.object(agent.subprocess, "Popen") as popen:
answer = self.ask({"kind": "steam-url", "url": "steam://open/downloads"})
self.assertTrue(answer["ok"])
self.assertTrue(answer["launched"])
self.assertEqual(["steam", "steam://open/downloads"], popen.call_args.args[0])
self.assertTrue(popen.call_args.kwargs["start_new_session"])
def test_steam_url_rejects_untrusted_routes_and_argument_injection(self):
for url in ("steam://open/settings", "steam://open/downloads\n--exec", "https://example.com"):
with self.subTest(url=url), patch.object(agent.subprocess, "Popen") as popen:
answer = self.ask({"kind": "steam-url", "url": url})
self.assertFalse(answer["ok"])
self.assertEqual("INVALID_REQUEST", answer["error"]["code"])
popen.assert_not_called()
def fake_proc(self, pid, parent, comm, env):
root = self.dir / "proc" / str(pid)
root.mkdir(parents=True)