* Creates a regex pattern that matches safe invocations of a command. * * The regex ensures commands are invoked safely by blocking: * - Shell metacharacters that could lead to command injection or redirection * - Command substitution via backticks or $() * - Variable expansion that could conta
(command: string)
| 1510 | * @returns RegExp that matches safe invocations of the command |
| 1511 | */ |
| 1512 | function makeRegexForSafeCommand(command: string): RegExp { |
| 1513 | // Create regex pattern: /^command(?:\s|$)[^<>()$`|{}&;\n\r]*$/ |
| 1514 | return new RegExp(`^${command}(?:\\s|$)[^<>()$\`|{}&;\\n\\r]*$`) |
| 1515 | } |
| 1516 | |
| 1517 | // Simple commands that are safe for execution (converted to regex patterns using makeRegexForSafeCommand) |
| 1518 | // WARNING: If you are adding new commands here, be very careful to ensure |
nothing calls this directly
no outgoing calls
no test coverage detected