[bug] Dangerous-command rules miss standard forms: git push -f, dd with reordered args, systemctl poweroff, dead ":>" regex
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- shell, typescript
Hướng nghiên cứu
Issue chỉ đến tệp packages/coding-agent/src/step/command-policy.ts dòng 93-105, nơi các quy tắc dangerous-command được định nghĩa. Bắt đầu bằng cách kiểm tra các mẫu regex cho lệnh dd, git, systemctl và :>. Chạy các đoạn mã thử nghiệm được cung cấp để xác nhận các âm tính giả. Việc sửa lỗi liên quan đến cập nhật các regex để khớp với các dạng lệnh tiêu chuẩn và thêm các lệnh còn thiếu vào tập lifecycle. Kiểm tra permissions.ts để hiểu cách decideStepToolCall hoạt động. Viết bài kiểm tra cho từng quy tắc đã sửa để đảm bảo chúng hiện kích hoạt xác nhận.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 850
- Fork
- 62
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 43
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của stepfun-ai/Step-Code
-
area/build bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#190 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/tools bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#186 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/tools bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#185 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/tools bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#184 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#179 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của stepfun-ai/Step-Code
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vercel/streamdown#673 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(stream-protocol): document messageMetatadata on start/finish and the message-metadata chunkCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởfactory-active task-identify-harness-labels-done task-identify-issue-type-done
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vercel/ai#23375 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
agilepathway/label-checker#721 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CLI Empathy needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
chromaui/chromatic-cli#1524 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày