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

Function validateJqCommand

source code/tools/BashTool/bashSecurity.ts:744–783  ·  view source on GitHub ↗
(context: ValidationContext)

Source from the content-addressed store, hash-verified

742}
743
744function validateJqCommand(context: ValidationContext): PermissionResult {
745 const { originalCommand, baseCommand } = context
746
747 if (baseCommand !== 'jq') {
748 return { behavior: 'passthrough', message: 'Not jq' }
749 }
750
751 if (/\bsystem\s*\(/.test(originalCommand)) {
752 logEvent('tengu_bash_security_check_triggered', {
753 checkId: BASH_SECURITY_CHECK_IDS.JQ_SYSTEM_FUNCTION,
754 subId: 1,
755 })
756 return {
757 behavior: 'ask',
758 message:
759 'jq command contains system() function which executes arbitrary commands',
760 }
761 }
762
763 // File arguments are now allowed - they will be validated by path validation in readOnlyValidation.ts
764 // Only block dangerous flags that could read files into jq variables
765 const afterJq = originalCommand.substring(3).trim()
766 if (
767 /(?:^|\s)(?:-f\b|--from-file|--rawfile|--slurpfile|-L\b|--library-path)/.test(
768 afterJq,
769 )
770 ) {
771 logEvent('tengu_bash_security_check_triggered', {
772 checkId: BASH_SECURITY_CHECK_IDS.JQ_FILE_ARGUMENTS,
773 subId: 1,
774 })
775 return {
776 behavior: 'ask',
777 message:
778 'jq command contains dangerous flags that could execute code or read arbitrary files',
779 }
780 }
781
782 return { behavior: 'passthrough', message: 'jq command is safe' }
783}
784
785function validateShellMetacharacters(
786 context: ValidationContext,

Callers

nothing calls this directly

Calls 1

logEventFunction · 0.85

Tested by

no test coverage detected