All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.codemodder.codemods.SQLParameterizerCodemod.description.md Maven / Gradle / Ivy

The newest version!
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:

```diff
- 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();
```




© 2015 - 2024 Weber Informatics LLC | Privacy Policy