Jackie-Jiang commented on code in PR #19235:
URL: https://github.com/apache/pinot/pull/19235#discussion_r4623059466


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableConfigValidationUtils.java:
##########
@@ -80,6 +82,23 @@ public static EnumSet<ValidationType> 
parseValidationTypesToSkip(@Nullable Strin
     }
   }
 
+  /// Rejects legacy FieldSpec Groovy transforms before schema validation can 
compile them.
+  @SuppressWarnings("deprecation") // FieldSpec transforms remain supported in 
stored schemas.
+  static void validateSchemaGroovy(Schema schema, ControllerConf 
controllerConf) {
+    if (controllerConf.isDisableIngestionGroovy()) {
+      String groovyPrefix = 
GroovyFunctionEvaluator.getGroovyExpressionPrefix() + "(";
+      for (FieldSpec fieldSpec : schema.getAllFieldSpecs()) {
+        String transformFunction = fieldSpec.getTransformFunction();
+        if (transformFunction != null
+            && transformFunction.regionMatches(true, 0, groovyPrefix, 0, 
groovyPrefix.length())) {

Review Comment:
   [P1] Block implicit Groovy transforms before compilation
   
   With ingestion Groovy disabled, a schema field named `attrs__KEYS` with 
`dataType: "STRING"`, `transformFunction: ""`, and a nonempty 
`virtualColumnProvider` passes this guard. Virtual fields skip 
`SchemaUtils.validateIngestionTransformVolatility()`, but 
`SchemaUtils.validate()` subsequently requests an evaluator for the non-null 
empty transform. `FunctionEvaluatorFactory.getExpressionEvaluator(FieldSpec)` 
treats the empty expression as absent and synthesizes 
`Groovy({attrs.sort()*.key}, attrs)` for the map suffix. Thus 
`/schemas/validate` still reaches the Groovy compiler despite the disabled 
policy, with the user-controlled column-name prefix interpolated into the 
generated script.
   
   Please cover the implicit `__KEYS`/`__VALUES` paths before evaluator 
construction, or prevent schema validation from constructing these fallback 
evaluators for empty transforms, and add a regression test for this case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to