Skip to content

Commit cab5728

Browse files
committed
Remove system directory write blocks from dangerous-command-blocker
The redirect patterns matched text content inside command arguments (e.g. PR body text containing example paths), causing false positives. Write location enforcement is the scope guard's responsibility, not the dangerous-command-blocker's.
1 parent a70105c commit cab5728

File tree

3 files changed

+8
-25
lines changed

3 files changed

+8
-25
lines changed

container/.devcontainer/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- Fix false positives blocking writes to system paths (`/dev/null`, `/usr/`, `/etc/`, `$HOME/`) — scope guard now only enforces isolation between workspace projects
88
- Remove complex system-command exemption logic (no longer needed)
99

10+
### Dangerous Command Blocker
11+
12+
- Remove system directory write redirect blocks (`> /usr/`, `> /etc/`, `> /bin/`, `> /sbin/`) — caused false positives on text content in command arguments (e.g. PR body text containing paths); write location enforcement is the scope guard's responsibility
13+
1014
### CLI Integration
1115

1216
- Add codeforge-cli devcontainer feature — installs the CodeForge CLI (`codeforge` command) globally via npm

container/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/scripts/block-dangerous.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@
5555
r"\bgit\s+push\s+--force\s+(origin\s+)?(main|master)\b",
5656
"Blocked: force push to main/master destroys history",
5757
),
58-
# System directory modification
59-
(r">\s*/usr/", "Blocked: writing to /usr system directory"),
60-
(r">\s*/etc/", "Blocked: writing to /etc system directory"),
61-
(r">\s*/bin/", "Blocked: writing to /bin system directory"),
62-
(r">\s*/sbin/", "Blocked: writing to /sbin system directory"),
6358
# Disk formatting
6459
(r"\bmkfs\.\w+", "Blocked: disk formatting command"),
6560
(r"\bdd\s+.*of=/dev/", "Blocked: dd writing to device"),

container/tests/plugins/test_block_dangerous.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,7 @@ def test_bare_force_push(self, cmd: str) -> None:
118118

119119

120120
# ---------------------------------------------------------------------------
121-
# 5. System directory writes
122-
# ---------------------------------------------------------------------------
123-
124-
125-
class TestSystemDirectoryWrites:
126-
@pytest.mark.parametrize(
127-
"cmd,dir_name",
128-
[
129-
("> /usr/foo", "/usr"),
130-
("> /etc/foo", "/etc"),
131-
("> /bin/foo", "/bin"),
132-
("> /sbin/foo", "/sbin"),
133-
],
134-
)
135-
def test_redirect_to_system_dir(self, cmd: str, dir_name: str) -> None:
136-
assert_blocked(cmd, substr=dir_name)
137-
138-
139-
# ---------------------------------------------------------------------------
140-
# 6. Disk operations
121+
# 5. Disk operations
141122
# ---------------------------------------------------------------------------
142123

143124

@@ -229,6 +210,9 @@ class TestSafeCommands:
229210
"cat /etc/hosts",
230211
"echo hello",
231212
"git status",
213+
"echo '> /usr/local/bin/foo' | gh pr create --body-file -",
214+
"echo x > /usr/local/bin/tool",
215+
"echo x > /etc/myconfig",
232216
],
233217
)
234218
def test_safe_commands_allowed(self, cmd: str) -> None:

0 commit comments

Comments
 (0)