Repository navigation
fix(send): 收紧参数预检,阻止位置参数静默吞正文 - #2774
Merged
Merged
Conversation
added 2 commits
November 3, 2026 22:36
在 Riff/sandbox 分流和任何会话/relay/marker 变更之前统一解析 send argv:裸 - 作为 stdin,附件 flag 后多写的真实文件路径直接报错,未知 flag、任意 occurrence 缺值、exact -- 和手写 riff-upload 占位符一律提前拒绝。Riff host 只做 placeholder 结构与 uploads 双射校验,不做 stat 或位置文件启发式。 补充真实 send/dry-run/Riff 通道的回归测试,并让 fixture 可按需记录全部 HTTP 以便断言解析失败零 transport。
BanboLee
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
November 4, 2026 07:13
交叉复审发现:preflightSendInvocation 的空正文判定只放行了 --diff, 但 --as independent|suggestion 的正文本来就由 cmdSend 后续合成 (crossPrincipalAsKeyword),skill 也明确写了可单独 `botmux send --as independent` 不带正文。收紧预检后这条用法被误杀为 exit 2「正文为空」。 - --as 与 --diff 并列作为「正文由后续阶段合成」的来源,空 stdin 放行 - 非法 --as 值在空正文判定之前报 as_usage,参数错误不被「正文为空」覆盖 - 补端到端回归:空 stdin 的 --as independent/suggestion 实发并断言合成 token;非法值断言 as_usage 且零 CAPTURE - 补预检顺序取舍注释与「virtual 会话 + 非空 stdin 仍被 transport 闸拒绝」 的构建版行为测试 - RIFF_UPLOAD_PREFIX 交给 client 占位符拼装处使用,不再是无引用导出 - docs/riff.md:send 的 --content-file - 已在客户端预检拒绝,heredoc/ 管道裸 stdin 替代;card stream write 仍保留 Co-Authored-By: Claude Code <[email protected]>
Owner
|
交叉复审后追加了一个修复提交 修了什么复审发现一个 P2:新的 send 预检把
顺带处理了复审的几个非阻断项:
测试
这是自动评审流程追加的修复,最终以维护者审阅为准。 |
第二轮交叉复审的两个非阻断小修: - --as 值是纯 argv 推导(与 --image-mode/--response-kind 同类),把校验 从 readStdin() 之后挪到之前:非法 --as 配永不 EOF 的非 TTY stdin 时 直接报 as_usage(exit 2),不再无意义地阻塞在 stdin 读取上。合法 --as 空 stdin 的放行不变。补一条「stdin 为持开 socket、--as bogus 必须自行 exit 2」的子进程测试;把校验挪回 readStdin 之后该用例会 挂到超时(变异已验)。 - docs/riff.md:Riff 工具通道里裸 `-` 位置参数会被判为未知 flag (riff_host_flag_unsupported:-),只有 heredoc/管道走 stdin 字段可用; 裸 `-` 作 stdin 同义只在普通本地 CLI 成立,文档据此更正。 Co-Authored-By: Claude Code <[email protected]>
同步主干以解决 src/cli.ts 与 deepcoldy#2770 beginFeedbackEffect 的签名/调用点 机械冲突:cmdSend(rest, beginFeedbackEffect?, preflight?),send 调用点 同时传 lease 回调与 sendPreflight,两条路径时序各自保持原样。 tree c4aa98b,已经双审背书。
同步到 e013b27;src/cli.ts 与 deepcoldy#2770/deepcoldy#2772 的 send/workflow 改动非相邻, git 自动合并。落地树 c47ef79 已双审背书。
同步 deepcoldy#2784(并发上限可配置);与本 PR send/riff 零交集,git 自动合并。 落地树 5518442 已双审背书。
Owner
|
已合并,感谢 @BanboLee 的贡献 🎉 这个 PR 把 交叉评审中一起打磨的点(均已包含在合并提交中):
没有阻断性遗留项。欢迎继续贡献! |
|
🚀 Released in v3.57.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
基线:
0502c3c03(origin/master)改了什么
botmux send的正文/附件解析长期存在一类静默错误:多余位置参数会被当成正文,且位置正文优先于 stdin/heredoc;--files/--images每次只吃 1 个值;-不是 stdin 别名,会原样变成正文-(Markdown 渲染成一个点)。本次把解析收敛到最早入口的共享 preflight,并补上确定性校验:src/cli/send-invocation.ts:角色无关 parse + client/host 两个 validator + 完整 arity。src/cli.ts:在 Riff/sandbox 分流、session 解析、marker/ledger 变更和任何 transport 之前 preflight;cmdSend/sendDryRun/relaySend消费同一份 plan;stdin 在 preflight 读取并缓存,避免拒绝正文前先推进 queued turn。-仅作为唯一位置参数时读 stdin;空白 stdin 直接 exit 2。--files/--images:额外 token 全部 stat 为真实普通文件,或判为 path-like(无空白/CJK/URL,且命中显式前缀/ ./ ../ ~/、盘符、单/双前导反斜杠,或以常见附件扩展名结尾)。显式前缀但带空白/CJK 的 token,仅在同时以常见扩展名结尾时按路径处理。附件-only 发送仍允许空正文。--、client 手写riff-upload:占位符都在最早入口拒绝。image-mode/response-kind的非法值在 stdin 读取前校验,参数错误不被“正文为空”覆盖。ClientSendPlan,Riff client 从同一份缓存stdinContent重建 plan(防御性重校验,stdin 不二读);Riff host 只做 placeholder 结构 + uploads 双射,不 stat、不做位置文件启发式;host strict 不 trim。src/services/riff-upload-placeholder.ts:^riff-upload:(0|[1-9]\d*)$单一来源。为什么
线上出现三类用户可见事故:文件只发 path、只发一个点、只发一张图没有正文。根因都是参数解析把真实正文替换成了另一个路径/
-,且不报错。本次把确定性类别改成响亮失败,避免 bot 在不知情时继续错发。影响面
真实 send、
--dry-run、sandbox relay、Riff client/host、remote-runner 合成 argv、scheduled turn、plugin card 均接入同一 preflight。CLI 行为变化;无 DB/持久状态迁移。不包含(后续 PR):
--分隔符完整支持、--attention/--urgent空格形式报错、docs/i18n/dry-run 文案补齐。验证
在独立 checkout(
/tmp/botmux-verify,deps 完整;未使用 canonicalnode_modules)执行:bunx tsc -p tsconfig.json --noEmit:exit 0bun run build:通过(typecheck:scripts / test-mocks / dashboard bundle / asset audits)388 tests passedbunx vitest run --project unit test/send-invocation.test.ts test/cli-send-dry-run.test.ts test/riff-send-preflight.test.ts test/send-preflight-transport.test.ts test/send-preflight-marker.test.ts test/send-policy.test.ts test/cli-send-dispatch.test.ts test/cli-send-image-mode.test.ts test/cli-send-diff.test.ts test/cli-send-custom-final.test.ts test/cli-send-reply-card.test.ts test/riff-host-tools.test.ts test/remote-runner-outbound-send.test.ts test/cli-send-link-ref.test.ts test/cli-root-help.test.ts24 tests passedbunx vitest run --project unit test/cli-send-deferred-topic-isolated.test.ts test/sandbox-send-route.test.ts test/send-attachment-message-ids-wiring.test.ts test/cli-send-topic-policy.test.ts六条路径的覆盖:
cmdSendtest/cli-send-reply-card.test.ts+test/send-preflight-transport.test.ts(fixture fake HTTP,断言解析失败零 transport/零状态变化)--dry-runtest/cli-send-dry-run.test.ts(lone-、多附件、exact--、参数错误优先于空正文)test/cli-send-deferred-topic-isolated.test.ts、test/cli-send-topic-policy.test.tstest/riff-send-preflight.test.ts(上传/rewrite 前拒绝;缓存 stdin 只读一次)test/riff-host-tools.test.ts(placeholder 严格匹配、uploads 双射、不 stat、不写入 upload 临时目录)test/sandbox-send-route.test.ts、test/send-attachment-message-ids-wiring.test.tstest/remote-runner-outbound-send.test.ts新增副作用回归:
test/send-preflight-transport.test.ts表驱动覆盖 blank lone-与 blank 隐式 stdin,同时断言 marker 字节不变、ledger 文件名/字节不变、CAPTURE_HTTP为空、sandbox relay 目录无.req.json。test/send-preflight-marker.test.ts另外单独锁 marker。Riff 侧新增计数测试:传入缓存stdinContent时底层readStdin调用 0 次,无缓存时调用 1 次。全量 unit suite 实况:
2195 passed / 35 failed files / 103 failed tests,失败集中在 workspace-recycle / traex 的临时路径期望;本 PR 不修改这些模块,CI 会再跑。60867ad复验:9 个 send/riff/relay 文件 146 passed / 0 failed;tsc --noEmit0 错;bun run build通过;real CLI dry-run 矩阵 11 放行 / 7 拒绝;三条变异各自咬红。错误优先级:body/arity preflight 先于 transport/sandbox gate 报错(有意行为;gate 仍然是最终的发送拒绝者)。
已知边界
missing)仍按正文;含空格/CJK 且无常见扩展名的缺失路径也可能漏判。allFiles(stat)分支,但命中显式路径前缀或常见附件扩展名时仍会拒绝。./build.sh 会生成 report.sql),这是与带空格文件名不可区分时的取舍。--仍 blanket ban。交叉评审后追加的提交(append 在作者原提交之后,未改写原提交)
botmux send --as independent|suggestion单独发送(空 stdin,正文由cmdSend用crossPrincipalAsKeyword合成、嵌入[botmux-as:v1:…])此前被新预检误判为「正文为空」(exit 2),现恢复可用;非法--as值在读取 stdin 之前报参数用法错误(非法值配合不闭合的非 TTY stdin 不再阻塞在 stdin 读取)。docs/riff.md:Riff 工具通道的send正文只走 heredoc/管道 stdin,裸-位置参数会被判riff_host_flag_unsupported:-;裸-作 stdin 同义仅普通本地 CLI 成立;card stream write --content-file -仍保留。RIFF_UPLOAD_PREFIX,不再散落字面量。有意行为变化(在上方清单基础上补充)
--as independent|suggestion单独发送(无正文/无附件)恢复为合法输入,正文在下游合成;这是恢复cmdSend本就存在的能力(合法输入集相对本 PR 收紧阶段略放大,最终相对收紧前 master 为「恢复原有行为」)。send --content-file -在 client 预检直接拒绝(Riff 与本地一致),改用 heredoc/管道;card stream write --content-file -不变。--在send全域拒绝。