Shell Command Execution
As of 0.9.11 the
ShellAccesstoolset is no longer available. Theshell_commandtool is a now a system-level tool which can be enabled using a session configuration property documented here
shell_command
Executes one of the allowed shell commands within the current project’s root directory and returns the shell command’s output.
Heads up! The tool tries to err on the side of caution and detect and prompt you for confirmation even when you’ve approved commands but built-in (and custom) restricted strings are detected. Regardless, you and only you are responsible for the outcome of any commands run via this tool.
Parameters
command(String, required): The shell command(s) to execute. Multiple commands can be supplied separated by supported delimiters.
Tool Settings
Settings for shell_command can be specified in the config file under the tool_settings: section:
tool_settings:
shell_command:
SETTING: VALUEThe following settings are available:
-
allowed_commands- An array of executable names that are permitted.
- If unset, falls back to the
ENKAIDU_ALLOWED_EXECUTABLESenvironment variable (space‑separated). - Defaults to
ls cat grep whoami file wc findwhen not set.
-
approved_commands- An array of executables that can run without user confirmation.
- If not set, falls back to the
ENKAIDU_APPROVED_EXECUTABLESenvironment variable (space‑separated). - Defaults to an empty list.
-
restricted_terms- Additional strings that, when present anywhere in the command, require user confirmation
- If not set, checks
ENKAIDU_RESTRICTED_TERMSenvironment variable or a config entry. - The following OS‑specific terms are always included (checking is case insensitive):
- Windows:
RM,DEL,EVAL,FOR,--EXPRESSION,-E,-E=,|,; - Unix:
RM,EVAL,$(,--EXPRESSION,-E,-E=,|,;
- Windows:
-
network_allowed_commandsNew in 0.9.14- An array of commands that are allowed to run with network access when running inside the cordon.
- Commands here are typically a subset of
allowed_commands— a command must still be allowed to run at all. All other allowed commands run without network access. - Commands are matched by prefix, so you can allow a command broadly, then grant network access only when it is invoked with a particular subcommand (e.g. allow
ops, but grant network only toops test). - The cordon policy’s
allow_networksetting must betruefor this setting to have any effect. Whenallow_networkisfalse(the default), nothing running in the cordon gets network access. - Example:
tool_settings: shell_command: allowed_commands: ["ops", "ruby"] # Only "ops test" runs with network; other "ops" subcommands won't. network_allowed_commands: ["ops test"]
-
execute_through_shellNew in 0.9.11 isfalseby default.- When enabled, this allows commands that use redirection, piping and more in shell commands.
-
skip_confirm_with_cordonNew in 0.9.11 isfalseby default.- Dangerous without caution.
- If set to
trueand shell command execution is cordoned (i.e. notunsafe), user confirmation is skipped for restricted terms and allowed-but-not-approved commands. - Logs a warning if required confirmation is skipped.
Notes
-
Forbidden strings:
- On Unix the characters
&,<,>,..are forbidden. - On Windows
&is allowed (it separates commands), while..,<and>remain forbidden.
- On Unix the characters
-
Multi‑command splitting:
- An internal platform-specific regex is used to split commands in case there are multiple
- Each split command is checked for safety
-
Safety checks:
- Commands must start with one of the allowed executables (exact match or followed by a space).
- It must not contain any forbidden substrings (
..,<,>,&on Unix). - Commands that include any restricted terms or that are not approved require user confirmation before execution.
- The tool raises
PermissionErrorif the user denies the confirmation, andSafetyErrorfor unsafe commands.
-
Network inside the cordon New in 0.9.14:
- Networking inside the cordon is still gated by the cordon policy’s
allow_networkflag — when it isfalse(the default) nothing run in the cordon gets network access. - When
allow_networkistrue, network access is now granted per command: only commands that prefix-match an entry innetwork_allowed_commandsrun with network access; every other allowed command runs without it.
- Networking inside the cordon is still gated by the cordon policy’s