(self, command: str)
| 173 | time.sleep(0.05) |
| 174 | |
| 175 | def _normalize_command(self, command: str) -> str: |
| 176 | command = command.strip() |
| 177 | |
| 178 | if command.startswith("```") and command.endswith("```"): |
| 179 | command = command[3:-3].strip() |
| 180 | if "\n" in command: |
| 181 | first_line, _, rest = command.partition("\n") |
| 182 | if first_line.strip().lower() in {"bash", "sh", "shell", "zsh", "python", "python3"}: |
| 183 | command = rest.strip() |
| 184 | if command.startswith("`") and command.endswith("`"): |
| 185 | command = command[1:-1].strip() |
| 186 | |
| 187 | if "\n" in command: |
| 188 | lines = [line.strip() for line in command.splitlines() if line.strip()] |
| 189 | lines = [line for line in lines if not line.startswith("```")] |
| 190 | if len(lines) == 1: |
| 191 | command = lines[0] |
| 192 | elif lines: |
| 193 | command = " ".join(lines) |
| 194 | |
| 195 | command = self._strip_natural_language_prefixes(command) |
| 196 | |
| 197 | if self._has_unbalanced_quotes(command): |
| 198 | command += self._closing_quotes(command) |
| 199 | |
| 200 | for prefix, message in UNSUPPORTED_MESSAGES.items(): |
| 201 | if prefix in command: |
| 202 | return message |
| 203 | |
| 204 | if "xray" in command and "--poc" in command: |
| 205 | command = self._remove_xray_poc_argument(command) |
| 206 | |
| 207 | return self._rewrite_scanner_command(command) |
| 208 | |
| 209 | @staticmethod |
| 210 | def _looks_like_shell_command(command: str) -> bool: |
no test coverage detected