The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(approval): deno eval asks for approval behind global flags (-q, -L <level>)
teknium16ae1fab336cc
diff --git a/tests/tools/test_approval_bun_deno_eval.py b/tests/tools/test_approval_bun_deno_eval.pyindex 8240cb0ec03..7fdfffde296 100644--- a/tests/tools/test_approval_bun_deno_eval.py+++ b/tests/tools/test_approval_bun_deno_eval.py@@ -21,6 +21,13 @@ class TestBunDenoInlineScriptExecution:# Command-position wrappers must not shield the interpreter.('sudo bun -e "console.log(1)"', "script execution via -e/-c flag"),('sudo deno eval "console.log(1)"', "script execution via -e/-c flag"),+ # Deno global options precede the subcommand (`deno [OPTIONS] [COMMAND]`); `-L`+ # takes a separate value. Verified against deno 2.9.6: each of these runs the script.+ ('deno -q eval "console.log(1)"', "script execution via -e/-c flag"),+ ('deno --quiet eval "console.log(1)"', "script execution via -e/-c flag"),+ ('deno -L debug eval "console.log(1)"', "script execution via -e/-c flag"),+ ('deno -Ldebug eval "console.log(1)"', "script execution via -e/-c flag"),+ ('deno --log-level=debug eval "console.log(1)"', "script execution via -e/-c flag"),# Windows resolves executable names case-insensitively; `_interpreter_family`# lowercases the basename, so BUN.EXE / Deno.exe must be classified too.('BUN.EXE -e "console.log(1)"', "script execution via -e/-c flag"),@@ -46,6 +53,10 @@ class TestBunDenoInlineScriptExecution:"deno lint",# A file literally named eval.ts is a `run` operand, not the eval subcommand."deno run eval.ts",+ "deno -q run eval.ts",+ "deno -L debug run eval.ts",+ # `deno -- eval` opens the REPL (the subcommand parser stops at `--`); nothing runs.+ 'deno -- eval "console.log(1)"',# `deno eval` inside quotes is data for echo, not a command position."echo 'use deno eval for that'",],diff --git a/tools/approval_detection.py b/tools/approval_detection.pyindex 755d15f94b4..7421f7a9741 100644--- a/tools/approval_detection.py+++ b/tools/approval_detection.py@@ -596,10 +596,10 @@ _INTERPRETER_WITH_ARG = {"php": {"-c", "-d", "-z"},"powershell": {"-configurationname", "-custompipename", "-executionpolicy", "-inputformat", "-outputformat","-settingsfile", "-version", "-windowstyle", "-workingdirectory"},- # Deno deliberately maps to no value-taking globals: its inline-script entry is the- # bare `eval` subcommand (first-arg fast path below), and its dash flags that precede- # `eval` (--ext, --no-check, ...) never swallow the next token as a value.- "bun": {"--config", "--cwd", "--env-file", "--preload", "--require"}, "deno": set(),+ # Deno's inline-script entry is the bare `eval` subcommand; the only global option that+ # may precede it and take a separate value is `-L/--log-level <level>` (`--env-file[=v]`+ # binds with `=`; the `--unstable-*` and `--ext` flags belong after `eval`).+ "bun": {"--config", "--cwd", "--env-file", "--preload", "--require"}, "deno": {"-L", "--log-level"},}_READ_TOOL_EXEC_FLAGS = {"sort": {"--compress-program"}, "rg": {"--pre", "--hostname-bin"}, "ag": {"--pager"},@@ -846,10 +846,6 @@ def _iter_top_level_shell_segments(command: str):def _interpreter_exec_flag(family: str, args: list[str]) -> str | None:"""Return an execution-bearing interpreter option, if present."""flags, with_arg = _INTERPRETER_EXEC_FLAGS[family], _INTERPRETER_WITH_ARG[family]- # Deno evaluates inline scripts via a bare `eval` subcommand rather than a dash flag, and- # only as the first argument; a later positional `eval` stays data.- if family == "deno" and args and args[0].lower() == "eval":- return "eval"powershell = family == "powershell"skip_value = Falsefor token in args:@@ -857,6 +853,11 @@ def _interpreter_exec_flag(family: str, args: list[str]) -> str | None:skip_value = Falsecontinueif token == "--" or (not powershell and not token.startswith("-")):+ # Deno evaluates inline scripts via a bare `eval` subcommand rather than a dash+ # flag: the FIRST positional token, after any global options (`deno -q eval ...`);+ # a later positional `eval` (`deno run eval.ts`) stays data.+ if family == "deno" and token.lower() == "eval":+ return "eval"breakoption, equals, _ = token.partition("=")comparable = option.lower() if powershell else option