### What Implemented detection for dangerous "force delete" commands on Windows to trigger the user approval prompt when `--ask-for-approval on-request` is set. This aligns Windows behavior with the existing safety checks for `rm -rf` on Linux. ### Why Fixes #8567 - a critical safety gap where destructive Windows commands could bypass the approval prompt. This prevents accidental data loss by ensuring the user explicitly confirms operations that would otherwise suppress the OS's native confirmation prompts. ### How Updated the Windows command safety module to identify and flag the following patterns as dangerous: * **PowerShell**: * Detects `Remove-Item` (and aliases `rm`, `ri`, `del`, `erase`, `rd`, `rmdir`) when used with the `-Force` flag. * Uses token-based analysis to robustly detect these patterns even inside script blocks (`{...}`), sub-expression `(...)`, or semicolon-chained sequences. * **CMD**: * Detects `del /f` (force delete files). * Detects `rd /s /q` (recursive delete quiet). * **Command Chaining**: Added support for analyzing chained commands (using `&`, `&&`, `|`, `||`) to separate and check individual commands (e.g., catching `del /f` hidden in `echo log & del /f data`). ### Testing Added comprehensive unit tests covering: * **PowerShell**: `Remove-Item -Path 'test' -Recurse -Force` (Exact reproduction case). * **Complex Syntax**: Verified detection inside blocks (e.g., `if ($true) { rm -Force }`) and with trailing punctuation. * **CMD**: * `del /f` (Flagged). * `rd /s /q` (Flagged). * Chained commands: `echo hi & del /f file` (Flagged). * **False Positives**: * `rd /s` (Not flagged - relies on native prompt). * Standard deletions without force flags. Verified with `cargo test` and `cargo clippy`. --------- Co-authored-by: Eric Traut <etraut@openai.com>
codex-core
This crate implements the business logic for Codex. It is designed to be used by the various Codex UIs written in Rust.
Dependencies
Note that codex-core makes some assumptions about certain helper utilities being available in the environment. Currently, this support matrix is:
macOS
Expects /usr/bin/sandbox-exec to be present.
When using the workspace-write sandbox policy, the Seatbelt profile allows
writes under the configured writable roots while keeping .git (directory or
pointer file), the resolved gitdir: target, and .codex read-only.
Linux
Expects the binary containing codex-core to run the equivalent of codex sandbox linux (legacy alias: codex debug landlock) when arg0 is codex-linux-sandbox. See the codex-arg0 crate for details.
All Platforms
Expects the binary containing codex-core to simulate the virtual apply_patch CLI when arg1 is --codex-run-as-apply-patch. See the codex-arg0 crate for details.