第三十轮: 全面体检发现项全部修 —— 下载白名单/视频归属/会话落盘/i18n 收口/口令下限
老板对上一轮「只查未改」的体检清单回「全部」,逐项修完并直接上生产验证。
P0 产物下载白名单(实测复现的真 bug)
- Agnes 水印版产物走另一个 CDN(maas-watermark-prod-new.cn-wlcb.ufileos.com),
download.allowed_hosts 只有普通版域名 → admin 老产物点「下载」必 400。
- 补域名;yaml + README 写明这张表是出网白名单、换 CDN 要同步维护。
- 生产实测:水印图下载 200 / 129871 bytes(改前 400);非白名单域名仍 400。
视频任务归属(新增 app/video_owners.py)
- GET /v1/videos/{id} 原先不判归属,任何登录账号拿到 id 就能读别人任务状态与产物 URL。
- 创建成功时登记 video_id→账号,轮询判权:他人 404(不用 403,避免 id 变存在性探针)、
admin 放行、无登记的老任务放行(渐进收紧)。落盘 data/video_owners.json(600/TTL 7 天)。
登录会话落盘(app/sessions.py)
- 原先纯内存 → 每次重启全体被踢;现在 data/sessions.json:只存 token 的 sha256、
原子写 + 600、写失败只告警、载入丢过期。吊销语义不变且吊销也落盘。
- 生产实测:登录拿 token → 重启 → 同一 token 仍 200;文件里不含明文 token。
口令下限 4→8(app/users.py)
- 只作用于「显式给密码/事后改密」;登录不判长度,既有短口令账号照常登。
/config/env 值校验
- 拒绝 \n / \r / \x00 与 >4096(带换行的值能在 .env 里凭空多出几行改掉别的变量)。
- 生产实测 400 且 md5(data/.env) 未变。
其它后端/一致性
- history 四个端点补 _offload(整份读写 ≤4MB,此前是唯一还在事件循环里同步跑的 IO)。
- /health/{provider} 注释更正:一直是 require_auth(恒定鉴权、不随 health_auth 放宽)。
- GET / 导航的 docs 一行改为仅在 docs_enabled 时列出;FastAPI 描述补 OpenCode Go。
- _req_headers 陈旧注释、_media_headers 与测速探针的「有意随机 session」注明。
- app/settings.py 备份写完显式 chmod 600(copy2 会照抄源的 644)。
前端 i18n 收口
- Videos 素材摘要 / lib/upload.ts 全部报错 / charts.ts 空态 → i18n(中英 737/737)。
- 删除 router.ts 中无人消费的 meta.title(只有中文的死元数据)。
- check-i18n.mjs 新增「硬编码中文」扫描(剥注释后扫字符串字面量,允许清单只放语言自称)。
文档 / 基建
- README:.env 补 OPENCODE_API_KEY、两层 .env 的 override 关系、auth.users 死引用、
「自动路由」措辞、下载白名单维护、密码 8 位、测试计数 165→179。
- .env.example 重写(删 B_AI_API_KEY、补 OPENCODE 与全部可覆盖路径)。
- Makefile:lint 改 compileall(原手写清单漏了 6 个模块);test 注释改实话(环境无 pytest)。
- .gitignore 补 6 项;data/gateway.yaml*.bak 三个文件 git rm --cached(本地保留)。
- 新增 scripts/ci_check.sh:一条命令跑完 compileall + 单测 + i18n/SVG 体检 + vue-tsc + build。
- flake8 --select=F,E9 清到 0。
测试
- 179 passed / 0 failed(173→179)。新增会话落盘/过期丢弃、视频归属语义 + 端点级 404、
env 值校验 + 沙箱写、口令下限。
- 修隐患:新增 GATEWAY_ENV_FILE 覆盖 —— 此前测试若覆盖写路径会直接改生产 data/.env。
CSP 结论
- 实测(A/B):去掉 'unsafe-eval' 后登录页 #app 全空、表单不渲染;根因是 vue-i18n 运行时
消息编译器(打包产物里唯一一处 new Function)。正解是构建期预编译文案,不是放宽 CSP。
This commit is contained in:
1 parent
55eb89ce0e
commit
0bf607e35f
24 files changed
+887
-535
No files matched your search
@@ -327,6 +327,12 @@ export default {
|
||||
placeholderRef: 'Describe the video and camera move (use <Picture 1> / <Audio 1> for reference materials)',
|
||||
needFrame: 'Keyframe mode needs at least one uploaded image or image URL',
|
||||
needRef: 'Reference mode needs at least one image or audio (upload or URL)',
|
||||
// Round 30: the material summary on the card (was hardcoded Chinese in mediaSummary())
|
||||
mediaFirst: 'first',
|
||||
mediaLast: 'last',
|
||||
mediaImg: 'img',
|
||||
mediaAud: 'audio',
|
||||
mediaUrl: 'URL',
|
||||
duration: 'Duration (s)',
|
||||
aspect: 'Aspect',
|
||||
quality: 'Quality',
|
||||
@@ -472,7 +478,7 @@ export default {
|
||||
userEnabledOk: 'Account {name} enabled — old password and API keys work again',
|
||||
namesRule: 'Username must be alphanumeric; default password = username',
|
||||
changePw: 'Change password',
|
||||
newPw: 'New password (min 4 chars)',
|
||||
newPw: 'New password (min 8 chars)',
|
||||
pwTip: 'You are signed in — just set a new password, no current password needed. All sessions are revoked and you will sign in again with the new one.',
|
||||
pwNeedNew: 'Please enter a new password',
|
||||
pwChanged: 'Password updated — please sign in again',
|
||||
@@ -486,7 +492,7 @@ export default {
|
||||
noKey: 'You have no API Key — create one to use as a Bearer credential externally',
|
||||
userMgmt: 'Account management (admin)',
|
||||
newUserName: 'New username (alphanumeric)',
|
||||
newUserTip: 'Create account; default password = username',
|
||||
newUserTip: 'Create account; default password = username (custom password ≥ 8 chars)',
|
||||
createUser: 'Create account',
|
||||
keyCount: 'Keys',
|
||||
resetPw: 'Reset password',
|
||||
@@ -774,4 +780,24 @@ export default {
|
||||
f_max_bytes: 'Max file size (bytes)',
|
||||
h_max_bytes: 'Default 67108864 = 64MB',
|
||||
},
|
||||
|
||||
// Round 30: user-visible errors from the frontend upload/compression helpers
|
||||
// (they used to be hardcoded Chinese, so English toasts still showed Chinese)
|
||||
upload: {
|
||||
presetChat: 'chat image',
|
||||
presetRef: 'reference image',
|
||||
presetFrame: 'first/last frame',
|
||||
presetVideoRef: 'video reference image',
|
||||
presetAudio: 'reference audio',
|
||||
presetFeedback: 'feedback image',
|
||||
errRead: 'Failed to read the file',
|
||||
errDecode: 'Could not decode the image (unsupported format?)',
|
||||
errNoCanvas: 'This browser has no Canvas 2D support, so the image cannot be compressed',
|
||||
errNotImage: '{name} is not an image file',
|
||||
errTooBigAfterCompress: '{name} is still {size} after compression, over the {label} per-item limit of {max}',
|
||||
errNotAudio: '{name} is not an audio file (supported: {ext})',
|
||||
errAudioTooBig: '{name} is {size}, over the reference-audio limit of {max} (please trim or compress it)',
|
||||
errBodyBudget: 'This request body is about {size}, over the gateway upload limit (~{max}).',
|
||||
errBodyBudgetTip: 'Please use fewer materials, or smaller images/audio files.',
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user