fix: address multi-agent review issues — pool safety, EOF sentinel, ReDoS guard, formatter pool#347
Conversation
…eDoS guard, formatter pool - tokenizer/pool.go: panic with meaningful message instead of silently putting nil into pool when New() fails (A1) - tokenizer/tokenizer.go: return error on unterminated block comment instead of silently consuming to EOF (A2) - parser/parser.go: use tokens[:0] in Reset() to preserve capacity; set zero-value EOF sentinel in advance() when past end of token slice (B1, B2) - parser/select_clauses.go: companion fix for advance() EOF sentinel — parseFromClause now correctly handles both in-slice and past-end positions - errors/builders.go: replace O(n²) string concat with strings.Join (C1) - errors/cache.go: document random eviction trade-off (C2) - formatter/formatter.go: use GetParser()/PutParser() pool instead of allocating a new parser per Format() call (D1) - security/scanner.go: add safeRegexMatch() with 10KB input guard to prevent ReDoS on block comment regex with nested quantifiers (E1) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @ajitpratap0's task —— View job Comprehensive PR Review - Multi-Agent Security and Performance FixesI've completed a thorough review of all 8 changed files. This PR addresses several important issues identified by review agents, implementing targeted fixes for pool safety, parser robustness, performance optimization, and security hardening. ✅ Excellent Changes Implemented1. Tokenizer Pool Safety (A1) -
|
Summary
Fixes confirmed bugs and robustness gaps identified by five review agents (Software Architect, QA, Monkey Testing, UAT, Code Review) across five packages:
sync.PoolNew()now panics with a meaningful message instead of silently insertingnilwhenNew()fails, preventing a confusing nil-pointer panic deep in call stacks/* ...with no closing*/) now returns anUnterminatedStringErrorat the comment start position instead of silently consuming input to EOFReset()usestokens[:0]to preserve pre-allocated capacity;advance()now sets a zero-valueTokenWithSpan{}EOF sentinel instead of leaving a stale token value when past the end of the token sliceparseFromClausecorrectly handles both in-slice and past-end positions after the EOF sentinel changejoinStrings()replaced O(n²) string concatenation loop withstrings.JoinFormat()now usesGetParser()/PutParser()pool instead of allocating a fresh parser on every callsafeRegexMatch()helper truncates input to 10KB before applying the block comment regex (which has nested quantifiers) to bound worst-case ReDoS backtrackingTest plan
go test -race -timeout 120s ./...— all 47 packages pass, zero race conditions🤖 Generated with Claude Code