The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(plugins): Desktop and Webapp agent-plugin installs clone https only
Teknium12944611f0a0
diff --git a/hermes_cli/plugins_cmd_install.py b/hermes_cli/plugins_cmd_install.pyindex 1ec9c0f203c..22176f8f173 100644--- a/hermes_cli/plugins_cmd_install.py+++ b/hermes_cli/plugins_cmd_install.py@@ -849,6 +849,25 @@ def _resolve_source(identifier: str, catalog_name: Optional[str]) -> tuple:return entry, identifier, warnings, None+def gui_install_source_refusal(identifier: str, catalog_name: Optional[str] = None) -> Optional[str]:+ """Why a Desktop/Webapp install of *identifier* is refused, else None.++ A GUI install clones over ``https://`` only: a click there names a source the user may not have+ read, and ``file://`` copies any local folder, ``ssh``/``git@`` signs in with the host's ssh-agent,+ ``http://`` is unauthenticated. ``hermes plugins install`` keeps accepting every documented scheme.+ A *catalog_name* install clones the catalog's own source, so *identifier* is not used."""+ if catalog_name:+ return None+ try:+ git_url = _pc()._resolve_git_url(identifier.strip())[0]+ except ValueError:+ return None # not a source at all: the installer's own error names it+ if git_url.startswith("https://"):+ return None+ return ("Plugins are installed from Hermes Desktop and the Webapp over https:// only. "+ "Use `hermes plugins install` in a terminal for other sources.")++def _place_tree(entry, identifier: str, *, force: bool, ref: Optional[str], assume_deps_consent: bool,step: Callable[[InstallPhase], None], inspected_sha: Optional[str] = None) -> tuple | dict:"""``(target, manifest, installed_name)`` of the tree to enable, or the error result. A catalogdiff --git a/hermes_cli/web_routers/dashboard_ui.py b/hermes_cli/web_routers/dashboard_ui.pyindex dd774f8a1e6..34654e2e876 100644--- a/hermes_cli/web_routers/dashboard_ui.py+++ b/hermes_cli/web_routers/dashboard_ui.py@@ -202,11 +202,14 @@ async def _plugin_mutation(fn: Callable[[], dict]) -> dict:async def post_agent_plugin_install(request: Request, body: _AgentPluginInstallBody):_require_token(request)from hermes_cli.plugins_cmd import dashboard_install_plugin+ from hermes_cli.plugins_cmd_install import gui_install_source_refusalcatalog_name = (body.catalog_name or "").strip()identifier = body.identifier.strip()if not identifier and not catalog_name:raise HTTPException(status_code=400, detail="Provide an identifier or a catalog_name.")+ if refusal := gui_install_source_refusal(identifier, catalog_name):+ raise HTTPException(status_code=400, detail=refusal)result = await _plugin_mutation(lambda: _plugin_action(dashboard_install_plugin(identifier, force=body.force, enable=body.enable, catalog_name=catalog_name or None,diff --git a/tests/hermes_cli/test_web_plugin_install_source.py b/tests/hermes_cli/test_web_plugin_install_source.pynew file mode 100644index 00000000000..dac10cf095a--- /dev/null+++ b/tests/hermes_cli/test_web_plugin_install_source.py@@ -0,0 +1,35 @@+"""POST /api/dashboard/agent-plugins/install clones over https:// only, like plugins.manage install."""++import pytest+++def client(monkeypatch, _isolate_hermes_home):+ try:+ from starlette.testclient import TestClient+ except ImportError:+ pytest.skip("fastapi/starlette not installed")+ import hermes_state+ from hermes_constants import get_hermes_home+ from hermes_cli.web_server import app, _SESSION_HEADER_NAME, _SESSION_TOKEN++ monkeypatch.setattr(hermes_state, "DEFAULT_DB_PATH", get_hermes_home() / "state.db")+ c = TestClient(app)+ c.headers[_SESSION_HEADER_NAME] = _SESSION_TOKEN+ return c+++def test_install_endpoint_refuses_non_https_sources_and_passes_https(client, monkeypatch):+ from hermes_cli import plugins_cmd+ seen = []+ monkeypatch.setattr(plugins_cmd, "dashboard_install_plugin",+ lambda ident, **k: seen.append(ident) or {"ok": False, "error": "stub"})++ for identifier in ("file:///srv/plugin", "ssh://[email protected]/a/p.git", "[email protected]:a/p.git",+ "http://example.com/a/p.git"):+ resp = client.post("/api/dashboard/agent-plugins/install", json={"identifier": identifier})+ assert resp.status_code == 400 and "https://" in resp.json()["detail"], identifier+ assert seen == []++ client.post("/api/dashboard/agent-plugins/install", json={"identifier": "https://example.com/a/p.git"})+ assert seen == ["https://example.com/a/p.git"]diff --git a/tests/tui_gateway/test_plugins_manage_install_source.py b/tests/tui_gateway/test_plugins_manage_install_source.pynew file mode 100644index 00000000000..b9b34f328f6--- /dev/null+++ b/tests/tui_gateway/test_plugins_manage_install_source.py@@ -0,0 +1,38 @@+"""plugins.manage install (Desktop and Webapp) clones over https:// only; the CLI keeps every scheme."""++import pytest++from tui_gateway import server++REFUSED = ["file:///srv/plugin", "ssh://[email protected]/acme/plugin.git", "[email protected]:acme/plugin.git",+ "http://example.com/acme/plugin.git"]+++def _install(**params):+ return server.handle_request({"id": "1", "method": "plugins.manage", "params": {"action": "install", **params}})++[email protected]("identifier", REFUSED)+def test_non_https_source_is_refused_before_any_clone(identifier, monkeypatch):+ from hermes_cli import plugins_cmd+ monkeypatch.setattr(plugins_cmd, "dashboard_install_plugin", lambda *a, **k: pytest.fail("installer ran"))++ resp = _install(identifier=identifier)++ assert "https://" in resp["error"]["message"]++[email protected]("params", [+ {"identifier": "https://example.com/acme/plugin.git"}, {"identifier": "acme/plugin"},+ # A catalog install clones the catalog's own source, whatever identifier rides along.+ {"identifier": "file:///srv/plugin", "catalog_name": "alpha"},+])+def test_https_shorthand_and_catalog_sources_reach_the_installer(params, monkeypatch):+ from hermes_cli import plugins_cmd+ seen = []+ monkeypatch.setattr(plugins_cmd, "dashboard_install_plugin",+ lambda ident, **k: seen.append(ident) or {"ok": False, "error": "stub"})++ _install(**params)++ assert len(seen) == 1diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.pyindex 2bd46cb1db7..6a42ba986b4 100644--- a/tui_gateway/methods_tools.py+++ b/tui_gateway/methods_tools.py@@ -1767,6 +1767,8 @@ def _plugins_install(rid, params):catalog_name = str(params.get("catalog_name") or "").strip()if not ident and not catalog_name:return _err(rid, 4019, "plugins.install requires 'identifier', 'repo', or 'catalog_name'")+ if refusal := _tools_mod("hermes_cli.plugins_cmd_install").gui_install_source_refusal(ident, catalog_name):+ return _err(rid, 5026, refusal)_ensure_plugin_activation_listener()result = _tools_mod("hermes_cli.plugins_cmd").dashboard_install_plugin(ident, force=bool(params.get("force")), enable=params.get("enable", True), catalog_name=catalog_name or None,diff --git a/website/docs/user-guide/desktop.md b/website/docs/user-guide/desktop.mdindex f1ab2e4e50a..d843f95f044 100644--- a/website/docs/user-guide/desktop.md+++ b/website/docs/user-guide/desktop.md@@ -791,8 +791,11 @@ picker installs reviewed entries at their pinned commit into the selectedprofile, and **Install from Git** takes any other repository through the samereview-then-install dialog; its optional **Pin to commit** field installs oneexact 40-character commit SHA (private repos included), and pinned plugins-carry a `pinned @ <sha8>` badge in the list. Old `Settings → Plugins` links-redirect here.+carry a `pinned @ <sha8>` badge in the list. Desktop and the Webapp install+from `https://` sources (or `owner/repo` shorthand) only, and refuse a desktop+plugin folder that contains a symbolic link; `hermes plugins install` in a+terminal still takes `git@`/`ssh://`, `http://` and `file://` sources. Old+`Settings → Plugins` links redirect here.## Troubleshooting