MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / isHelpCommand

Function isHelpCommand

source code/utils/bash/commands.ts:390–438  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

388 * @returns true if it's a help command, false otherwise
389 */
390export function isHelpCommand(command: string): boolean {
391 const trimmed = command.trim()
392
393 // Check if command ends with --help
394 if (!trimmed.endsWith('--help')) {
395 return false
396 }
397
398 // Reject commands with quotes, as they might be trying to bypass restrictions
399 if (trimmed.includes('"') || trimmed.includes("'")) {
400 return false
401 }
402
403 // Parse the command to check for other flags
404 const parseResult = tryParseShellCommand(trimmed)
405 if (!parseResult.success) {
406 return false
407 }
408
409 const tokens = parseResult.tokens
410 let foundHelp = false
411
412 // Only allow alphanumeric tokens (besides --help)
413 const alphanumericPattern = /^[a-zA-Z0-9]+$/
414
415 for (const token of tokens) {
416 if (typeof token === 'string') {
417 // Check if this token is a flag (starts with -)
418 if (token.startsWith('-')) {
419 // Only allow --help
420 if (token === '--help') {
421 foundHelp = true
422 } else {
423 // Found another flag, not a simple help command
424 return false
425 }
426 } else {
427 // Non-flag token - must be alphanumeric only
428 // Reject paths, special characters, etc.
429 if (!alphanumericPattern.test(token)) {
430 return false
431 }
432 }
433 }
434 }
435
436 // If we found a help flag and no other flags, it's a help command
437 return foundHelp
438}
439
440const BASH_POLICY_SPEC = `<policy_spec>
441# Claude Code Code Bash command prefix detection

Callers 1

commands.tsFile · 0.85

Calls 1

tryParseShellCommandFunction · 0.85

Tested by

no test coverage detected