MCPcopy Create free account
hub / github.com/codeaashu/claude-code / validateSafeCommandSubstitution

Function validateSafeCommandSubstitution

src/tools/BashTool/bashSecurity.ts:585–610  ·  view source on GitHub ↗
(
  context: ValidationContext,
)

Source from the content-addressed store, hash-verified

583}
584
585function validateSafeCommandSubstitution(
586 context: ValidationContext,
587): PermissionResult {
588 const { originalCommand } = context
589
590 if (!HEREDOC_IN_SUBSTITUTION.test(originalCommand)) {
591 return { behavior: 'passthrough', message: 'No heredoc in substitution' }
592 }
593
594 if (isSafeHeredoc(originalCommand)) {
595 return {
596 behavior: 'allow',
597 updatedInput: { command: originalCommand },
598 decisionReason: {
599 type: 'other',
600 reason:
601 'Safe command substitution: cat with quoted/escaped heredoc delimiter',
602 },
603 }
604 }
605
606 return {
607 behavior: 'passthrough',
608 message: 'Command substitution needs validation',
609 }
610}
611
612function validateGitCommit(context: ValidationContext): PermissionResult {
613 const { originalCommand, baseCommand } = context

Callers

nothing calls this directly

Calls 1

isSafeHeredocFunction · 0.85

Tested by

no test coverage detected