MCPcopy Create free account
hub / github.com/WJX20/claude-code / checkPwshCommandOrFile

Function checkPwshCommandOrFile

src/tools/PowerShellTool/powershellSecurity.ts:192–205  ·  view source on GitHub ↗

* Checks for PowerShell re-invocation (nested pwsh/powershell process). * * Any PowerShell executable in command position is flagged — not just * -Command/-File. Bare `pwsh` receiving stdin (`Get-Content x | pwsh`) or * a positional script path executes arbitrary code with none of the explicit

(
  parsed: ParsedPowerShellCommand,
)

Source from the content-addressed store, hash-verified

190 * process will run.
191 */
192function checkPwshCommandOrFile(
193 parsed: ParsedPowerShellCommand,
194): PowerShellSecurityResult {
195 for (const cmd of getAllCommands(parsed)) {
196 if (isPowerShellExecutable(cmd.name)) {
197 return {
198 behavior: 'ask',
199 message:
200 'Command spawns a nested PowerShell process which cannot be validated',
201 }
202 }
203 }
204 return { behavior: 'passthrough' }
205}
206
207/**
208 * Checks for download cradle patterns - common malware techniques

Callers

nothing calls this directly

Calls 2

isPowerShellExecutableFunction · 0.85
getAllCommandsFunction · 0.50

Tested by

no test coverage detected