microsoft/TypeAgent
Publicmirrored from https://github.com/microsoft/TypeAgentAvailable
Commit
agent-flows: defuse polynomial-regex warnings in catalog/llm parsers
CodeQL flagged three regexes whose adjacent \s*/\s+ and lazy any-char quantifiers could share the same characters during backtracking:
- actionCatalog.ts: schema-header regex \s+(.+)$ could split trailing whitespace many ways. Anchor the capture with (\S.*) so the lead char is forced to be non-whitespace.
- llmResponse.ts: the `json\s*([\s\S]*?)` and `(ts|js|...)?\s*([\s\S]*?)` matchers had \s* adjacent to a lazy [\s\S]*?. Drop the redundant \s* (JSON.parse and the existing .trim() handle the leading whitespace).
Smoke-tested: normal/trailing-whitespace inputs unchanged; 50k-tab pathological inputs now complete in 0-2ms.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>Changed files
2 files listed