From 02601f6d338e265ba8fb00c3866c1cdd2c316929 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 12 Sep 2026 12:15:35 +0800 Subject: [PATCH] =?UTF-8?q?test(llm):=20=E9=9D=B6=E6=9C=BA=E8=A1=A5?= =?UTF-8?q?=E8=AE=B0=20x-api-key=20/=20anthropic-version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Anthropic 协议的鉴权头是 x-api-key,而网关当前只覆写 Authorization。 靶机原来不记录 x-api-key,导致「下游那把 sk_ 是否被原样漏给上游」 在回归里是看不见的 —— 实测已确认会漏。先让靶机把它记下来。 --- tests/llm/upstream.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/llm/upstream.py b/tests/llm/upstream.py index 5eb2aae..745eec6 100644 --- a/tests/llm/upstream.py +++ b/tests/llm/upstream.py @@ -26,6 +26,11 @@ class H(BaseHTTPRequestHandler): "path": self.path, "method": self.command, "auth": self.headers.get("Authorization", "-"), + # x-api-key / anthropic-version 必须记:Anthropic 协议的上游只认 + # `x-api-key`,而网关当前只覆写 Authorization。**不记就意味着 + # 「下游那把 sk_ 是否被原样漏给上游」这件事在这里是看不见的**。 + "x_api_key": self.headers.get("x-api-key", "-"), + "anthropic_version": self.headers.get("anthropic-version", "-"), "host": self.headers.get("Host", "-"), "body": body.decode("utf-8", "replace"), }