You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After #11581 made the hooks executable, block-dangerous-commands.sh began firing — and it blocks ordinary read-only commands with "destructive disk operation detected". Four false positives in one session; every blocked command merely contained 2>/dev/null or >/dev/null. It even blocks gh issue create when the issue body quotes the pattern.
>[[:space:]]*/dev/ is intended to catch writes to raw devices (> /dev/sda) but also matches the universal shell idiom 2>/dev/null. The hook was committed non-executable (#11581), so this never fired before and the false positive went undetected.
Fix
Restrict the redirect pattern to block devices (/dev/(sd|hd|nvme|vd|xvd|mmcblk|loop|dm-|md)) instead of all of /dev/, keeping mkfs/dd if= intact. Add regression tests: 2>/dev/null and >/dev/null must pass; > /dev/sda1 must stay blocked.
Acceptance criteria (quoted verbatim from issue body):
"Restrict the redirect pattern to block devices (/dev/(sd|hd|nvme|vd|xvd|mmcblk|loop|dm-|md)) instead of all of /dev/, keeping mkfs/dd if= intact" — ✅ block-dangerous-commands.sh line 228-231, exactly that pattern; mkfs/dd if= alternations unchanged.
"Add regression tests: 2>/dev/null and >/dev/null must pass; > /dev/sda1 must stay blocked" — ✅ 7 new cases in block-dangerous-commands_test.sh (3 allow: stderr discard, stdout+stderr discard, git null redirect; 4 block: sda1 write, nvme0n1 write, dd if=, mkfs). Suite: 40 passed, 0 failed.
Activity
fix(hooks): disk-redirect guard targets block devices only (#11593) (#…
github-actions commentedon Jul 11, 2026
PR #11594 (merged to
Dev_new_gui) references this issue with a close keyword.If this issue is fully resolved, close it manually. If work remains, no action is needed.
mrveiss commentedon Jul 11, 2026
✅ Closed with proof of implementation
Commit(s):
f525a513a(guard narrowed + 7 regression tests) — merged to Dev_new_gui via PR #11594.Gate 2:
check-issue-close-refs.sh 11593→ clear (exit 0).Acceptance criteria (quoted verbatim from issue body):
/dev/(sd|hd|nvme|vd|xvd|mmcblk|loop|dm-|md)) instead of all of/dev/, keepingmkfs/dd if=intact" — ✅block-dangerous-commands.shline 228-231, exactly that pattern;mkfs/dd if=alternations unchanged.2>/dev/nulland>/dev/nullmust pass;> /dev/sda1must stay blocked" — ✅ 7 new cases inblock-dangerous-commands_test.sh(3 allow: stderr discard, stdout+stderr discard, git null redirect; 4 block: sda1 write, nvme0n1 write, dd if=, mkfs). Suite: 40 passed, 0 failed.Edit was user-authorized in-session (protect-files hook otherwise forbids editing hook scripts).