Bug fix: Enhanced SQL statement validation with word boundary matching #2324
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.
Enhanced SQL statement validation to handle disallowed keywords appearing as substrings. Introduced regular expression-based word boundary matching to accurately detect whole-word occurrences of disallowed operations, preventing potential misinterpretations and unintended false positives.
Issue #, if available:
#2323
Description of changes:
customConnectorVerifications
method in theDDBQueryPassthrough
class.contains
check to detect disallowed keywords.java.util.regex.Matcher
class to perform word boundary matching.\\w+
) to match one or more word characters.Matcher
.AthenaConnectorException
is thrown with the appropriate error message and error code.SELECT * from xyupdatez
" are correctly identified as valid SELECT statements, even though they contain the substring "UPDATE" within an identifier.In summary: The proposed solution introduces regular expression-based word boundary matching to accurately identify whole-word occurrences of disallowed operations, thereby improving the correctness and accuracy of the validation process. This change ensures that valid SELECT statements are not incorrectly rejected, preventing potential issues or unintended behavior.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.