[bug] Dangerous-command rules miss standard forms: git push -f, dd with reordered args, systemctl poweroff, dead ":>" regex
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 75/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- shell, typescript
调研方向
该 issue 指向文件 packages/coding-agent/src/step/command-policy.ts 第 93-105 行,其中定义了 dangerous-command 规则。首先检查 dd、git、systemctl 和 :> 命令的正则表达式模式。运行提供的测试代码片段以确认假阴性。修复涉及更新正则表达式以匹配标准命令形式,并将缺失的命令添加到 lifecycle 集合中。检查 permissions.ts 以了解 decideStepToolCall 的工作原理。为每个已更正的规则编写测试,以确保它们现在会触发确认。
由索引模型根据 Issue 内容生成。
描述
What happened?
The dangerous-command rules in packages/coding-agent/src/step/command-policy.ts:93-105 miss several standard, unobfuscated forms of the exact command classes they are meant to catch. Since the default permission preset is bypass ("Run ordinary tools without approval; dangerous commands still ask") and an unmatched command analyzes as ordinary and is allowed with no confirmation (decideStepToolCall, permissions.ts), these execute silently in the default configuration:
dd bs=4M if=disk.img of=/dev/sda/dd of=/dev/sda if=/dev/zero— thecopy-devicerule/\bdd\s+if=/iurequiresif=immediately afterdd; anybs=/of=first defeats it.git push -f origin main/git push origin +main—destructive-gitonly matches--force, not-for+refspec.git -C repo reset --hard/git -c x=y push --force— the regex requires the subcommand to immediately followgit, so any global option defeats all three git rules.systemctl poweroff/systemctl halt/init 0—DANGEROUS_LIFECYCLE_COMMANDSonly containsreboot/shutdown.:> /dev/sda—/\b:>\s*\/dev\//ucan never match realistic input:\bbefore:requires a preceding word character, so only odd forms likex:> /dev/sdamatch. The rule is effectively dead code.
Steps to reproduce
/\bdd\s+if=/iu.test("dd bs=4M if=disk.img of=/dev/sda") // false
// destructive-git:
/\bgit\s+(?:reset\s+--hard|clean\s+-[^\n]*f|push\s+[^\n]*--force(?:-with-lease)?)/iu.test("git push -f origin main") // false
/\b:>\s*\/dev\//u.test(":> /dev/sda") // false
Feeding each command through analyzeCommandPolicy returns { kind: "ordinary" }, and decideStepToolCall("run_command", ..., bypass) returns { action: "allow" } — while rm -rf ./build and git push --force correctly return confirm.
Expected behavior
Standard forms of these dangerous commands should trigger confirmation, as the bypass preset promises. Suggestions: match of=/dev/ anywhere in dd args; evaluate git via parsed argv (as isRecursiveForceRemove already does) to cover -f, +refspec, and git -C/-c prefixes; add poweroff/halt and init 0|6 to the lifecycle set; fix or drop the :> rule; add tests using each rule’s standard spellings. Happy to implement this if you’d like.
Version
main @ e411b1a
- 主要语言
- TypeScript
- 星标
- 850
- 派生
- 62
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 43
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
stepfun-ai/Step-Code 的其他 Issue
-
area/build bug
难度 2/5 1-3 小时 新手友好度 75/100
stepfun-ai/Step-Code#190 · 2 条评论 ·
维护者通常 1 天内回复
-
area/tools bug
难度 2/5 1-3 小时 新手友好度 75/100
stepfun-ai/Step-Code#186 · 1 条评论 ·
维护者通常 1 天内回复
-
area/tools bug
难度 2/5 1-3 小时 新手友好度 75/100
stepfun-ai/Step-Code#185 · 1 条评论 ·
维护者通常 1 天内回复
-
area/tools bug
难度 2/5 1-3 小时 新手友好度 75/100
stepfun-ai/Step-Code#184 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
stepfun-ai/Step-Code#179 · 1 条评论 ·
维护者通常 1 天内回复
查看 stepfun-ai/Step-Code 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
vercel/streamdown#673 · 1 个 reaction ·
维护者通常 1 天内回复
-
docs(stream-protocol): document messageMetatadata on start/finish and the message-metadata chunk可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭factory-active task-identify-harness-labels-done task-identify-issue-type-done
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
agilepathway/label-checker#721 ·
维护者通常 1 天内回复
-
CLI Empathy needs triage
难度 2/5 1-3 小时 新手友好度 74/100
chromaui/chromatic-cli#1524 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复