From fcf807fa65b5180efd143eb818857e4c77875e10 Mon Sep 17 00:00:00 2001 From: Owen <34784541+Owenmzz@users.noreply.github.com> Date: Sun, 5 Jul 2026 21:34:04 +0800 Subject: [PATCH] fix(s03): add 'del' keyword to Gate 2 bash rule for Windows compatibility Windows uses 'del' as the native delete command (equivalent to 'rm' on Linux/macOS). The Gate 2 keyword list only checked for 'rm ', '> /etc/', and 'chmod 777', so deleting a file via 'del' bypassed the permission check entirely on Windows. Add 'del' to the keyword list in code.py and the three README files (zh/en/ja) to keep them in sync. Closes #448 --- s03_permission/README.en.md | 2 +- s03_permission/README.ja.md | 2 +- s03_permission/README.md | 2 +- s03_permission/code.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/s03_permission/README.en.md b/s03_permission/README.en.md index f2f78a454..06e46daed 100644 --- a/s03_permission/README.en.md +++ b/s03_permission/README.en.md @@ -65,7 +65,7 @@ PERMISSION_RULES = [ }, { "tools": ["bash"], - "check": lambda args: any(kw in args.get("command", "") for kw in ["rm ", "> /etc/", "chmod 777"]), + "check": lambda args: any(kw in args.get("command", "") for kw in ["rm ", "> /etc/", "chmod 777", "del"]), "message": "Potentially destructive command", }, ] diff --git a/s03_permission/README.ja.md b/s03_permission/README.ja.md index 4008ed6eb..b84f87bac 100644 --- a/s03_permission/README.ja.md +++ b/s03_permission/README.ja.md @@ -65,7 +65,7 @@ PERMISSION_RULES = [ }, { "tools": ["bash"], - "check": lambda args: any(kw in args.get("command", "") for kw in ["rm ", "> /etc/", "chmod 777"]), + "check": lambda args: any(kw in args.get("command", "") for kw in ["rm ", "> /etc/", "chmod 777", "del"]), "message": "Potentially destructive command", }, ] diff --git a/s03_permission/README.md b/s03_permission/README.md index 0c745664c..307bb46de 100644 --- a/s03_permission/README.md +++ b/s03_permission/README.md @@ -65,7 +65,7 @@ PERMISSION_RULES = [ }, { "tools": ["bash"], - "check": lambda args: any(kw in args.get("command", "") for kw in ["rm ", "> /etc/", "chmod 777"]), + "check": lambda args: any(kw in args.get("command", "") for kw in ["rm ", "> /etc/", "chmod 777", "del"]), "message": "Potentially destructive command", }, ] diff --git a/s03_permission/code.py b/s03_permission/code.py index ba869c7db..5ccecf26c 100644 --- a/s03_permission/code.py +++ b/s03_permission/code.py @@ -161,7 +161,7 @@ def check_deny_list(command: str) -> str | None: "check": lambda args: not (WORKDIR / args.get("path", "")).resolve().is_relative_to(WORKDIR), "message": "Writing outside workspace"}, {"tools": ["bash"], - "check": lambda args: any(kw in args.get("command", "") for kw in ["rm ", "> /etc/", "chmod 777"]), + "check": lambda args: any(kw in args.get("command", "") for kw in ["rm ", "> /etc/", "chmod 777", "del"]), "message": "Potentially destructive command"}, ]