Refactor DatabaseHandler to prevent SQL injection using PreparedStatement#89
Refactor DatabaseHandler to prevent SQL injection using PreparedStatement#89
Conversation
Refactored `DatabaseHandler.execAction` to a new method `execUpdate` that uses `PreparedStatement` to prevent SQL injection. Introduced `SqlHelper` class to encapsulate the `PreparedStatement` logic and allow unit testing without JavaFX dependencies. Updated `MainController` to use `execUpdate` with parameterized queries. Added unit tests for `SqlHelper` using Derby in-memory database. Deprecated `execAction` in `DatabaseHandler`. Co-authored-by: G30RG3-GJ <203693057+G30RG3-GJ@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR addresses the "Raw SQL Execution" code health issue in
DatabaseHandler.java.It replaces the insecure
execActionmethod (which executed raw SQL strings) with a newexecUpdatemethod that usesPreparedStatementand parameterized queries.A new helper class
SqlHelperwas created to implement this logic in a testable way, avoiding the project's tight coupling with JavaFX which makes testing difficult in some environments.MainControllerwas updated to use the new method for Issue, Renew, and Submission operations.Unit tests covering Insert, Update, Delete, and error handling were added in
test/library/assistant/database/SqlHelperTest.java.PR created automatically by Jules for task 15066920583056467580 started by @G30RG3-GJ