fix: sanitize SQL filter inputs in timeline-db to prevent injection - #234
Open
TerminalGravity wants to merge 1 commit into
Open
fix: sanitize SQL filter inputs in timeline-db to prevent injection#234TerminalGravity wants to merge 1 commit into
TerminalGravity wants to merge 1 commit into
Conversation
- Add escapeSQL() for string literal sanitization in buildWhereFilter - Validate event types against EVENT_TYPES whitelist - Validate timestamps with ISO-8601 regex before interpolation - Export helpers for testability - Add 17 tests covering all filter sanitization paths Previously, buildWhereFilter interpolated user-supplied project, branch, type, and timestamp values directly into SQL WHERE clauses without escaping. A crafted project path or branch name containing single quotes could break out of the string literal.
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.
What
buildWhereFilterandsearchExactintimeline-db.tsinterpolated user-supplied values (project paths, branch names, timestamps, event types) directly into SQL WHERE clauses without proper sanitization.Fix
escapeSQL()— escapes single quotes in string literals (project, branch)isValidEventType()— whitelist validation againstEVENT_TYPESisValidTimestamp()— regex validation for ISO-8601 formatTests
17 new tests covering all sanitization paths — escaping, validation, filter composition, and rejection of malicious inputs.
All 60 tests pass ✅