fix: sanitize SQL string interpolation in timeline-db WHERE clauses - #139
Open
TerminalGravity wants to merge 3 commits into
Open
fix: sanitize SQL string interpolation in timeline-db WHERE clauses#139TerminalGravity wants to merge 3 commits into
TerminalGravity wants to merge 3 commits into
Conversation
…ge, and contracts examples
buildWhereFilter and searchExact were interpolating user-supplied strings directly into SQL WHERE clauses without escaping, allowing potential injection via project, branch, since/until, and search query fields. - Add escapeSqlString() to double single quotes and strip null bytes - Validate event type against known EVENT_TYPES enum - Replace raw interpolation in searchExact with escapeSqlString - Add 6 unit tests for escapeSqlString
TerminalGravity
commented
Mar 7, 2026
TerminalGravity
left a comment
Collaborator
Author
There was a problem hiding this comment.
Reviewed — this is solid. The escapeSqlString helper with null byte stripping + quote doubling handles the key injection vectors. Type validation via enum whitelist is the right call. Tests cover the edge cases well. If LanceDB ever supports parameterized queries we should migrate, but this is good to merge now. 🚢
Collaborator
Author
|
Reviewed — SQL injection fix is solid. Escaping with doubled single-quotes plus enum validation for event types covers the attack surface. Tests are thorough. Merging. |
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.
Problem
buildWhereFilterandsearchExactintimeline-db.tsinterpolated user-supplied strings directly into SQL WHERE clauses without escaping. A crafted project name, branch, or search query containing single quotes could break queries or inject arbitrary SQL.Fix
escapeSqlString()— doubles single quotes, strips null bytesisValidEventType()— validates type field against theEVENT_TYPESenum instead of trusting the inputbuildWhereFilterandsearchExactTests
All 49 tests pass.