Repository navigation
fix(security,cbinding): scan raw-text statements, recover from panics in C exports - #871
Conversation
… in C exports - Scanner.Scan(tree) scans standalone VALUES and statements the parser keeps as text (utility, SET, transaction, USE, unsupported, T-SQL blocks, PREPARE/EXECUTE, CREATE POLICY/TRIGGER) with the ScanSQL rules, so payloads such as VALUES (SLEEP(5)) and IF 1=1 WAITFOR DELAY are reported; no finding is reported twice. - Every C-binding export recovers from a panic and returns its normal error result with a fixed message instead of crashing the host. - DialectExtras()/DialectModifiers() read accessors return values, so the shared zero-value stand-ins can no longer be mutated through them; EnsureExtras() stays the mutable path. No new allocations. - tokscratch panics with a clear message when the tokenizer is not linked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ajitpratap0's task in 20s —— View job Review of PR #871I read the diff for the scanner, C binding recovery, Scanner (
C binding (
AST accessors (
Tests
Verdict: Approve-worthy once you decide on the "shallow copy" doc wording. The other points are optional. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 19s —— View job Review of PR #871I read the diffs for Scanner (
C binding (
AST accessors (
Tests
Verdict: No blockers. I'd fix the "shallow copy" wording and the fixture regeneration note before merging. The other points are optional. |
Summary
Follow-ups from the pre-merge security and AST reviews of #866–#868:
Scanner.Scan(tree)now sees newly parseable statements. StandaloneVALUESand every statement the parser keeps as raw text go through theScanSQLrules: utility,SET, transaction,USE, unsupported, T-SQLIF/WHILE/BEGINbodies,PREPARE/EXECUTE,CREATE POLICY/TRIGGER.VALUES (SLEEP(5))andIF 1=1 WAITFOR DELAY '0:0:5'are now reported as TIME_BASED. Each statement takes exactly one path, so nothing is reported twice.//exportrecovers from a panic and returns its normal error result with a fixed message. A panic can no longer crash the host process, and panic values (which may contain SQL or paths) are not exposed.DialectExtras()/DialectModifiers()return values instead of pointers to shared zero values, so a caller can no longer mutate every node through them.EnsureExtras()remains the mutable path. These accessors are unreleased, so the signature change is safe.internal/tokscratchpanics with a clear message if the tokenizer isn't linked.Test Plan
gofmt,go vet,golangci-lint run(0 issues),task test:race,task test:cbindingScanSQLproduced is preserved, andScan(tree)now matchesScanSQLon the newly parseable statementsBenchmarkRealWorldParseFormatvs main, 4 interleaved runs: median 9.68 vs 9.63 ms/op, same B/op and allocs/opBreaking Changes
DialectExtras()/DialectModifiers()now return values (SelectExtras,FunctionExtras,BinaryExtras,InsertDialectFields,DMLTargetFields,TableModifiers) instead of pointers. These were added after v1.16.0 and are unreleased.🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2