Repository navigation
fix(query): tighten function name and cast type parsing in the AST - #14866
Conversation
Func and Cast nodes now only accept names and types that match the identifier and type grammar the builders already enforce for selectCast, so the parser, builder and hand-built trees agree. toAst() now throws UnsupportedException for filter methods it does not model, matching build(), instead of emitting a Raw node. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
This PR hardens the query DSL against injection through function names and cast types: AST constructors now validate identifiers before serialization, and unsupported filter expressions are rejected instead of silently emitting raw SQL.
One low-severity regex-anchoring nit was found; otherwise the fix is sound and all legitimate call paths were traced as unaffected. Reviewed commit: e33df0b |
🟢 Tier S · Ready to mergeThe PR hardens AST function-name and cast-type validation, rejects unsupported filter methods during AST conversion, and adds regression coverage for these cases. The latest changes centralize identifier/type checks in a shared grammar utility and cover whitespace edge cases and multi-word cast types. Latest changes: The newest commits replace the AST nodes’ duplicated regex checks with shared Grammar validators and add cases for trailing whitespace and valid multi-word cast types.
📂 Walkthrough · 5
🔇 Filtered out · 1Findings Hansi considered but did not post.
Merged |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
AGENTS.md disallows regex validation, so Func and Cast now check names and types with strspn and string functions through a shared Grammar class. The accepted grammar is unchanged except that a trailing newline is now rejected: the previous pattern's `$` anchor matched before a final "\n", so "NOW\n" was accepted as a function name and "INT\n" as a cast type. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…iers fix(query): tighten function name and cast type parsing in the AST (cherry picked from commit f7f087f)
What does this PR do?
Func and Cast nodes now only accept names and types that match the identifier and type grammar the builders already enforce for selectCast, so the parser, builder and hand-built trees agree. toAst() now throws UnsupportedException for filter methods it does not model, matching build(), instead of emitting a Raw node.
Test Plan
composer test in packages/query (5578 tests, 8 new regression tests). bin/monorepo check query (Rector, Pint, PHPStan) is clean.
Related PRs and Issues
Checklist
🤖 Generated with Claude Code