Skip to content

Commit b909df6

Browse files
committed
Allow shell output redirections to /tmp/ in plan/explorer agents instead of denying them
1 parent 9dbe3d4 commit b909df6

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Improve MCP error logging to show error code, message, and data instead of null.
77
- Improve error handling when MCP promtps fail on server side.
88
- Use rewrite-json to edit jsons without losing formatting.
9+
- Allow shell output redirections to `/tmp/` in plan/explorer agents instead of denying them.
910

1011
## 0.115.1
1112

src/eca/config.clj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
(defn get-property [property] (System/getProperty property))
4343

4444
(def ^:private dangerous-commands-regexes
45-
[".*[12&]?>>?\\s*(?!/dev/null($|\\s))(?!&\\d+($|\\s))\\S+.*"
46-
".*\\|\\s*(tee|dd|xargs).*",
47-
".*\\b(sed|awk|perl)\\s+.*-i.*",
48-
".*\\b(rm|mv|cp|touch|mkdir)\\b.*",
49-
".*git\\s+(add|commit|push).*",
50-
".*npm\\s+install.*",
51-
".*-c\\s+[\"'].*open.*[\"']w[\"'].*",
52-
".*bash.*-c.*[12&]?>>?\\s*(?!/dev/null($|\\s))(?!&\\d+($|\\s))\\S+.*"])
45+
[".*[12&]?>>?\\s*(?!/dev/null($|\\s))(?!/tmp/\\S*($|\\s))(?!&\\d+($|\\s))(?!>)\\S+.*" ;; output redirection (except /dev/null and /tmp/)
46+
".*\\|\\s*(tee|dd|xargs).*", ;; pipe to tee/dd/xargs
47+
".*\\b(sed|awk|perl)\\s+.*-i.*", ;; in-place editing
48+
".*\\b(rm|mv|cp|touch|mkdir)\\b.*", ;; file mutation commands
49+
".*git\\s+(add|commit|push).*", ;; git write ops
50+
".*npm\\s+install.*", ;; npm install
51+
".*-c\\s+[\"'].*open.*[\"']w[\"'].*", ;; python open(...,'w')
52+
".*bash.*-c.*[12&]?>>?\\s*(?!/dev/null($|\\s))(?!/tmp/\\S*($|\\s))(?!&\\d+($|\\s))(?!>)\\S+.*"])
5353

5454
(def ^:private openai-variants
5555
{"none" {:reasoning {:effort "none"}}

test/eca/features/tools_test.clj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@
324324
"date"
325325
"env"))
326326

327+
(testing "redirections to /tmp/ are not denied in plan mode"
328+
(are [command] (not= :deny
329+
(f.tools/approval all-tools shell-tool
330+
{"command" command} {} config "plan"))
331+
"gh api repos/editor-code-assistant/eca-emacs/contents/eca-chat.el --jq '.content' 2>/dev/null | base64 -d 2>/dev/null > /tmp/eca-chat.el && wc -l /tmp/eca-chat.el"
332+
"echo test > /tmp/output.txt"
333+
"cat file.txt > /tmp/result.log"
334+
"ls -la >> /tmp/listing.txt"
335+
"some-cmd 2> /tmp/errors.log"
336+
"bash -c 'echo test > /tmp/file.txt'"))
337+
327338
(testing "same commands work fine in code agent mode (not denied)"
328339
(are [command] (not= :deny
329340
(f.tools/approval all-tools shell-tool

0 commit comments

Comments
 (0)