Files
jsowell-charger-web/docs/plan/2026-07-17-todo-center-security-performance-checklist.md
2026-07-17 18:12:53 +08:00

64 lines
2.5 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.
# 待办中心安全与性能验证清单
## 部署前 SQL
按顺序在测试库执行:
1. `docs/sql/sys_todo_task.sql`(仅新环境)或 `docs/sql/sys_todo_performance_index.sql`(已有表)。
2. `docs/sql/sys_todo_menu.sql`
3. `docs/sql/clearing_withdraw_invoice.sql`
4. `docs/sql/sys_todo_maintenance_job.sql`
## 路由安全
- 默认仅允许 `invoiceDetail``financeDetail` 两个业务路由。
- 新业务路由上线前必须追加到 `todo.route-whitelist`,不允许直接信任请求体中的路由名。
- `route_params` 必须是 JSON 对象,只允许 `params``query` 两层结构,最终值只能是字符串、数字、布尔值或空值。
- 用户端详情、已读、完成和取消接口继续使用当前登录用户 ID 作为 SQL 条件。
- 管理端接口使用独立的 `system:todo:admin:*` 权限,普通角色不得授权。
## 索引与执行计划
使用具有代表性的数据量执行:
```sql
EXPLAIN
SELECT todo_id, task_type, title, summary, business_type, business_id,
route_name, route_params, priority, task_status, read_status, create_time
FROM sys_todo_task
WHERE assignee_user_id = 100
AND task_status IN ('PENDING', 'PROCESSING')
AND del_flag = '0'
ORDER BY priority DESC, create_time DESC, todo_id DESC
LIMIT 3;
EXPLAIN
SELECT count(1)
FROM sys_todo_task
WHERE assignee_user_id = 100
AND task_status IN ('PENDING', 'PROCESSING')
AND read_status = '0'
AND del_flag = '0';
```
首页列表应命中 `idx_todo_user_active_sort`,未读数量应命中 `idx_todo_user_status`。如果优化器未选择目标索引,执行 `ANALYZE TABLE sys_todo_task` 后复测。
## HTTP 性能抽样
登录测试账号后分别对以下接口执行不少于 100 次请求,记录 P50、P95 和最大响应时间:
- `GET /system/todo/unreadCount`
- `GET /system/todo/homeList?limit=3`
- `GET /system/todo/list?pageNum=1&pageSize=10&taskStatus=ACTIVE`
验收目标:首页数量和最近待办接口 P95 小于 500ms分页接口无全表扫描、无跨用户数据。
## 回归场景
- 修改 `userId``assigneeUserId` 等请求参数不能查看或更新其他用户待办。
- 非白名单路由创建待办时返回明确业务错误。
- 嵌套对象、数组或非法 JSON 的路由参数被拒绝。
- 普通用户访问 `/system/todo/admin/**` 返回无权限。
- 到期待办释放 `active_idempotent_key`,同业务后续可重新生成待办。
- 终态任务在 180 天内不归档,超过保留期后仅逻辑隐藏,不物理删除。