extra ignored test which can output the sql query for a set of scala …#433
Draft
andrew-nowak wants to merge 1 commit into
Draft
extra ignored test which can output the sql query for a set of scala …#433andrew-nowak wants to merge 1 commit into
andrew-nowak wants to merge 1 commit into
Conversation
bryophyta
reviewed
Aug 12, 2025
|
|
||
| // Replace the parameter placeholders with the corresponding values | ||
| // WARNING | ||
| // This is a textbook example of how to get hit by a SQL injection attack - this should be used |
bryophyta
approved these changes
Aug 12, 2025
bryophyta
left a comment
Contributor
There was a problem hiding this comment.
looks great, super useful and very good to have the injection warning documentation too! 🤩
bryophyta
reviewed
Aug 22, 2025
| val matcher = "\\?(?![|?])" | ||
| param match { | ||
| case p: Int => statement.replaceFirst(matcher, s"$p ") | ||
| case p: String => statement.replaceFirst(matcher, s"'$p' ") |
Contributor
There was a problem hiding this comment.
just spotted that this will fail if the param is the name of a column, because that doesn't want to be placed inside 's.
we are currently doing that in some queries (I think here?):
newswires/newswires/app/db/FingerpostWireEntry.scala
Lines 288 to 293 in d00ab66
not sure if it's worth trying to account for this edge case in the code, but thought i'd flag it as something to be aware of for future travellers :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…params
What does this change?
How to test
How can we measure success?
Have we considered potential risks?
Images
Accessibility