fix(core): require approval for force delete on Windows #8590
+173
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Implemented detection for dangerous "force delete" commands on Windows to trigger the user approval prompt when
--ask-for-approval on-requestis set. This aligns Windows behavior with the existing safety checks forrm -rfon 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:
Remove-Item(and aliases) when used with the-Forceflag.del /f(force delete files).rd /s /q(recursive delete quiet).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).cargo testandcargo clippy.