Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[bug] Dangerous-command rules miss standard forms: git push -f, dd with reordered args, systemctl poweroff, dead ":>" regex

Aperta Adatta ai principianti
#130 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
shell, typescript
Ambito
cli, security, tooling

Direzione di ricerca

L'issue punta al file packages/coding-agent/src/step/command-policy.ts righe 93-105, dove sono definite le regole dangerous-command. Inizia esaminando i pattern regex per i comandi dd, git, systemctl e :>. Esegui i frammenti di test forniti per confermare i falsi negativi. La correzione comporta l'aggiornamento delle regex per farle corrispondere alle forme standard dei comandi e l'aggiunta dei comandi mancanti al set lifecycle. Controlla permissions.ts per capire come funziona decideStepToolCall. Scrivi test per ogni regola corretta per assicurarti che ora attivino una conferma.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

untriaged
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 — the copy-device rule /\bdd\s+if=/iu requires if= immediately after dd; any bs=/of= first defeats it.
  • git push -f origin main / git push origin +main — destructive-git only matches --force, not -f or +refspec.
  • git -C repo reset --hard / git -c x=y push --force — the regex requires the subcommand to immediately follow git, so any global option defeats all three git rules.
  • systemctl poweroff / systemctl halt / init 0 — DANGEROUS_LIFECYCLE_COMMANDS only contains reboot/shutdown.
  • :> /dev/sda — /\b:>\s*\/dev\//u can never match realistic input: \b before : requires a preceding word character, so only odd forms like x:> /dev/sda match. 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

Lingua principale
TypeScript
Stelle
850
Fork
62
Merge medio
1g 12h
PR unite (30g)
43

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stepfun-ai/Step-Code

Tutte le issue di stepfun-ai/Step-Code

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.