Skip to content

SchemaController: User PreparedStatements where possible #205

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

Merged

Conversation

mureinik
Copy link
Contributor

Use PreparedStatements where possible in the SchemaController in order to avoid SQL Injections.

Note that PreparedSatements can only dynamically bind values and not object names, so this technique could only be applied to the queries, and not the DDL statements. The security around these statements can probably be improved by sanitizing the schema values, but it's out of the scope of this PR.

As a side bonus, this PR also uses the try-with-resource idiom when creating these PreparedStatements and ResultSets so they will be properly closed instead of the current implementation that may leak resources.

Closes #120

Use PreparedStatements where possible in the SchemaController in order
to avoid SQL Injections.

Note that PreparedSatements can only dynamically bind values and not
object names, so this technique could only be applied to the queries,
and not the DDL statements. The security around these statement can
probably be improved by sanitizing the schema values, but it's out of
the scope of this PR.

As a side bonus, this PR also uses the try-with-resource idiom when
creating these PreparedStatements and ResultSets so they will be
properly closed instead of the current implementation that may leak
resources.

Closes operator-framework#120
@adam-sandor
Copy link
Collaborator

Nicely done @mureinik ! thanks for the PR!

@adam-sandor adam-sandor merged commit 85ea247 into operator-framework:master Oct 17, 2020
@mureinik mureinik deleted the mysql-prepared-statements branch October 17, 2020 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MySQL Schema example - JDBC query parameter handling
2 participants