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

Function isNormalizedGitCommand

src/tools/BashTool/bashPermissions.ts:2568–2589  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

2566 * NO_COLOR=1 git status — env var prefix hides the command
2567 */
2568export function isNormalizedGitCommand(command: string): boolean {
2569 // Fast path: catch the most common case before any parsing
2570 if (command.startsWith('git ') || command === 'git') {
2571 return true
2572 }
2573 const stripped = stripSafeWrappers(command)
2574 const parsed = tryParseShellCommand(stripped)
2575 if (parsed.success && parsed.tokens.length > 0) {
2576 // Direct git command
2577 if (parsed.tokens[0] === 'git') {
2578 return true
2579 }
2580 // "xargs git ..." — xargs runs git in the current directory,
2581 // so it must be treated as a git command for cd+git security checks.
2582 // This matches the xargs prefix handling in filterRulesByContentsMatchingInput.
2583 if (parsed.tokens[0] === 'xargs' && parsed.tokens.includes('git')) {
2584 return true
2585 }
2586 return false
2587 }
2588 return /^git(?:\s|$)/.test(stripped)
2589}
2590
2591/**
2592 * Checks if a subcommand is a cd command after normalizing away safe wrappers

Callers 2

bashToolHasPermissionFunction · 0.85
commandHasAnyGitFunction · 0.85

Calls 2

stripSafeWrappersFunction · 0.85
tryParseShellCommandFunction · 0.85

Tested by

no test coverage detected