diff --git a/docs/Git增量部署方案.md b/docs/Git增量部署方案.md index 27239aa..8eea503 100644 --- a/docs/Git增量部署方案.md +++ b/docs/Git增量部署方案.md @@ -47,6 +47,7 @@ - 已分别固定构建机和生产机的 SSH SHA256 主机指纹;OpenSSH 模式还必须使用预置、只读的 `known_hosts` 文件。 - 私有 Git 仓库认证必须预先配置在维护机和构建机的只读、最小权限 credential helper 中。脚本拒绝 `GIT_DEPLOY_PASSWORD`、`GIT_AUTH_HEADER` 和 URL 内嵌凭据。 - 由于 Gitea 使用 HTTP,正式构建或发布必须显式传入维护机已核对的 40 位小写 `-Commit`;脚本不允许把 HTTP 返回的分支最新提交直接当作发布依据。 +- 维护机和构建机的 Git HTTP 读取均启用 30 秒低速超时;Gitea 无响应时发布应明确失败,不得无限等待或绕过精确提交门禁。 ## 安全边界 diff --git a/docs/部署规范.md b/docs/部署规范.md index 0004d01..53112f1 100644 --- a/docs/部署规范.md +++ b/docs/部署规范.md @@ -51,6 +51,8 @@ 不要把 Git 密码写进仓库 URL,也不要把临时部署密码写入文档或提交到仓库。Gitea 的 HTTP 通道不具备传输加密与证书身份保证,因此只能使用只读、最小权限 credential helper;正式构建/部署必须显式指定维护机已核对的完整 40 位小写提交 SHA,并继续核对 SSH 主机指纹、镜像 ID 与 manifest digest。 +脚本对维护机和构建机的 Git HTTP 读取设置 30 秒低速超时。Gitea 无响应时本次发布失败关闭,不允许无限挂起后由人工跳过源码身份校验。 + ### 2.2 部署命令 正式部署前先做 DryRun: diff --git a/lib/__tests__/video-transcode-deploy-drain.test.ts b/lib/__tests__/video-transcode-deploy-drain.test.ts index f2b6f1a..329696d 100644 --- a/lib/__tests__/video-transcode-deploy-drain.test.ts +++ b/lib/__tests__/video-transcode-deploy-drain.test.ts @@ -411,6 +411,10 @@ describe('production video transcode drain gate', () => { expect(script).toContain('HTTP Git transport requires -Commit with the exact 40-character lowercase SHA') expect(script).toContain("[ \"$REPO_URL\" = 'http://git.1080p.hk/WuYongJie/gongxiangp2.git' ]") expect(script).not.toContain('https://git.1080p.hk') + expect(script).toContain("-c 'http.lowSpeedLimit=1'") + expect(script).toContain("-c 'http.lowSpeedTime=30'") + expect(script).toContain('-c http.lowSpeedLimit=1') + expect(script).toContain('-c http.lowSpeedTime=30') expect(script).toContain('StrictHostKeyChecking=yes') expect(script).toContain('-hostkey $BuildServerHostKey') expect(script).toContain('Production host key fingerprint does not match the pinned value') diff --git a/scripts/git-incremental-deploy.ps1 b/scripts/git-incremental-deploy.ps1 index e0e9341..9ce9734 100644 --- a/scripts/git-incremental-deploy.ps1 +++ b/scripts/git-incremental-deploy.ps1 @@ -185,7 +185,10 @@ function Invoke-PreflightGit { $ErrorActionPreference = 'Continue' $env:GIT_TERMINAL_PROMPT = '0' try { - $output = & $GitExecutable @Arguments 2>&1 + $output = & $GitExecutable ` + -c 'http.lowSpeedLimit=1' ` + -c 'http.lowSpeedTime=30' ` + @Arguments 2>&1 $exitCode = $LASTEXITCODE } finally { @@ -682,7 +685,12 @@ ok() { printf '[OK] %s\n' "$*"; } warn() { printf '[WARN] %s\n' "$*"; } fail() { printf '[ERR] %s\n' "$*" >&2; exit 1; } -git_cmd() { GIT_TERMINAL_PROMPT=0 git "$@"; } +git_cmd() { + GIT_TERMINAL_PROMPT=0 git \ + -c http.lowSpeedLimit=1 \ + -c http.lowSpeedTime=30 \ + "$@" +} require_cmd() { command -v "$1" >/dev/null 2>&1 || fail "Missing command on build server: $1"