Files
dsh-web/web
m1saka 66abb76318 Fix audit findings: lock architecture, security, deployment hardening
Close all 14 findings from the codebase audit (1 high, 5 medium, 8 low):

- Locking: replace the global API and workspace mutexes with per-instance
  and per-user keyed locks (new internal/api/locks.go) so a slow restore,
  upgrade or transfer no longer blocks unrelated users or instances; move
  Docker I/O out of the build queue and invalidate concurrent image-index
  observations with a generation counter; serialize instance deletion
  behind in-flight creation.
- Security: equalize login timing for unknown usernames, periodically
  purge expired sessions/refresh tokens/lock rows, URL-encode orphan IDs
  in the frontend, upgrade vitest 3.x->5.x to clear 3 npm audit
  vulnerabilities (2 critical RCE).
- Deployment: add a -healthcheck mode probing /healthz (used by Dockerfile
  HEALTHCHECK and compose), make ADMIN_PASSWORD optional in compose with
  removal guidance after first start, exclude test scripts from the image,
  and cap panel resources (cpus: 2, pids_limit: 512).
- Reliability: check rows.Err() on admin listing loops, surface intent
  polling errors without sticking, disable close during in-flight create.

Verified: go build/vet, full go test -race -count=1 ./..., frontend
tsc build + 32 tests, npm audit 0, compose config, real-container
healthcheck.
2026-10-13 20:59:28 +08:00
..
2026-10-13 09:34:47 +08:00
2026-10-13 09:34:47 +08:00
2026-10-13 09:34:47 +08:00
2026-10-13 09:34:47 +08:00
2026-10-13 09:34:47 +08:00
2026-10-13 09:34:47 +08:00
2026-10-13 09:34:47 +08:00

DSH 中文工作台

React 19 + TypeScript + Vite;普通 CSS 响应式布局,没有运行时演示数据。

开发与验证

使用 Node.js 22+:

npm ci
npm run dev
npm test
npm run build

开发服务只监听 127.0.0.1:5173,/api 和 /dsh 代理至 127.0.0.1:8088。生产产物为 dist/,由后端同源提供;不能直接通过 file:// 使用。

API 与安全

  • 根目录 API.md 是接口契约;API 客户端集中在 src/api.ts,可注入 fetch 进行独立单元测试。
  • HttpOnly Cookie 登录;CSRF token 仅留在内存,刷新通过 /api/me 重新获取。密码、token 不写入 localStorage。
  • 操作失败保留错误,不模拟成功;删除、重启、构建等操作二次确认。
  • 备份恢复和升级等待后端契约,当前明确显示不可用说明,不发送猜测接口。
  • 单元测试里的 fetch 替身仅用于测试,不打包进生产页面。

当前后端仍在实现部分端点,页面会真实显示其 HTTP 错误。请不要把前端入口存在等同于后端能力已交付。