permissions: reads and read-only bash run free; secrets and writes ask
This commit is contained in:
1 parent
1e830bb8f4
commit
b5db6ce80a
6 files changed
+85
-10
No files matched your search
+2
-2
@@ -52,13 +52,13 @@ kill $srv; rm -f hello.txt
|
||||
|
||||
# 3) extension blocks the bash call (cat) and registers its tool
|
||||
start 3
|
||||
printf '[[extensions]]\ncommand = ["python3", "%s/examples/ext_guard.py", "cat hello"]\n' "$root" >> "$tmp/home/.hx/config.toml"
|
||||
printf '[[extensions]]\ncommand = ["python3", "%s/examples/ext_guard.py", "sort hello"]\n' "$root" >> "$tmp/home/.hx/config.toml"
|
||||
"$root/target/debug/hx" -p "go" --mode json > "$tmp/ext" 2> "$tmp/err" || fail "ext run" "$tmp/err"
|
||||
python3 - "$tmp/ext" <<'PY' || fail "ext block" "$tmp/ext"
|
||||
import json, sys
|
||||
ev = [json.loads(l) for l in open(sys.argv[1])]
|
||||
log = json.dumps(ev)
|
||||
assert "blocked: ext_guard: `cat hello` is not allowed" in log, "no block"
|
||||
assert "blocked: ext_guard: `sort hello` is not allowed" in log, "no block"
|
||||
bash = [e for e in ev if e["type"] == "tool_result" and e["name"] == "bash"]
|
||||
assert len(bash) == 1 and bash[0]["is_error"] and bash[0]["content"].startswith("blocked:"), bash
|
||||
PY
|
||||
|
||||
Reference in new issue
Block a user