Skip to content

Conversation

@hdcodedev
Copy link

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: Remove-Item (and aliases) when used with the -Force flag.
  • CMD: del /f (force delete files).
  • CMD: rd /s /q (recursive delete quiet).
    • Note: rd /s (without /q) is NOT flagged because it already natively prompts the user.

Testing

Added comprehensive unit tests covering:

  • Remove-Item -Path 'test' -Recurse -Force (Exact reproduction case).
  • del /f (Flagged).
  • rd /s /q (Flagged).
  • rd /s (Not flagged - confirms no false positives).
  • Standard deletions without force flags.
  • Verified with cargo test and cargo clippy.

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@hdcodedev hdcodedev changed the title fix: require approval for force delete on Windows fix(core): require approval for force delete on Windows Dec 28, 2025
@hdcodedev
Copy link
Author

Merged latest main to pick up the lru advisory fix (RUSTSEC-2026-0002). cargo deny now passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Force delete without confirmation

1 participant