(command: string)
| 201 | } |
| 202 | |
| 203 | export function stripShellWrapper(command: string): string { |
| 204 | const pattern = /^\s*(?:sh|bash|zsh|cmd.exe)\s+(?:\/c|-c)\s+/; |
| 205 | const match = command.match(pattern); |
| 206 | if (match) { |
| 207 | let newCommand = command.substring(match[0].length).trim(); |
| 208 | if ( |
| 209 | (newCommand.startsWith('"') && newCommand.endsWith('"')) || |
| 210 | (newCommand.startsWith("'") && newCommand.endsWith("'")) |
| 211 | ) { |
| 212 | newCommand = newCommand.substring(1, newCommand.length - 1); |
| 213 | } |
| 214 | return newCommand; |
| 215 | } |
| 216 | return command.trim(); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Detects command substitution patterns in a shell command, following bash quoting rules: |
no outgoing calls
no test coverage detected