-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Parser enhancements batch 3 - Security scanner, lint rules & RETURNING clause #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…TURNING clause This PR adds comprehensive SQL linting rules, integrates the security scanner into the CLI analyzer, and adds RETURNING clause support for DML statements. ## Security Scanner Integration (#154) - Integrated `pkg/sql/security` scanner into CLI's `SQLAnalyzer` - Now detects SQL injection patterns (tautologies, UNION-based, time-based) - Added `convertSecurityFindings()` to map security findings to analysis issues - Security score adjustments based on finding severity ## Phase 1 Lint Rules Complete (#155) Added 7 new lint rules for comprehensive SQL style checking: ### Whitespace Rules - **L003**: Consecutive blank lines detection with auto-fix - **L004**: Indentation depth check (warns on excessive nesting) - **L010**: Redundant whitespace detection (multiple spaces) with auto-fix ### Style Rules - **L006**: SELECT column alignment checking - **L008**: Comma placement consistency (trailing vs leading) - **L009**: Table aliasing consistency detection ### Keyword Rules - **L007**: Keyword case consistency with auto-fix (upper/lowercase) ## RETURNING Clause Support (#159) - Added `TokenTypeReturning` (379) for RETURNING keyword - Parser now supports RETURNING clause for INSERT, UPDATE, DELETE - Added `parseReturningColumns()` for parsing return expressions - Supports: column names, *, qualified names, expressions ## Additional Improvements - Added ALTER TABLE operation keywords (ADD, COLUMN, CONSTRAINT, RENAME, TO) - Extended SQL formatter with `AlterStatement` support - Comprehensive battle tests for all lint rules (50+ test cases) - Fixed L004 bug: depth > 9 now displays correctly in messages ## Test Results - All tests pass with race detection enabled - golangci-lint: 0 issues - 78+ lint-related tests covering edge cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Claude finished @ajitpratap0's task —— View job Code Review CompleteI've completed a comprehensive review of PR #164. This is an excellent contribution that adds significant value to the GoSQLX project. Here's my detailed analysis: Summary AssessmentOverall Grade: A- - High-quality implementation with strong architectural decisions and comprehensive testing. ✅ Strengths1. Excellent Architecture & Design
2. Security Scanner Integration (
|
The Go 1.24 CI jobs were failing because: 1. setup-go installs Go 1.24 2. Go 1.24 sees `toolchain go1.25.0` in go.mod and auto-downloads it 3. setup-go then tries to restore cache with the same toolchain files 4. Cache extraction fails with "Cannot open: File exists" errors Fix by setting GOTOOLCHAIN=local to prevent auto-download, and fail-fast: false to run all matrix combinations even if one fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @ajitpratap0's task —— View job Code Review Complete ✅I've completed a comprehensive review of PR #164. This is a well-implemented contribution that adds significant value to the GoSQLX project. Here's my detailed analysis: Summary AssessmentOverall Grade: A- - High-quality implementation with strong architectural decisions and comprehensive testing. ✅ Strengths1. Excellent Architecture & Design
2. Security Scanner Integration (
|
Summary
This PR delivers three major enhancements to GoSQLX:
Changes
Security Scanner Integration (#154)
pkg/sql/securityscanner into CLI'sSQLAnalyzer.Analyze()method'1'='1'), UNION-based, time-based, out-of-bandconvertSecurityFindings()to map security findings to unifiedAnalysisIssueformatPhase 1 Lint Rules Complete (#155)
Added 7 new lint rules, bringing the total to 10:
New Rule Packages:
pkg/linter/rules/keywords/- Keyword case rule (L007)pkg/linter/rules/style/- Column alignment (L006), comma placement (L008), aliasing (L009)RETURNING Clause Support (#159)
TokenTypeReturning(379) for RETURNING keyword tokenizationINSERT INTO ... RETURNING *UPDATE ... RETURNING id, nameDELETE FROM ... RETURNING *parseReturningColumns()for parsing return expressions*, qualified names (table.column), expressionsAdditional Improvements
*ast.AlterStatementtypeFiles Changed
New Files (8)
pkg/linter/rules/battle_test.go- Comprehensive battle testspkg/linter/rules/keywords/keyword_case.go- L007 rulepkg/linter/rules/style/aliasing_consistency.go- L009 rulepkg/linter/rules/style/column_alignment.go- L006 rulepkg/linter/rules/style/comma_placement.go- L008 rulepkg/linter/rules/whitespace/consecutive_blank_lines.go- L003 rulepkg/linter/rules/whitespace/indentation_depth.go- L004 rulepkg/linter/rules/whitespace/redundant_whitespace.go- L010 ruleModified Files (10)
cmd/gosqlx/cmd/lint.go- Register all 10 rulescmd/gosqlx/cmd/lint_test.go- Updated test expectationscmd/gosqlx/cmd/sql_analyzer.go- Security scanner integrationcmd/gosqlx/cmd/sql_analyzer_test.go- Security integration testscmd/gosqlx/cmd/sql_formatter.go- AlterStatement formattingpkg/models/token_type.go- Added TokenTypeReturningpkg/sql/keywords/keywords.go- RETURNING + ALTER keywordspkg/sql/parser/dml.go- RETURNING clause parsingpkg/sql/parser/parser_targeted_coverage_test.go- Parser testspkg/sql/tokenizer/tokenizer.go- Minor improvementsTest Plan
Manual Testing
🤖 Generated with Claude Code