Repository navigation
fix: validate the arguments of JSON functions in ExpressionValidator - #2952
Merged
manticore-projects merged 1 commit intoNov 23, 2026
Merged
manticore-projects merged 1 commit into
manticore-projects merged 1 commit into
Conversation
Contributor
|
Thank you! |
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.
ExpressionValidator.visit(JsonFunction)andvisit(JsonAggregateFunction)were empty (// no idea what this is good for), so nothing insideJSON_OBJECT,JSON_ARRAY,JSON_VALUE/JSON_QUERY,JSON_ARRAYAGGorJSON_OBJECTAGGwas validated: not the key and value expressions, the aggregate argument, itsFILTER,OVER (PARTITION BY .. ORDER BY ..)or innerORDER BY, nor thePASSINGandON EMPTY/ON ERRORexpressions. WithFeature.functionremoved,SELECT JSON_ARRAY(upper(a)) FROM tvalidated with no errors whileSELECT upper(a) FROM tis rejected, and withFeaturesAllowed.SELECTthe subquery inSELECT JSON_ARRAY((SELECT a FROM t FOR UPDATE))passed while the same subquery in the select list reportsselectForUpdate. A caller that restricts user SQL withValidationcould be bypassed by wrapping the disallowed part in a JSON constructor. I found it by listing theExpressionValidatorvisits that return without looking at their children;ExpressionVisitorAdapteralready walks these sub-expressions, soStatementFeatureVisitorandTablesNamesFinderwere not affected. Both methods now validate the same sub-expressions the adapter walks. The newtestValidateFunctionInJsonFunction(7 cases) andtestValidateSubSelectInJsonFunctionfail before (8 failures) and pass after; theutil.validationtests, spotless, Checkstyle and PMD on main pass. The rest of./gradlew testis unchanged on this Windows machine (the only local failures are 33 Mockito inline-mock-maker init errors and 2 temp-dir access errors, unrelated to this change).