MCPcopy Create free account
hub / github.com/freecodexyz/free-code / validateDangerousVariables

Function validateDangerousVariables

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

Source from the content-addressed store, hash-verified

821}
822
823function validateDangerousVariables(
824 context: ValidationContext,
825): PermissionResult {
826 const { fullyUnquotedContent } = context
827
828 if (
829 /[<>|]\s*\$[A-Za-z_]/.test(fullyUnquotedContent) ||
830 /\$[A-Za-z_][A-Za-z0-9_]*\s*[|<>]/.test(fullyUnquotedContent)
831 ) {
832 logEvent('tengu_bash_security_check_triggered', {
833 checkId: BASH_SECURITY_CHECK_IDS.DANGEROUS_VARIABLES,
834 subId: 1,
835 })
836 return {
837 behavior: 'ask',
838 message:
839 'Command contains variables in dangerous contexts (redirections or pipes)',
840 }
841 }
842
843 return { behavior: 'passthrough', message: 'No dangerous variables' }
844}
845
846function validateDangerousPatterns(
847 context: ValidationContext,

Callers

nothing calls this directly

Calls 1

logEventFunction · 0.85

Tested by

no test coverage detected