Skip to content

Conversation

@448523760
Copy link
Contributor

Fix force delete approval bypass on Windows. Ensures ask-for-approval setting is respected when executing force delete operations, aligning behavior with Linux platform.

close #8567

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

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 168 to 176
// Classic `cmd /c start https://...` ShellExecute path.
if first_cmd_lc == "start" {
return args_have_url(cmd_args);
}

// Parity with Unix `rm -f`: CMD `del/erase /f` forces deletion of read-only files.
if matches!(first_cmd_lc.as_str(), "del" | "erase") {
return cmd_args.iter().any(|a| a.eq_ignore_ascii_case("/f"));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Preserve URL checks for non-start cmd /c invocations

With this change, is_dangerous_cmd only treats start and del/erase /f as dangerous and returns false for any other command body. That drops the previous args_have_url fallback, so cmd /c msedge https://example.com, cmd /c rundll32 url.dll,fileprotocolhandler https://..., etc. are no longer flagged even though they launch URLs via cmd. This is a regression because the cmd wrapper is the executable being inspected, so is_direct_gui_launch won’t catch the nested browser invocation; as a result the approval gate can be bypassed for URL launches.

Useful? React with 👍 / 👎.

@448523760 448523760 marked this pull request as draft December 27, 2025 15:06
Copy link
Contributor

@LIHUA919 LIHUA919 left a comment

Choose a reason for hiding this comment

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

LGTM

@448523760 448523760 marked this pull request as ready for review December 29, 2025 01:31
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

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 180 to 184
let mut nested: Vec<String> = Vec::with_capacity(1 + cmd_args.len());
nested.push(first_cmd.to_string());
nested.extend(cmd_args.iter().cloned());
if is_direct_gui_launch(&nested) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Detect nested PowerShell URL launches via cmd

After parsing cmd /c …, this branch only treats start, del/erase /f, or direct GUI launchers as dangerous. A command like cmd /c powershell -Command "Start-Process https://example.com" (or pwsh) contains a URL but won’t match is_direct_gui_launch, so is_dangerous_cmd returns false and approval is bypassed for a URL launch via PowerShell. This was previously caught by the generic URL-arg fallback and now regresses URL gating for nested PowerShell invocations on Windows.

Useful? React with 👍 / 👎.

@448523760
Copy link
Contributor Author

close it, since duplicated with #8590

@448523760 448523760 closed this Dec 29, 2025
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

2 participants