( context: ValidationContext, )
| 844 | } |
| 845 | |
| 846 | function validateDangerousPatterns( |
| 847 | context: ValidationContext, |
| 848 | ): PermissionResult { |
| 849 | const { unquotedContent } = context |
| 850 | |
| 851 | // Special handling for backticks - check for UNESCAPED backticks only |
| 852 | // Escaped backticks (e.g., \`) are safe and commonly used in SQL commands |
| 853 | if (hasUnescapedChar(unquotedContent, '`')) { |
| 854 | return { |
| 855 | behavior: 'ask', |
| 856 | message: 'Command contains backticks (`) for command substitution', |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | // Other command substitution checks (include double-quoted content) |
| 861 | for (const { pattern, message } of COMMAND_SUBSTITUTION_PATTERNS) { |
| 862 | if (pattern.test(unquotedContent)) { |
| 863 | logEvent('tengu_bash_security_check_triggered', { |
| 864 | checkId: |
| 865 | BASH_SECURITY_CHECK_IDS.DANGEROUS_PATTERNS_COMMAND_SUBSTITUTION, |
| 866 | subId: 1, |
| 867 | }) |
| 868 | return { behavior: 'ask', message: `Command contains ${message}` } |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | return { behavior: 'passthrough', message: 'No dangerous patterns' } |
| 873 | } |
| 874 | |
| 875 | function validateRedirections(context: ValidationContext): PermissionResult { |
| 876 | const { fullyUnquotedContent } = context |
nothing calls this directly
no test coverage detected