The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(security): corrupt-token and docker_env warnings never echo the value
kshitijk4poorc95743268501
diff --git a/tests/tools/test_docker_environment.py b/tests/tools/test_docker_environment.pyindex aeaa0811d3b..b92f2dcda10 100644--- a/tests/tools/test_docker_environment.py+++ b/tests/tools/test_docker_environment.py@@ -1778,3 +1778,12 @@ def test_docker_run_secret_values_never_in_argv(monkeypatch):assert "MY_TOKEN" in argsassert all(secret not in str(a) for a in args)assert (kwargs.get("env") or {}).get("MY_TOKEN") == secret+++def test_docker_env_warnings_never_echo_values(caplog):+ """Values in docker_env can be secrets; a rejected entry is logged by key and type only (#102308)."""+ import logging++ with caplog.at_level(logging.WARNING, logger="tools.environments.docker"):+ docker_env._normalize_env_dict({"TOKEN": ["sk-live-value"], "OK": "1"})+ assert "TOKEN" in caplog.text and "sk-live-value" not in caplog.textdiff --git a/tests/tools/test_mcp_oauth.py b/tests/tools/test_mcp_oauth.pyindex bfb0cc5ebe0..b26c2ebfb9f 100644--- a/tests/tools/test_mcp_oauth.py+++ b/tests/tools/test_mcp_oauth.py@@ -171,6 +171,26 @@ class TestHermesTokenStorage:import asyncioassert asyncio.run(storage.get_tokens()) is None+ def test_corrupt_tokens_warning_never_echoes_the_token_material(self, tmp_path, monkeypatch, caplog):+ """A pydantic ValidationError's str() includes the raw input; the corrupt-store warning must+ name the failing fields only (#102308)."""+ import asyncio+ import logging++ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ storage = HermesTokenStorage("bad-server")+ d = tmp_path / "mcp-tokens"+ d.mkdir(parents=True)+ secret = "sk-live-QQQQQQQQ" # short enough that pydantic's input echo does not elide it+ # access_token must be a str: a one-element list fails validation on THAT field, and pydantic's+ # message echoes the failing field's input — i.e. the token.+ (d / "bad-server.json").write_text(json.dumps({"access_token": [secret], "token_type": "Bearer"}))++ with caplog.at_level(logging.WARNING, logger="tools.mcp_oauth"):+ assert asyncio.run(storage.get_tokens()) is None+ assert any("Corrupt" in r.message for r in caplog.records)+ assert secret not in caplog.text+# ---------------------------------------------------------------------------# build_oauth_auth