fix: 5 个安全/正确性问题(第二轮)

1. (High) user_id NOT NULL 导致 add 任务失败
   → ALTER TABLE 加 DEFAULT '', DROP NOT NULL
2. (High) 调度器任务卡住阻塞后续
   → timeout(120s) + kill_on_drop
3. (Medium) 多实例重复执行
   → SELECT ... FOR UPDATE SKIP LOCKED
4. (Medium) SQL 注入(字符串拼接)
   → psql -v 参数化 (:name, :cmd, :interval)
5. (Medium) 非工具对话 usage 未记录
   → consume() 改为 &mut self,消费后再读 usage
This commit is contained in:
2026-06-02 11:03:31 +08:00
parent 5602b08faf
commit 6dd12425d6
5 changed files with 33 additions and 21 deletions
+2 -1
View File
@@ -222,7 +222,8 @@ impl ChatHandle {
chunk
}
pub async fn consume(mut self) -> Result<String, String> {
/// 消费所有流式块,返回完整文本
pub async fn consume(&mut self) -> Result<String, String> {
while let Some(chunk) = self.next_chunk().await {
if let StreamChunk::Error(e) = chunk { return Err(e); }
}