第三十轮: 全面体检发现项全部修 —— 下载白名单/视频归属/会话落盘/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
3e56e7dec3
commit
13789da6d1
24 files changed
+887
-535
No files matched your search
+16
-13
@@ -4,6 +4,9 @@ import { GATEWAY_CONFIG_ENABLED } from './lib/features'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
// 第三十轮: 这里的 meta.title 已删除 —— 它是**没人读的死元数据**(全仓没有任何
|
||||
// ``document.title``/``route.meta.title`` 消费点),而且只有中文:切英文后一旦有人
|
||||
// 开始用它,界面就会冒出中文。菜单标题的唯一来源是 lib/nav.ts(键)+ i18n 文案。
|
||||
routes: [
|
||||
{ path: '/login', name: 'login', component: () => import('./views/Login.vue'), meta: { public: true } },
|
||||
{
|
||||
@@ -11,19 +14,19 @@ const router = createRouter({
|
||||
component: () => import('./layouts/MainLayout.vue'),
|
||||
children: [
|
||||
{ path: '', redirect: '/dashboard' },
|
||||
{ path: 'dashboard', name: 'dashboard', component: () => import('./views/Dashboard.vue'), meta: { title: '仪表盘' } },
|
||||
{ path: 'chat', name: 'chat', component: () => import('./views/Chat.vue'), meta: { title: '对话' } },
|
||||
{ path: 'images', name: 'images', component: () => import('./views/Images.vue'), meta: { title: '图像' } },
|
||||
{ path: 'videos', name: 'videos', component: () => import('./views/Videos.vue'), meta: { title: '视频' } },
|
||||
{ path: 'models', name: 'models', component: () => import('./views/Models.vue'), meta: { title: '模型与供应商' } },
|
||||
{ path: 'metrics', name: 'metrics', component: () => import('./views/Metrics.vue'), meta: { title: '指标' } },
|
||||
{ path: 'keys', name: 'keys', component: () => import('./views/ApiKeys.vue'), meta: { title: 'API 密钥' } },
|
||||
{ path: 'users', name: 'users', component: () => import('./views/Users.vue'), meta: { title: '用户管理', admin: true } },
|
||||
{ path: 'feedback-inbox', name: 'feedbackinbox', component: () => import('./views/FeedbackInbox.vue'), meta: { title: '用户反馈', admin: true } },
|
||||
{ path: 'feedback', name: 'feedback', component: () => import('./views/Feedback.vue'), meta: { title: '意见反馈', memberOnly: true } },
|
||||
{ path: 'gateway-config', name: 'gatewaycfg', component: () => import('./views/GatewayConfig.vue'), meta: { title: '网关配置', admin: true } },
|
||||
{ path: 'logs', name: 'logs', component: () => import('./views/Logs.vue'), meta: { title: '日志' } },
|
||||
{ path: 'settings', name: 'settings', component: () => import('./views/Settings.vue'), meta: { title: '设置' } },
|
||||
{ path: 'dashboard', name: 'dashboard', component: () => import('./views/Dashboard.vue') },
|
||||
{ path: 'chat', name: 'chat', component: () => import('./views/Chat.vue') },
|
||||
{ path: 'images', name: 'images', component: () => import('./views/Images.vue') },
|
||||
{ path: 'videos', name: 'videos', component: () => import('./views/Videos.vue') },
|
||||
{ path: 'models', name: 'models', component: () => import('./views/Models.vue') },
|
||||
{ path: 'metrics', name: 'metrics', component: () => import('./views/Metrics.vue') },
|
||||
{ path: 'keys', name: 'keys', component: () => import('./views/ApiKeys.vue') },
|
||||
{ path: 'users', name: 'users', component: () => import('./views/Users.vue'), meta: { admin: true } },
|
||||
{ path: 'feedback-inbox', name: 'feedbackinbox', component: () => import('./views/FeedbackInbox.vue'), meta: { admin: true } },
|
||||
{ path: 'feedback', name: 'feedback', component: () => import('./views/Feedback.vue'), meta: { memberOnly: true } },
|
||||
{ path: 'gateway-config', name: 'gatewaycfg', component: () => import('./views/GatewayConfig.vue'), meta: { admin: true } },
|
||||
{ path: 'logs', name: 'logs', component: () => import('./views/Logs.vue') },
|
||||
{ path: 'settings', name: 'settings', component: () => import('./views/Settings.vue') },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user