Skip to content

fix: Use Start-Process for online help to avoid security warning#5447

Closed
aryanjsingh wants to merge 1 commit intoPowerShell:mainfrom
aryanjsingh:fix/issue-5427-ctrlf1-on-a-keyword-in-the-editor-window
Closed

fix: Use Start-Process for online help to avoid security warning#5447
aryanjsingh wants to merge 1 commit intoPowerShell:mainfrom
aryanjsingh:fix/issue-5427-ctrlf1-on-a-keyword-in-the-editor-window

Conversation

@aryanjsingh
Copy link
Copy Markdown

Summary

Fixes an issue where using 'Show Help' (Ctrl+F1) would trigger an Invoke-WebRequest security warning in the PowerShell Integrated Console. The implementation has been changed from an LSP notification to executing a command directly in the console. The new command gets the online help URL and opens it using Start-Process, which avoids the underlying Invoke-WebRequest call that caused the warning.

Changes

  • src/features/ShowHelp.ts: The ShowHelpFeature is updated to execute a PowerShell command directly in the integrated console instead of sending an LSP notification. The new command retrieves the online help URL from Get-Help and opens it with Start-Process, bypassing the Invoke-WebRequest call that triggered a security warning in recent PowerShell versions.

Related Issue

Closes #5427

Copilot AI review requested due to automatic review settings April 3, 2026 20:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR changes how “Show Help” (Ctrl+F1) opens online help so it no longer triggers the Invoke-WebRequest security warning in recent Windows PowerShell versions, by switching to a Start-Process-based approach.

Changes:

  • Replaces the prior LSP notification-based “Show Help” flow with a PowerShell command executed in the integrated console.
  • Builds a PowerShell command that resolves the online help URI via Get-Help and opens it via Start-Process.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7 to 8
import { PowerShellIntegratedConsole } from "../powerShellIntegratedConsole";

Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The new import "../powerShellIntegratedConsole" (and PowerShellIntegratedConsole.instance.executeCommand(...)) does not resolve anywhere in src/—there is no powerShellIntegratedConsole.ts and no exported PowerShellIntegratedConsole class. This will fail TypeScript compilation. Either add/commit the missing module, or rework this to use the existing session/terminal plumbing (e.g., via the session manager / PowerShellProcess terminal) that already exists in this repo.

Copilot uses AI. Check for mistakes.
Comment on lines 25 to +29
const selection = editor.selection;
const doc = editor.document;
const cwr = doc.getWordRangeAtPosition(selection.active);
const text = doc.getText(cwr);
text = doc.getText(cwr);
}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

doc.getWordRangeAtPosition(...) can return undefined (e.g., when the cursor is on whitespace). Passing undefined to doc.getText() returns the entire document, which would make escapedText huge and produce an invalid/slow PowerShell command. Consider explicitly handling cwr === undefined (return early or fall back to the selection text) before calling getText.

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +37
// We need to escape single quotes for the PowerShell command.
const escapedText = text.replace(/'/g, "''");
const psCommand =
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This file already has a shared helper for escaping single quotes in PowerShell strings (utils.escapeSingleQuotes(...)). Using that helper here would avoid duplicating escaping logic and keep quoting consistent across the extension.

Copilot uses AI. Check for mistakes.
@andyleejordan
Copy link
Copy Markdown
Member

I think I'd rather see us use VS Code to render the content at the URL from Get-Help. What does the equivalent functionality in e.g. the Python extension look like? If at all possible we should just avoid running Get-Help in the integrated console, the better user experience would be native display in VS Code.

@aryanjsingh aryanjsingh closed this Apr 4, 2026
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.

[Ctrl]+[F1] on a keyword in the editor window leads to a Security Warning dialog in the terminal window

3 participants