mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-23 09:01:16 +01:00
d60b2911d9
Previously, clicking "Always allow for `cargo` commands" after running `cargo build --release` would also silently permit `cargo run` (arbitrary code execution), `cargo publish`, and any other cargo subcommand. This was overly broad and did not match user intent. Now the extracted pattern includes the subcommand when present, so the button reads "Always allow for `cargo build` commands" and the pattern `^cargo\s+build\b` only matches `cargo build` invocations — not `cargo test`, `cargo run`, etc. ### How it works - The second token is included in the pattern when it looks like a subcommand (alphanumeric, hyphens, underscores, no leading `-`). - When the second token is a flag (e.g. `ls -la`), only the command name is used — the user sees "Always allow for `ls` commands". - Single-word commands and path-like commands behave the same as before. ### Examples | Command | Pattern | Button label | |---|---|---| | `cargo build --release` | `^cargo\s+build\b` | Always for `cargo build` commands | | `cargo test -p search` | `^cargo\s+test\b` | Always for `cargo test` commands | | `npm install` | `^npm\s+install\b` | Always for `npm install` commands | | `ls -la` | `^ls\b` | Always for `ls` commands | | `ls` | `^ls\b` | Always for `ls` commands | | `./script.sh` | *(rejected)* | *(no pattern button)* | Release Notes: - Agent: "Always allow" suggestions for terminal commands are now subcommand-specific (e.g. "Always allow for `cargo build` commands" instead of "Always allow for `cargo` commands").