The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(providers): delegate is_official_openai_host to base_url_host_matches
Victor Kyriazakos008f1efe087f
diff --git a/hermes_cli/providers.py b/hermes_cli/providers.pyindex 57483e99820..241b51d700f 100644--- a/hermes_cli/providers.py+++ b/hermes_cli/providers.py@@ -592,9 +592,11 @@ def is_official_openai_host(base_url: str) -> bool:(``proxy.test/api.openai.com/v1``) are rejected. A genuine``*.api.openai.com`` subdomain requires control of openai.com DNS, sothe dot-suffix match does not reopen the #32243 spoofing hole.+ Delegates to ``utils.base_url_host_matches``, which owns the+ exact-or-dot-suffix hostname contract (userinfo/port stripped,+ lowercased, trailing dot removed) — one implementation, not two."""- hostname = base_url_hostname(base_url)- return hostname == "api.openai.com" or hostname.endswith(".api.openai.com")+ return base_url_host_matches(base_url, "api.openai.com")def host_mandated_api_mode(base_url: str = "") -> Optional[str]:diff --git a/tests/hermes_cli/test_official_openai_host.py b/tests/hermes_cli/test_official_openai_host.pyindex da0c92b556e..8d91adfe5f2 100644--- a/tests/hermes_cli/test_official_openai_host.py+++ b/tests/hermes_cli/test_official_openai_host.py@@ -26,6 +26,9 @@ class TestOfficialHosts:"https://eu.api.openai.com/v1","https://US.api.OpenAI.com/v1", # case-insensitive hostname"https://in.api.openai.com/v1", # future regional variants+ "https://api.openai.com:443/v1", # port stripped by hostname parse+ "https://api.openai.com./v1", # trailing dot normalized+ "https://[email protected]/v1", # userinfo stripped; real host wins],)def test_official_hosts_match(self, url):@@ -50,6 +53,8 @@ class TestSpoofRejection:# Unrelated hosts."https://openrouter.ai/api/v1","https://api.anthropic.com/v1",+ # IPv6 literal and empty input.+ "https://[::1]:8080/v1","",],)