MCPcopy Create free account
hub / github.com/Noumena-Network/code / getDisableExtglobCommand

Function getDisableExtglobCommand

src/utils/shell/bashProvider.ts:40–57  ·  view source on GitHub ↗

* Returns a shell command to disable extended glob patterns for security. * Extended globs (bash extglob, zsh EXTENDED_GLOB) can be exploited via * malicious filenames that expand after our security validation. * * When CLAUDE_CODE_SHELL_PREFIX is set, the actual executing shell may differ * fr

(shellPath: string)

Source from the content-addressed store, hash-verified

38 * When no shell prefix is set, we use the appropriate command for the detected shell.
39 */
40function getDisableExtglobCommand(shellPath: string): string | null {
41 // When CLAUDE_CODE_SHELL_PREFIX is set, the wrapper may use a different shell
42 // than shellPath, so we include both bash and zsh commands
43 if (process.env.CLAUDE_CODE_SHELL_PREFIX) {
44 // Redirect both stdout and stderr because zsh's command_not_found_handler
45 // writes to stdout instead of stderr
46 return '{ shopt -u extglob || setopt NO_EXTENDED_GLOB; } >/dev/null 2>&1 || true'
47 }
48
49 // No shell prefix - use shell-specific command
50 if (shellPath.includes('bash')) {
51 return 'shopt -u extglob 2>/dev/null || true'
52 } else if (shellPath.includes('zsh')) {
53 return 'setopt NO_EXTENDED_GLOB 2>/dev/null || true'
54 }
55 // Unknown shell - do nothing, we don't know the right command
56 return null
57}
58
59export async function createBashShellProvider(
60 shellPath: string,

Callers 1

buildExecCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected