修复 BgFilter 内部 Token 单段校验

统一校验 BgFilter 内部 Token 并限制启动角色

部署与 provision 预检拒绝内部空白和多行 Token

补充定向测试、运维门禁与架构文档
This commit is contained in:
2026-07-22 14:15:13 +00:00
parent f5db8f4c1e
commit 835fe20c63
7 changed files with 181 additions and 29 deletions
+18 -2
View File
@@ -654,6 +654,22 @@ validate_no_bgfilter_internal_token_plaintext() {
done
}
bgfilter_internal_token_file_is_single_segment() {
local token_file="$1"
run_privileged awk '
/[^[:space:]]/ {
non_empty_lines += 1
if ($0 !~ /^[[:space:]]*[^[:space:]]+[[:space:]]*$/) {
invalid = 1
}
}
END {
exit !(non_empty_lines == 1 && invalid == 0)
}
' "${token_file}"
}
validate_bgfilter_internal_token_file() {
local api_env_file="$1"
local token_file token_metadata
@@ -667,8 +683,8 @@ validate_bgfilter_internal_token_file() {
echo "[production-api-deploy] BgFilter 内部 Token 必须是非空普通文件且不能是符号链接: ${token_file}" >&2
return 1
fi
if ! run_privileged grep -q '[^[:space:]]' -- "${token_file}"; then
echo "[production-api-deploy] BgFilter 内部 Token 文件必须至少包含一个非空白字符: ${token_file}" >&2
if ! bgfilter_internal_token_file_is_single_segment "${token_file}"; then
echo "[production-api-deploy] BgFilter 内部 Token 文件必须为不含空白字符的单段值: ${token_file}" >&2
return 1
fi