mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 07:04:53 +00:00
* Fix PowerShell MCP command execution * Harden PowerShell prompt detection and document its scope - Annotate isPowerShellPrompt and the matching regex in shellUtils with a "default prompt only" caveat, so future readers know custom prompt themes (oh-my-posh, starship, custom prompt functions) are out of scope on purpose, and keep the two regexes in sync. - Cover edge cases that the original tests left implicit: trailing whitespace after the `>`, ANSI-coloured prompts, bare `PS>` with no working directory, empty/undefined inputs, and command output that merely starts with `PS` (e.g. `PSO>`, `ZIPS>`) so we don't regress into mis-wrapping non-PowerShell sessions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address multi-agent review findings on PowerShell prompt detection - Refuse to override an explicit non-PowerShell shellKind. The override is only useful when the session has no confirmed shell type (the issue #841 case is an SSH session, where shellKind is undefined). On a confirmed bash/zsh/fish session a malicious remote process emitting a `PS ...>` line could otherwise coerce one mis-wrapped command; this closes that foothold while still fixing the original bug. - Tighten the regex to /^PS(?:\s+\S.*)?>$/ so a literal `"PS >"` line is rejected. The default PowerShell prompt never emits that shape, so it's a clean spoof signal to ignore. - Treat `\r` as a line break, not a stripped character, when extracting the last idle line. PSReadLine / ConPTY emit bare `\r` to repaint the current line; without this, `"PS C:\\old>\rPS C:\\new>"` would match as one long doubled prompt that never round-trips through the live PTY tail. - Hoist the regex into shellUtils as `isDefaultPowerShellPromptLine` so prompt extraction and wrapper selection share one source of truth. - Drop a redundant optional-chain on `String.prototype.split().pop()`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Drop dead 'powershell' entry from override set; document shellKind universe Round-2 review noted that listing "powershell" in SHELL_KINDS_OPEN_TO_PROMPT_OVERRIDE was a no-op: when the configured shell kind is already powershell, the override path returns "powershell" on a match and the fall-through returns "powershell" on a miss, so the entry only mattered if reverse PS-to-POSIX detection were added later. Removing it makes the gate's intent ("override only when there's no confirmed shell type") obvious from the data alone. Also enumerate the full universe of shellKind values in a comment next to the set so the next reader doesn't have to grep terminalBridge and localShell.cjs to know what's excluded and why ("raw" sessions bypass buildWrappedCommand entirely; "cmd"/"fish" are confirmed and shouldn't flip to PowerShell on a spoofed remote line). Add a regression test that locks the current behavior for an explicit shellKind="powershell" session whose visible prompt looks POSIX (e.g. nested into WSL/bash) — we keep powershell wrapping. Lock this so a future maintainer doesn't accidentally introduce reverse detection without also handling the cross-shell quoting implications. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>