The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(profiles): profile export and --clone-all keep the Webapp's browser credential private
emozilla54e5118a6d7b
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.pyindex 2a8d40da1aa..472a4576a01 100644--- a/hermes_cli/profiles.py+++ b/hermes_cli/profiles.py@@ -40,10 +40,10 @@ _CLONE_CONFIG_FILES = ["config.yaml", ".env", "SOUL.md"]# identity, as important as SOUL.md for continuity._CLONE_SUBDIR_FILES = ["memories/MEMORY.md", "memories/USER.md"]-# Runtime files stripped after --clone-all. A post-copy step rather than an ignore filter-# because they are created dynamically and may be absent at copy time.+# Runtime files stripped after --clone-all, the Webapp's browser credential among them (each gateway+# mints its own). A post-copy step: they are created dynamically and may be absent at copy time._CLONE_ALL_STRIP: list[str] = [- "gateway.pid", "gateway_state.json", "processes.json",+ "gateway.pid", "gateway_state.json", "processes.json", "webapp/session-token",# Bot Desktop runtime identity: pid + create_time of the SOURCE's launcher, its DISPLAY/XAUTHORITY and# lease. Copied verbatim, `screen stop` on the clone would kill the source's X server. Browser user data# stays, but Chromium's process markers must not let the clone attach to the source's live browser.@@ -166,7 +166,7 @@ PROFILE_CREDENTIAL_PATHS = frozenset({"teams_pipeline_store.json", # Graph subscription client_state (webhook shared secret)"mcp-tokens", # MCP OAuth tokens"vault", # vault.key + vault.json.enc- "browser-profile", "browser_auth", "bot-desktop", # browser cookies / logins+ "browser-profile", "browser_auth", "bot-desktop", "webapp", # browser cookies / logins, Webapp sign-in"browser-profiles", "browser_profiles", # live CDP profiles, Browser Use CLI dir (Cookies, Login Data)"pairing", "platforms/pairing", "feishu_comment_pairing.json","whatsapp/session", "platforms/whatsapp/session", "matrix/store", "platforms/matrix/store",diff --git a/tests/hermes_cli/test_profile_export_credentials.py b/tests/hermes_cli/test_profile_export_credentials.pyindex 0cb338a9625..b5697851aa2 100644--- a/tests/hermes_cli/test_profile_export_credentials.py+++ b/tests/hermes_cli/test_profile_export_credentials.py@@ -10,6 +10,7 @@ The live profile on disk must stay untouched."""import tarfile+from pathlib import Pathimport pytest@@ -37,9 +38,10 @@ _EXTRA_STORES = {"browser-profiles/live/Default/Cookies", "browser_profiles/default/Default/Login Data","mcp-tokens/srv.json", "vault/vault.key", "platforms/pairing/approved.json", "slack_tokens.json","webhook_subscriptions.json", ".ssh/id_rsa", ".aws/credentials", ".gnupg/x", ".kube/config", ".envrc",+ "webapp/session-token", # the Webapp browser's credential (gateway.webapp_listener.TOKEN_PATH)}# Single-file stores whose name has no dot; every other dotless store is a token directory.-_DOTLESS_FILES = {"npmrc"}+_DOTLESS_FILES = {"npmrc", "webapp/session-token"}# Dot-named stores that are directories: the OS credential dirs shared with file_safety._DOT_DIRS = set(HOME_CREDENTIAL_DIRS)@@ -284,3 +286,30 @@ class TestExportSecretScrub:assert _LEAKED_KEY not in archivedassert _LEAKED_KEY in outside.read_text()assert link.is_symlink()+++def profile_env(tmp_path, monkeypatch):+ """Point the home folder and HERMES_HOME into tmp_path, as test_profiles.py does."""+ monkeypatch.setattr(Path, "home", lambda: tmp_path)+ default_home = tmp_path / ".hermes"+ default_home.mkdir(exist_ok=True)+ monkeypatch.setenv("HERMES_HOME", str(default_home))+ return tmp_path+++def test_clone_all_does_not_share_the_source_webapp_browser_credential(profile_env):+ """The Webapp's browser credential belongs to one gateway: a clone mints its own on first+ use, so signing one profile's browsers out never leaves them signed in to the other."""+ from gateway.webapp_listener import TOKEN_PATH, browser_session_token+ from hermes_cli.profiles import create_profile++ default_home = profile_env / ".hermes"+ (default_home / "config.yaml").write_text("model: test", encoding="utf-8")+ source_token = browser_session_token(default_home)++ profile_dir = create_profile("coder", clone_all=True, no_alias=True)++ assert not (profile_dir / TOKEN_PATH).exists()+ assert browser_session_token(profile_dir) != source_token+ assert browser_session_token(default_home) == source_token