Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored to use parameterized SQL APIs #1545

Merged

Conversation

pixeebot[bot]
Copy link
Contributor

@pixeebot pixeebot bot commented Jul 9, 2024

This change refactors SQL statements to be parameterized, rather than built by hand.

Without parameterization, developers must remember to escape inputs using the rules for that database. It's usually buggy, at the least -- and sometimes vulnerable.

Our changes look something like this:

- Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE name = '" + user + "'");
+ PreparedStatement stmt = connection.prepareStatement("SELECT * FROM users WHERE name = ?");
+ stmt.setString(1, user);
+ ResultSet rs = stmt.executeQuery();
More reading

🧚🤖 Powered by Pixeebot

Feedback | Community | Docs | Codemod ID: pixee:java/sql-parameterizer

@pixeebot pixeebot bot requested a review from Frooodle as a code owner July 9, 2024 04:05
@github-actions github-actions bot added the Java Pull requests that update Java code label Jul 9, 2024
@Frooodle Frooodle merged commit b7d37de into main Jul 9, 2024
4 checks passed
@pixeebot pixeebot bot deleted the pixeebot/drip-2024-07-09-pixee-java/sql-parameterizer branch July 9, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java Pull requests that update Java code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant