( cmd: string, )
| 379 | * loaded — caller should fall back to conservative behavior. |
| 380 | */ |
| 381 | export async function parseForSecurity( |
| 382 | cmd: string, |
| 383 | ): Promise<ParseForSecurityResult> { |
| 384 | // parseCommandRaw('') returns null (falsy check), so short-circuit here. |
| 385 | // Don't use .trim() — it strips Unicode whitespace (\u00a0 etc.) which the |
| 386 | // pre-checks in parseForSecurityFromAst need to see and reject. |
| 387 | if (cmd === '') return { kind: 'simple', commands: [] } |
| 388 | const root = await parseCommandRaw(cmd) |
| 389 | return root === null |
| 390 | ? { kind: 'parse-unavailable' } |
| 391 | : parseForSecurityFromAst(cmd, root) |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * Same as parseForSecurity but takes a pre-parsed AST root so callers that |
no test coverage detected