From c07673ba97cc1557be0709b5a19a6cfdea05a210 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Apr 2026 00:27:26 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20generateCosAuth=E6=B7=BB=E5=8A=A0host?= =?UTF-8?q?=E5=BF=85=E5=A1=AB=E6=A0=A1=E9=AA=8C=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E7=A9=BAhost=E5=AF=BC=E8=87=B4=E7=AD=BE=E5=90=8D=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/dc4da37f-9c43-4bcb-8d12-24e3310ecc9c Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- scripts/cos-auto-join-agent.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/cos-auto-join-agent.js b/scripts/cos-auto-join-agent.js index a3250849..b4c2d7d5 100644 --- a/scripts/cos-auto-join-agent.js +++ b/scripts/cos-auto-join-agent.js @@ -47,6 +47,9 @@ function hmacSha1(key, str) { } function generateCosAuth(secretId, secretKey, method, pathname, host) { + if (!host) { + throw new Error('COS签名需要host参数'); + } const now = Math.floor(Date.now() / 1000); const exp = now + 600; // 10分钟有效 const keyTime = `${now};${exp}`; @@ -56,7 +59,7 @@ function generateCosAuth(secretId, secretKey, method, pathname, host) { const qIdx = pathname.indexOf('?'); const signPath = qIdx >= 0 ? pathname.substring(0, qIdx) : pathname; - const httpString = `${method.toLowerCase()}\n${signPath}\n\nhost=${host || ''}\n`; + const httpString = `${method.toLowerCase()}\n${signPath}\n\nhost=${host}\n`; const sha1edHttpString = crypto.createHash('sha1').update(httpString).digest('hex'); const stringToSign = `sha1\n${keyTime}\n${sha1edHttpString}\n`; const signature = hmacSha1(signKey, stringToSign).toString('hex');