Skip to main content

Module command_effects

Module command_effects 

Source
Expand description

Structural typing of a shell command’s effects for authority decisions.

Fail closed: observation_only is an allowlist of shapes this module fully understands (an exact executable table, per-program option rules, and a quote-aware syntax scan). Anything unusual (env assignments, heredocs, comments, newlines, groupings, wrappers, unparsable segments) is simply not observation-only. deletes and fetches_network err the other way: they unwrap wrappers and groupings and over-report rather than miss. No wording of the command is ever read for intent.

Structs§

CommandEffects

Functions§

acts_on_its_ddev_project
Whether every command is a ddev project’s own Drush or WP-CLI command on its own site (run in its own containers, against its own database): no code handed to it, no URL among its arguments, no file written or deleted on this computer, nothing sent to a remote. Run inside a folder the request’s work created, what it touches is that work’s own project, whatever the command is (live 2026-11-13: ddev drush watchdog:show in the Drupal site the helper had just installed asked the owner). Which folder it runs in is the caller’s to judge; a cd is not accepted, so the folder is the one the call names.
command_card
The approval card for running line, from its structure: the folders it only looks inside, and the one effect worth a warning (deleting, with the targets when they can be read, or sending a write to a service). title is the call’s own few words for itself. The line is shown with every secret value hidden (crate::sanitize::redact_command_secrets).
command_effects
command_names_git_config_path
Whether any shell word of command (including redirect targets, --opt=value operands, substitution bodies and nested sh -c scripts) names a git configuration path per is_git_config_path.
egress_effect
An egress effect on host, with IPv6 brackets stripped so [::1] and ::1 name one host. None for an empty or unreadable host.
execution_backend_is_local
Whether the active execution backend is this machine, so paths resolve on the local disk.
fetches_network
Whether any command (behind wrappers, groupings, substitutions and sh -c) is a known network-reaching executable or subcommand.
file_tool_write_effects
The effects of write_file/edit_file: a write of the path argument (or its aliases). A relative path, or any path on a remote workspace, is undeterminable here.
is_git_config_path
Whether writing path can plant git configuration. A structural path fact, deliberately over-reporting:
is_observation_reading_input
An observation whose observers may also read plain input redirects (cat < file). For judging where output came from, with the redirect targets checked as operands (path_operands); the authority view (CommandEffects::observation_only) stays the stricter shape.
literal_path_operands
The literal paths a command names, for facts about named files (never for trust or confinement, which need path_operands’s all-or-nothing reading): every absolute or ~/ operand of every reachable command, plus its relative operands while no command changes directory. An operand that does not read literally (expansion, quoting the scanner cannot settle) is skipped, never guessed, and the rest still count.
looked_inside
The folders a read-only command looks inside, by name, for the owner’s card (“look inside your claude-drupal and claude-wordpress folders”). Empty unless every command only reads or reports on this computer (observations, cd, a local ddev project’s own query) and writes no file. Each listing command’s operand (ls, tree, du, find, stat, a loop’s words bound) counts once, by its first component when relative and its last when absolute; ., .., home and anything still holding a variable or a glob are left out.
only_reads
Whether every command only reads, here or across the network, and changes nothing: only_reads_this_computer’s shapes, plus curl reads of any site that save nothing and send no write. What a run given the network capability does when it is not this is a change somewhere the sandbox does not reach (a container engine, a service).
only_reads_this_computer
Whether every command only reads or reports on this computer and writes nothing: observations, cd, a local ddev project’s own query, and curl reads of sites on this computer that save nothing (no output, header, cookie or trace file). Checking the dev site the work set up is a read, like listing its folder. Fail closed like the other shapes: wget saves by default, and redirects into files, deletes and writes to a site are excluded.
path_effect
A path effect on raw, absolute and normalized: ~/ expands to the home directory and a relative path resolves against cwd (an absolute directory). On disk the nearest existing ancestor is canonicalized, so an existing path is declared by its canonical form (symlinks resolved, and on macOS case and /tmp as /private/tmp) and a new one below it agrees with it. A Delete keeps its last component: removing a symlink removes the link. None when the path cannot be read structurally (shell expansion) or is relative with no known working directory.
path_operands
Every operand a command could read as a path, as written: each non-option argument of every reachable command (patterns included; they are judged as paths, which only over-reports), and the value of a --option=value. None when any cannot be determined structurally: shell expansion (variables, substitutions, globs, braces, ~ other than a leading ~/), ANSI-C quoting, an option with a path glued to it (-I/x), or a command that changes directory (cd, pushd, popd), since relative operands then resolve somewhere else.
program_label
What a command runs, in a word or two for the owner: “a shell loop” for a for/while/until loop, else its first program’s name (“ddev”), “a command” when neither can be read. Never the raw line.
proven_fetch_urls
The URLs a command is proven to have fetched when it exits 0, as written: the whole command is curl or wget invocations joined only by &&, each naming exactly one strict URL in a shape the option tables understand. With && the exit status is the last invocation’s and every earlier one had to succeed for it to run, so status 0 proves every fetch completed (for curl: a response arrived; with -f also a non-error status). None for anything a later step could mask or that could run something else: ;, ||, a pipe, a background &, a newline, a subshell or substitution, an expansion, a launcher or variable assignment, an unlisted option, or a second URL in one invocation (curl reports only its last transfer).
reaches_only_this_computer
Whether every command reaches nothing beyond this computer: an observation, cd, a local ddev project’s own query, or a curl/wget read (no body, upload or writing method) whose every address points at this computer alone (crate::web::local_site_key: a localhost name, a loopback address, or a dev site such as *.ddev.site that resolves only to loopback). Checking a site the work set up is local work, and so is a ddev query, though both need the network capability in the sandbox to reach a local port or the container engine’s socket. The shapes are the same fail-closed tables as everywhere here. Resolves the addresses’ names, so it may block briefly.
recognizably_changes
Whether command recognizably changes something: a redirection into a file, a delete, a remote write, a known file-changing program (cp, mkdir, chmod, tee, sed -i, …), or a package install. Behind a remote-exec wrapper the command it runs is judged. Unlike “not read-only”, an unknown program is not a recognized change, so a caller that credits work from this can only miss a change, never invent one. Read from token structure only (machine format: a shell command line).
remote_inner_only_reads
For a command that runs another command somewhere else (docker exec, podman exec, kubectl exec, ssh): whether that inner command only reads. None when command is not one such single wrapper, or its inner command cannot be read structurally. The inner text is judged by only_reads, so a redirection, a delete or an unknown program inside counts as a change. Read from token structure only (machine format: a shell command line), never from wording.
root_holds_repository
Whether the directory root (home-expanded, resolved against base when relative) holds a .git entry directly inside it, so a write anywhere under it can plant repository configuration.
runs_project_code_of
Whether program with its first word subcommand (none: no word) runs code the project defines: a build or a test. A Python program runs project code whatever module it is given.
sends_remote_write
Whether any command (behind wrappers, groupings, substitutions and sh -c) asks a remote service to change something: curl with a method other than GET/HEAD, a body, a form or an upload; wget with a body or such a method; git push. Read from option structure, so a plain fetch is not a write. Other network programs are not judged here.
shell_call_effects
The typed effects of a shell command run in cwd (an absolute directory, if known): egress hosts from the URL operands of network programs, deletes, and writes from output redirects, tee, cp/mv destinations, touch and mkdir. NEVER complete: a shell string cannot be proven fully described (every review round found another construct), and the keys bind the owner’s declines either way. It is understood when every segment is a program this scan models, with literal operands it resolved (no substitution, expansion, cd or unknown program): the owner is then asked again after a decline only for a call that deletes or reaches outside, not for a plain copy into the work area followed by ls and date (live 2026-11-13).
shell_path_effects
A path operand of a shell command, resolved the way the OS resolves it: the longest existing prefix of the RAW path (.. not folded first, so link/.. is the link target’s parent) is canonicalized, then the rest is appended. A Delete also declares the entry as named (its parent canonicalized, its last component kept), so both a symlink and, through a trailing /, its target are covered. None when the path cannot be read (shell expansion, relative with no working directory), when an existing prefix cannot be canonicalized (a dangling symlink), or when .. follows a component that does not exist.
url_effect
The egress effect of a URL in its strict form (scheme://[userinfo@]host[:port][/path][?query][#fragment]). None for anything else: no scheme (programs guess one), non-ASCII, whitespace, control characters, \\, quotes, shell expansion, more than one @ in the authority, a host that is not a DNS name or IP literal, a bad port, or curl glob characters ({ } [ ] * ,) outside an IPv6 host literal. The host must also be the one the URL crate reads, so a program’s parser and ours cannot disagree.
url_host_effect
The egress effect of a parsed URL: its host and its explicit port, else the scheme’s default.
without_local_paths
Effects on a remote (SSH, Docker) workspace: its paths cannot be resolved on this disk, so path keys are dropped and the effects are incomplete. Egress keys stay.