fix: sanitize SQL identifiers in TimescaleDB tool and SQLite schema#65
Merged
Conversation
Member
Author
|
LGTM - Comprehensive SQL injection fixes. Note: PR contains commits from fix+timescale-sql-injection (PR #63) as base. Good coverage of policy.go, metadata.go, timeseries.go, and schema.go. |
- Add sanitizeIdentifier() and sanitizeStringLiteral() helpers to timescale_tool.go - Fix buildCreateHypertableSQL() to use proper identifier sanitization: - table and timeColumn are identifiers (not string literals) - chunkTimeInterval is a string literal (use sanitizeStringLiteral) - partitioningColumn is an identifier - Fix PRAGMA table_info() in SQLite schema to use sanitizeIdentifier() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…meseries - Add sanitization helpers to hypertable.go (shared across package) - Fix policy.go: ALTER TABLE, add_compression_policy, add_retention_policy, compress_chunks, decompress_chunks, and related queries - Fix metadata.go: generateStoredSchema CREATE HYPERTABLE and policy statements - Fix timeseries.go: WindowFunction alias field Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81a5e53 to
45752d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sanitizeIdentifier()andsanitizeStringLiteral()helpers totimescale_tool.gobuildCreateHypertableSQL()to use proper identifier sanitization:tableandtimeColumnare identifiers (not string literals), usesanitizeIdentifier()without quoteschunkTimeIntervalis a string literal, usesanitizeStringLiteral()partitioningColumnis an identifier, usesanitizeIdentifier()without quotesPRAGMA table_info()in SQLite schema to usesanitizeIdentifier()Test plan
create_hypertablewith various table/column namesGetColumnswith various table names🤖 Generated with Claude Code