suvodeep-pyne commented on code in PR #16723:
URL: https://github.com/apache/pinot/pull/16723#discussion_r2317170447


##########
pinot-common/src/main/java/org/apache/pinot/common/audit/AuditUrlPathFilter.java:
##########
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.audit;
+
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+import java.nio.file.PathMatcher;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import javax.inject.Singleton;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * URL path filter utility that uses Java's PathMatcher with glob patterns
+ * to determine if a URL path should be excluded from processing.
+ *
+ * This class provides powerful pattern matching capabilities including:
+ * - Wildcards: * (within path segment), ** (across path segments), ? (single 
character)
+ * - Character sets: [abc], [a-z], [!abc]
+ * - Grouping: {api,v1,v2}
+ *
+ * Examples:
+ * - health - exact match
+ * - api/* - matches api/users but not api/v1/users
+ * - api/** - matches api/users and api/v1/users
+ * - api/v[12]/users - matches api/v1/users and api/v2/users
+ * - api/{users,groups}/list - matches api/users/list and api/groups/list
+ */
+@Singleton
+public class AuditUrlPathFilter {
+  private static final Logger LOG = 
LoggerFactory.getLogger(AuditUrlPathFilter.class);
+  private static final String PREFIX_GLOB = "glob:";
+  private static final String PREFIX_REGEX = "regex:";
+
+  private static boolean testPattern(Path path, String pattern) {
+    try {
+      String globPattern = pattern;
+      if (!globPattern.startsWith(PREFIX_GLOB) && 
!globPattern.startsWith(PREFIX_REGEX)) {

Review Comment:
   yeah. regex is a big overkill for this. most systems offer basic rules and 
that is the standard. Here, we are just leveraging path matcher which has been 
out there and supports a lot of features. So, this will just expose that. glob 
is the default, but if someone really wants regex. that option stays accessible 
behind a more verbose syntax.



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