Repository navigation
MINOR: Modify logic to use parameterized queries - #24902
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request improves security by converting string interpolation to parameterized SQL queries in the ListFilter class for the alertType and notificationTemplate query parameters. The changes aim to prevent SQL injection vulnerabilities by using JDBI's named parameter binding (:alertType, :notificationTemplate) instead of direct string formatting. Additionally, a new test has been added to verify that SQL injection attempts do not cause internal server errors.
Key Changes
- Replaced
String.format()with parameterized query placeholders in two query-building methods - Added test coverage for SQL injection prevention scenarios
- Both MySQL and PostgreSQL query paths have been updated consistently
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ListFilter.java | Converted getEventSubscriptionAlertType() and getNotificationTemplateCondition() to use parameterized queries (:alertType and :notificationTemplate) instead of string interpolation for both MySQL and PostgreSQL |
| openmetadata-service/src/test/java/org/openmetadata/service/resources/events/EventSubscriptionResourceTest.java | Added test_sqlInjectionPrevention() test with multiple SQL injection attack patterns and verification that valid parameters continue to work |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@ayush-shah I've opened a new pull request, #24903, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * fix: address PR review comments - use JSON_UNQUOTE for MySQL queries and improve test logic Co-authored-by: ayush-shah <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: ayush-shah <[email protected]>
|
|
Changes have been cherry-picked to the 1.11.4 branch. |
(cherry picked from commit ea49233)



This pull request improves the security of query construction in the
ListFilterclass by switching to parameterized SQL queries, which helps prevent SQL injection vulnerabilities. Additionally, it introduces a new test to verify that SQL injection attempts do not cause internal server errors and that valid queries still work as expected.Security improvements to query construction:
ListFilter.javafor bothgetEventSubscriptionAlertType()andgetNotificationTemplateCondition()methods to use parameterized queries (e.g.,:alertType,:notificationTemplate) instead of string interpolation, reducing the risk of SQL injection. [1] [2]Testing for SQL injection prevention:
test_sqlInjectionPreventioninEventSubscriptionResourceTest.javato simulate SQL injection attempts and verify that these do not result in internal server errors, while also confirming that valid parameters return expected results.