From 89468bba4c1109100ae759b4b6617750347fb301 Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 5 Oct 2026 13:37:12 +0000 Subject: [PATCH] Allow the platform-injected internal http server URL in CI checkout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: 运行器注入 GITHUB_SERVER_URL='http://172.17.0.1:3000'(docker 网关直连宿主 Gitea, run 950 诊断实测);https 限定与硬编码常量比对都会拒绝合法检出,GATE 无法变绿。 Evidence: 校验收宽为 http(s)+netloc;凭据仍仅附着于注入基址+仓库白名单 URL,固定 SHA/ 路径/递归深度 fail-closed 语义不变。 Impact: 仅 ci.yaml checkout 一处。 --- .gitea/workflows/ci.yaml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index d2e18f02..1de4a457 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -27,16 +27,15 @@ jobs: import sys from urllib.parse import urlsplit - # 服务端基址取运行器注入的 GITHUB_SERVER_URL(平台控制、候选 PR 不可影响), - # 只做 https 形态校验;凭据仅附着于「该基址 + 下方仓库白名单」构造的 URL。 - # 2026-10-05 修复:此前与硬编码常量严格相等比对,运行器注入值与公网拼写 - # 不一致时合法检出也被拒绝(PR #213 run 948 实测),仓库白名单不变。 - print("diag GITHUB_SERVER_URL:", repr(os.environ.get("GITHUB_SERVER_URL")), - "GITHUB_API_URL:", repr(os.environ.get("GITHUB_API_URL")), - "GITHUB_REPOSITORY:", repr(os.environ.get("GITHUB_REPOSITORY"))) + # 服务端基址取运行器注入的 GITHUB_SERVER_URL(平台控制、候选 PR 不可影响)。 + # 2026-10-05 修复(run 948/949 实测):注入值为内网直连形态 + # 'http://172.17.0.1:3000'(docker 网关 → 宿主 Gitea),与公网拼写不同且为 + # http——此前硬编码常量严格比对会拒绝合法检出。校验收宽为「http(s) + 非空 + # netloc」;凭据仍只附着于「该基址 + 下方仓库白名单」构造的 URL。 SERVER = os.environ.get("GITHUB_SERVER_URL", "").rstrip("/") - if urlsplit(SERVER).scheme != "https" or not urlsplit(SERVER).netloc: - sys.exit("Checkout server must be the platform-injected https URL") + parsed_server = urlsplit(SERVER) + if parsed_server.scheme not in {"http", "https"} or not parsed_server.netloc: + sys.exit("Checkout server must be the platform-injected http(s) URL") SSH = "ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/" # Reviewed allowlist, independent of candidate .gitmodules. Add repositories # here only with an explicit review of the checkout credential's scope.