The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(line): fail closed on a whitespace-only channel secret
kshitijk4poora560ba0b0842
diff --git a/plugins/platforms/line/adapter.py b/plugins/platforms/line/adapter.pyindex cff72c8acf7..a3749a593ec 100644--- a/plugins/platforms/line/adapter.py+++ b/plugins/platforms/line/adapter.py@@ -342,9 +342,10 @@ def _truthy_env(name: str, default: bool = False) -> bool:def _credentials(config) -> Tuple[str, str]:"""Return ``(channel_access_token, channel_secret)`` from scoped secrets, then ``extra``."""extra = getattr(config, "extra", {}) or {}+ # Stripped: a whitespace-only secret must read as unset, not key the HMAC with blanks.return (- _get_scoped_secret("LINE_CHANNEL_ACCESS_TOKEN") or extra.get("channel_access_token", ""),- _get_scoped_secret("LINE_CHANNEL_SECRET") or extra.get("channel_secret", ""))+ str(_get_scoped_secret("LINE_CHANNEL_ACCESS_TOKEN") or extra.get("channel_access_token", "")).strip(),+ str(_get_scoped_secret("LINE_CHANNEL_SECRET") or extra.get("channel_secret", "")).strip())def _coerce(cast: Callable[[Any], Any], value: Any, default: Any) -> Any:diff --git a/tests/gateway/test_line_plugin.py b/tests/gateway/test_line_plugin.pyindex 82a3264d36e..5333daf7d0d 100644--- a/tests/gateway/test_line_plugin.py+++ b/tests/gateway/test_line_plugin.py@@ -415,6 +415,9 @@ class TestAdapterInit:ad = LineAdapter(cfg)assert ad.channel_access_token == "tok"assert ad.channel_secret == "sec"+ # A whitespace-only secret reads as unset, so connect fails closed instead of keying HMAC with blanks.+ assert LineAdapter(PlatformConfig(enabled=True, extra={"channel_access_token": "tok",+ "channel_secret": " "})).channel_secret == ""assert ad.webhook_port == 7777assert ad.public_base_url == "https://x.example.com"assert ad.allowed_users == {"U1", "U2"}