🐛 fix(sdk): bash 与后台进程任务域十一项修复——只读判定 fail-closed、后台超时豁免、存活判定口径 - #438
Conversation
Code Review十一项逐项核对完毕,十项半真实落地、测试为行为钉死型,质量高。唯一阻塞动作是 rebase 解决与 main #443 的 #381 超时语义分叉。 冲突分析(merge-tree 复现:2 文件 7 hunk)
[P1·存在于 main] sed 只读白名单两条绕过(本机 natives 实测复现)
危害路径=default/acceptEdits/plan 对 readonly 自动 allow。已开 issue #453(附 excludedCommands wrapper 绕过 env/command/xargs)。 非阻塞 P3
rebase 后过 gate 即可合。 |
Code Review十一项中十项半落地扎实、测试质量高(#313 用真实 spawn 双端验证身份一致性),但有一个实测复现的 P1 安全绕过 + 与 main 平行实现的语义分叉,需修后再合。 [P1·安全] PowerShell 白名单拒绝集漏圆括号,#300 修复可被绕过
powershell -Command Get-Date (del victim.txt) # 判只读 ✗
Get-ChildItem @(iex calc) # 判只读 ✗(del/iex 是别名,动词黑名单只扫全名,整串扫描也拦不住。)影响与 #300 同类:plan/default 模式免审批任意执行。修法一行:拒绝字符类补 [P2] #381 与 main 已落地实现(PR#443)语义分叉merge-tree 实测冲突:bash.ts(4 处)、process-job-worker.ts(1 处)。关键取舍:
其余核对结论(全部通过)#338 黑名单藏匿(complex 直接拒+文案不再谎称 prefix)/#313 身份口径(OS StartTime 异步探测±1s 容差,win32 双侧真实 spawn 测试)/#368 多字节跨界(StringDecoder 全链路 210KB 无 U+FFFD)/#329 探活顺序(kill(pid,0) 先行)/#330 ask-user 中止/#331 ProcessOutput 软中断/#332 stop 假终态(布尔返回+失败重探)/#376 身份缓存过期逐出/#377 worktree 提前。 P3 残留(不阻断):worker 身份探测永久失败时 alive 兜底的"假活"窄窗;taskkill 异步结果未确认;永不重读的缓存条目留到 clearProcessJobs。 结论修掉圆括号绕过(P1,一行)+ 完成 #381 语义取舍后可合。 |
- #300 非 simple 回退按方言区分:Bash 一律需审批;PowerShell 拒绝集补管道 |、链式/调用 &、别名 %、脚本块 {} 字符,白名单首词不再被复合载荷借道 - #338 沙箱 excludedCommands 命中判定:非 simple 直接 fail-closed 拒绝,$()/反引号/子 shell 内的目标命令不再漏检 - #368 durable 增量读改持 StringDecoder 流式解码并 drain 后 end() 补尾,64KB 块边界的多字节序列不再碎成 U+FFFD - #381 run_in_background 且未显式传 timeout 时不下发超时(spec 省略/direct 不挂 timer),后台 dev server 不再被 120s 默认预算静默击杀 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- #313 worker 身份改用 OS StartTime(PowerShell,异步探测不阻塞命令拉起),与注册表同源口径;比对侧保留 ±1s 容差兼容存量记录 - #329 isPersistedWorkerAlive 先 kill(pid,0) 探活再评估身份,心跳陈旧不再直接判死(休眠恢复误标 interrupted) - #331 ProcessOutput 阻塞等待传入 context.abortSignal,中止即转非阻塞返回(retrieval_status=aborted) - #332 ProcessStop 依赖 stop 成败:失败重探仍活则报错不动状态、不吞终态通知 - #376 身份缓存命中过期即 delete 重探,不再滞留陈旧条目 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- #330 invokeHandler 外包 abort 竞速,软中断即刻取消不再无限期阻塞宿主 handler;catch 区分 interrupted 与 handler 故障两种文案,中断不再谎报为 User declined Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- #377 prepareWorktree 提前到 createProcessJobRecord 之前并从运行路径移除原调用,后台 agent 任务记录自创建即携带 worktree 元数据 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
cde7528 to
aacfd6e
Compare
概述
修复 sdk 全量 review 提出的 11 个 issue(bash 工具 + 后台进程任务域),每个 commit 独立可跑绿。
|&%{}与 \r\n 换行语句分隔符(review 实测两段式绕过形态已封堵并附红绿负例)验证
bun run typecheck六 workspace 全绿Closes #300, closes #338, closes #368, closes #381, closes #313, closes #329, closes #330, closes #331, closes #332, closes #376, closes #377
🤖 Generated with Claude Code