优化: 对抗评估clamp去冗余+JSON提取正则兜底+update_task注释对齐status收口

This commit is contained in:
2026-06-16 22:20:14 +08:00
parent d242e8c69c
commit 129f0f0156
5 changed files with 48 additions and 15 deletions

View File

@@ -97,8 +97,13 @@ pub async fn update_task(
field: String,
value: String,
) -> Result<bool, String> {
// 字段名注入由 df-storage 白名单兜底;这里补 status / priority 值校验,
// 拦截拼写错误in-progess / "in progress" / 大小写错与越界数值999 / "abc")静默落库。
// status 值校验保留:仅对「非法值」(拼写错 in-progess / "in progress" / 大小写错 / 越界)
// 给出友好早错误(先于 crud.rs 白名单那串冷冰冰的「字段不在白名单」拒)。合法 status 值
// 不可经本 IPC 写入——crud.rs tasks 白名单已收口移除 status(F-03 batch64 b94e74a /
// D-260616-04),所有 status 改动须走 advance_task_atomic 状态机(CAS + can_transition +
// review_rounds 累加,唯一 status 写入路径)。即此 is_valid 校验的「通过」分支永不会触达
// update_field 的 status 写入(白名单会先拒);它只为非法值兜底 UX不承担合法值写入职责。
// priority 值校验同理补在下方:拦截 "abc" / 999 等脏数据静默落库。
if field == "status" && !TaskStatus::is_valid(&value) {
return Err(format!(
"非法 status 值 {:?},合法值: {:?}",