github-advanced-security[bot] commented on code in PR #18173:
URL: https://github.com/apache/druid/pull/18173#discussion_r2167053656


##########
sql/src/test/java/org/apache/druid/quidem/DruidQuidemTestBase.java:
##########
@@ -112,30 +120,92 @@
 
   public DruidQuidemTestBase(DruidQuidemRunner druidQuidemRunner)
   {
-    this.filterStr = System.getProperty(PROPERTY_FILTER, null);
-    this.filterMatcher = buildFilterMatcher(filterStr);
+    String filterStr = Strings.emptyToNull(System.getProperty(PROPERTY_FILTER, 
null));
+    String splitStr = Strings.emptyToNull(System.getProperty(PROPERTY_SPLIT, 
null));
+    this.filterMatcher = buildFilterMatcher(filterStr, splitStr);
     this.druidQuidemRunner = druidQuidemRunner;
   }
 
-  private static PathMatcher buildFilterMatcher(@Nullable String filterStr)
+  private PathMatcher buildFilterMatcher(String filterStr, String splitStr)
+  {
+    if (filterStr != null && splitStr != null) {
+      throw new IAE(
+          "Cannot configure multiple filter methods with properties: %s and 
%s.", PROPERTY_FILTER, PROPERTY_SPLIT
+      );
+    }
+    if (filterStr != null) {
+      return new IQPathMatcher(filterStr);
+    }
+    if (splitStr != null) {
+      return new QuidemSplitPathMatcher(splitStr);
+    }
+    return TrueFileFilter.INSTANCE;
+  }
+
+  static class QuidemSplitPathMatcher implements PathMatcher
+  {
+    private final int splitIndex;
+    private final int splitCount;
+
+    public QuidemSplitPathMatcher(String splitStr)
+    {
+      Pattern pattern = Pattern.compile("^([0-9]+)/([0-9]+)$");
+      Matcher m = pattern.matcher(splitStr);
+      if (!m.matches()) {
+        throw DruidException.defensive("Invalid split pattern; must match 
pattern [%s]", pattern);
+      }
+      splitIndex = Integer.parseInt(m.group(1));

Review Comment:
   ## Missing catch of NumberFormatException
   
   Potential uncaught 'java.lang.NumberFormatException'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/9270)



##########
sql/src/test/java/org/apache/druid/quidem/DruidQuidemTestBase.java:
##########
@@ -112,30 +120,92 @@
 
   public DruidQuidemTestBase(DruidQuidemRunner druidQuidemRunner)
   {
-    this.filterStr = System.getProperty(PROPERTY_FILTER, null);
-    this.filterMatcher = buildFilterMatcher(filterStr);
+    String filterStr = Strings.emptyToNull(System.getProperty(PROPERTY_FILTER, 
null));
+    String splitStr = Strings.emptyToNull(System.getProperty(PROPERTY_SPLIT, 
null));
+    this.filterMatcher = buildFilterMatcher(filterStr, splitStr);
     this.druidQuidemRunner = druidQuidemRunner;
   }
 
-  private static PathMatcher buildFilterMatcher(@Nullable String filterStr)
+  private PathMatcher buildFilterMatcher(String filterStr, String splitStr)
+  {
+    if (filterStr != null && splitStr != null) {
+      throw new IAE(
+          "Cannot configure multiple filter methods with properties: %s and 
%s.", PROPERTY_FILTER, PROPERTY_SPLIT
+      );
+    }
+    if (filterStr != null) {
+      return new IQPathMatcher(filterStr);
+    }
+    if (splitStr != null) {
+      return new QuidemSplitPathMatcher(splitStr);
+    }
+    return TrueFileFilter.INSTANCE;
+  }
+
+  static class QuidemSplitPathMatcher implements PathMatcher
+  {
+    private final int splitIndex;
+    private final int splitCount;
+
+    public QuidemSplitPathMatcher(String splitStr)
+    {
+      Pattern pattern = Pattern.compile("^([0-9]+)/([0-9]+)$");
+      Matcher m = pattern.matcher(splitStr);
+      if (!m.matches()) {
+        throw DruidException.defensive("Invalid split pattern; must match 
pattern [%s]", pattern);
+      }
+      splitIndex = Integer.parseInt(m.group(1));
+      splitCount = Integer.parseInt(m.group(2));

Review Comment:
   ## Missing catch of NumberFormatException
   
   Potential uncaught 'java.lang.NumberFormatException'.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/9271)



-- 
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