# 2026-06-04 — 安装向导守卫修复 + 审计项收尾 ## 摘要 修复安装向导在 step3 写入 `.env` 后 step4/5 API 被误拦 403 的 P1 逻辑错误;并处理 2a 审计其余 P2 项。 ## 动机 - **F-2a-01**:`_is_installed()` 将「仅有 `.env`」等同于「安装完成」,导致 `create-admin`/`lock` 无法调用。 - **F-2a-03**:`create_admin` 未显式 `is_active=1`,与 lock 前校验不一致。 - **F-2a-02/04/05**:Monaco 预加载失败悬挂、vendor tar 路径、config.json 明文库密。 ## 变更 | 项 | 文件 | 说明 | |----|------|------| | 守卫拆分 | `server/api/install.py` | `_has_env` / `_reject_if_env_exists`(仅 init-db)/ `_reject_if_locked`(step4/5);`installed`=`locked`;`/status` 增 `configured` | | 管理员 | `install.py` | INSERT/UPDATE 显式 `is_active=1` | | config | `install.py` | `config.json` 不再写入 `db_pass` | | Monaco | `web/app/api.js` | `onerror` + 成功时清 `_monacoLoading` | | vendor 脚本 | `scripts/sync_frontend_vendor.py` | tar 解压拒绝 `..` 路径 | | 测试 | `tests/test_security_unit.py` | 守卫回归 3 条 | ## 迁移 / 重启 - 无 DB 迁移;改 API 逻辑,重启 uvicorn 即可。 - 已有 `web/data/config.json` 若含 `db_pass` 可手动删除该字段(非必须)。 ## 验证 ```bash ruff check server/api/install.py pytest tests/test_security_unit.py -q pytest tests/ -q ``` ## 进度 ☑实现 ☑WSL验证 ☐审计8步 ☐部署 ☐健康检查 ☐浏览器验证 ☑changelog