somandal commented on code in PR #16616:
URL: https://github.com/apache/pinot/pull/16616#discussion_r2286823667


##########
pinot-common/src/main/java/org/apache/pinot/common/audit/AuditConfigManager.java:
##########
@@ -0,0 +1,130 @@
+/**
+ * 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.util.HashSet;
+import java.util.Set;
+import javax.inject.Singleton;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Thread-safe configuration manager for audit logging settings.
+ * Handles dynamic configuration updates from cluster configuration changes.
+ * Self-registers with the provided cluster config provider.
+ */
+@Singleton
+public final class AuditConfigManager {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(AuditConfigManager.class);
+
+  private final AuditConfig _currentConfig = new AuditConfig();
+
+  /**
+   * Checks if the given endpoint should be excluded from audit logging.
+   * Supports simple wildcard matching with '*' character.
+   */
+  public static boolean isEndpointExcluded(String endpoint, String 
excludedEndpointsString) {
+    if (StringUtils.isBlank(endpoint) || 
StringUtils.isBlank(excludedEndpointsString)) {
+      return false;
+    }
+
+    Set<String> excludedEndpoints = 
parseExcludedEndpoints(excludedEndpointsString);
+    if (excludedEndpoints.isEmpty()) {
+      return false;
+    }
+
+    // Check for exact matches first
+    if (excludedEndpoints.contains(endpoint)) {
+      return true;
+    }
+
+    // Check for wildcard matches
+    for (String excluded : excludedEndpoints) {
+      if (excluded.contains("*")) {
+        if (matchesWildcard(endpoint, excluded)) {
+          return true;
+        }
+      }
+    }
+
+    return false;
+  }
+
+  private static Set<String> parseExcludedEndpoints(String 
excludedEndpointsString) {
+    Set<String> excludedEndpoints = new HashSet<>();
+    if (StringUtils.isNotBlank(excludedEndpointsString)) {
+      String[] endpoints = excludedEndpointsString.split(",");
+      for (String endpoint : endpoints) {
+        String trimmed = endpoint.trim();
+        if (StringUtils.isNotBlank(trimmed)) {
+          excludedEndpoints.add(trimmed);
+        }
+      }
+    }
+    return excludedEndpoints;
+  }
+
+  private static boolean matchesWildcard(String endpoint, String pattern) {

Review Comment:
   yeah sure, feel free to address as a future change depending on how the 
requirements evolve. even just keeping it simple is fine, as long as the 
limitations are well documented 



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