fix: bound HTTP Gitea release fetches

This commit is contained in:
chenpei 2026-08-12 18:55:38 +08:00
parent 7c5f42ca40
commit 020006ceb7
4 changed files with 17 additions and 2 deletions

View File

@ -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 无响应时发布应明确失败,不得无限等待或绕过精确提交门禁。
## 安全边界

View File

@ -51,6 +51,8 @@
不要把 Git 密码写进仓库 URL,也不要把临时部署密码写入文档或提交到仓库。Gitea 的 HTTP 通道不具备传输加密与证书身份保证,因此只能使用只读、最小权限 credential helper;正式构建/部署必须显式指定维护机已核对的完整 40 位小写提交 SHA,并继续核对 SSH 主机指纹、镜像 ID 与 manifest digest。
脚本对维护机和构建机的 Git HTTP 读取设置 30 秒低速超时。Gitea 无响应时本次发布失败关闭,不允许无限挂起后由人工跳过源码身份校验。
### 2.2 部署命令
正式部署前先做 DryRun:

View File

@ -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')

View File

@ -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"