Skip to content

fix: sanitize SQL identifiers in TimescaleDB tool and SQLite schema#65

Merged
linhdmn merged 2 commits into
mainfrom
fix+more-sql-injection
Apr 19, 2026
Merged

fix: sanitize SQL identifiers in TimescaleDB tool and SQLite schema#65
linhdmn merged 2 commits into
mainfrom
fix+more-sql-injection

Conversation

@linhdmn
Copy link
Copy Markdown
Member

@linhdmn linhdmn commented Apr 18, 2026

Summary

  • Add sanitizeIdentifier() and sanitizeStringLiteral() helpers to timescale_tool.go
  • Fix buildCreateHypertableSQL() to use proper identifier sanitization:
    • table and timeColumn are identifiers (not string literals), use sanitizeIdentifier() without quotes
    • chunkTimeInterval is a string literal, use sanitizeStringLiteral()
    • partitioningColumn is an identifier, use sanitizeIdentifier() without quotes
  • Fix PRAGMA table_info() in SQLite schema to use sanitizeIdentifier()

Test plan

  • Build passes
  • golangci-lint passes
  • Test TimescaleDB create_hypertable with various table/column names
  • Test SQLite GetColumns with various table names

🤖 Generated with Claude Code

@linhdmn
Copy link
Copy Markdown
Member Author

linhdmn commented Apr 18, 2026

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.

linhdmn and others added 2 commits April 19, 2026 11:05
- 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>
@linhdmn linhdmn force-pushed the fix+more-sql-injection branch from 81a5e53 to 45752d8 Compare April 19, 2026 04:06
@linhdmn linhdmn merged commit 1b73809 into main Apr 19, 2026
2 of 3 checks passed
@linhdmn linhdmn deleted the fix+more-sql-injection branch April 19, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant