Files
Nexus/docs/changelog/2026-06-04-code-review-p0-p1-fixes.md
T
2026-07-08 22:31:31 +08:00

44 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-06-04 — Code Review P0/P1 修复批次
## 摘要
依据 Cursor 全量 code review 结论,修复安装窗口、并行推送 DB 会话、源路径校验、Refresh 轮换竞态、定时任务失败判定、Primary 锁降级及前端推送/登录问题。
## 动机
- P0`sync_files` 并行 worker 共用 `AsyncSession` 导致间歇性 DB 错误;`create-admin` 在 Step3~4 之间无鉴权可被抢管。
- P1:推送源路径未统一黑名单;Refresh 非原子轮换;schedule 全失败仍提交 `last_run_at`Redis 不可用时多 worker 重复后台任务;前端 WS 泄漏与开放重定向。
## 涉及文件
| 文件 | 变更 |
|------|------|
| `server/application/services/sync_engine_v2.py` | `_db_lock` 串行化 DB 写;源路径走 `resolve_nexus_push_source_path` |
| `server/utils/posix_paths.py` | 新增 `FORBIDDEN_NEXUS_SOURCE_PREFIXES``resolve_nexus_push_source_path` |
| `server/api/install.py` | Step3 签发 `install_token``create-admin` 校验令牌 |
| `web/app/install.html` | 保存并提交 `install_token` |
| `server/application/services/auth_service.py` | Redis Lua 原子 refresh 轮换 |
| `server/api/sync_v2.py` | validate/verify 复用统一源路径校验 |
| `server/main.py` | Redis 失败时 flock 文件锁 fallback(单 primary |
| `server/background/schedule_runner.py` | 推送零成功时 rollback schedule |
| `frontend/src/pages/LoginPage.vue` | 登录 redirect 防开放重定向 |
| `frontend/src/composables/push/usePushProgress.ts` | 失败时 disconnect WS4001/4401 强制登出 |
| `tests/test_security_unit.py` | install token + 源路径单元测试 |
## 迁移 / 重启
- 需重启 `nexus`Supervisor)使后端生效。
- 前端需 `vite build` 后部署静态资源。
- **安装向导**:Step3 响应新增 `install_token`,Step4 必须携带;进行中的安装需从 Step3 重新执行以获取令牌。
## 验证
```bash
.venv/bin/ruff check server/...
.venv/bin/python -c "import server.main"
.venv/bin/pytest tests/test_security_unit.py -q
cd frontend && npm run type-check
```
进度:`☑实现 ☑WSL验证 □审计8步 □部署 □健康检查 □浏览器验证 ☑changelog`