Replace SQL string concatenation with a PreparedStatement
ProprietaryRewrites JDBC Statement.executeQuery/executeUpdate/execute/addBatch calls whose argument is a string concatenation built from a literal SQL prefix plus simple variable operands into a PreparedStatement with ? placeholders and setX(i, ...) bindings. Only fixes the narrow safe subset where the Statement is a local variable from Connection.createStatement() used for a single SQL execution; other cases are left for the FindSqlInjection recipe to surface.
org. openrewrite. java. security. FixSqlInjectionConcatmod run . --recipe= org. openrewrite. java. security. FixSqlInjectionConcatInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.