Gabriel39 commented on code in PR #71414:
URL: https://github.com/apache/doris/pull/71414#discussion_r4796383369


##########
fe/fe-core/src/main/java/org/apache/doris/connector/CatalogEndpointSecurity.java:
##########
@@ -0,0 +1,132 @@
+// 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.doris.connector;
+
+import org.apache.doris.cloud.security.SecurityChecker;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.connector.spi.ConnectorSecuritySurface;
+
+import com.google.common.net.HostAndPort;
+import okhttp3.HttpUrl;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/** Standalone endpoint admission; callers supply the provider's effective, 
detached security surface. */
+public final class CatalogEndpointSecurity {
+    private CatalogEndpointSecurity() {
+    }
+
+    /**
+     * Checks every active destination using the installed policy. This 
utility does not initialize a
+     * connector, mutate a catalog, interpret storage properties, or guard 
subsequent SDK requests.
+     */
+    public static void validate(String catalogName, ConnectorSecuritySurface 
surface, Map<String, String> properties)
+            throws DdlException {
+        validate(catalogName, surface, properties, 
SecurityChecker.getInstance());
+    }
+
+    static void validate(String catalogName, ConnectorSecuritySurface surface, 
Map<String, String> properties,
+            SecurityChecker checker) throws DdlException {
+        if (!checker.isEnabled()) {
+            return;
+        }
+        Set<HostAndPort> destinations = new LinkedHashSet<>();
+        for (String key : surface.ssrfEndpointKeys()) {
+            List<String> values = surface.ssrfEndpointValues(key, 
properties.get(key));
+            // Projections already name individual destinations; list syntax 
belongs to the raw property only.
+            boolean splitRawValues = surface.isCommaSeparatedSsrfEndpoint(key)
+                    && !surface.hasSsrfEndpointValueOverride(key);
+            for (String value : values) {
+                if (value.trim().isEmpty()) {
+                    continue;
+                }
+                if (value.contains("${")) {
+                    throw new DdlException("Endpoint property '" + key + "' 
must be literal under the SSRF policy");
+                }
+                String[] endpoints = splitRawValues
+                        ? value.split(",", -1) : new String[] {value};
+                for (String endpoint : endpoints) {
+                    try {
+                        destinations.add(parseEndpoint(endpoint.trim(),

Review Comment:
   Fixed in f64076dc1286. Parsed DNS names and address hex are normalized with 
Locale.ROOT before deduplication; the complete IPv6 scope suffix keeps its 
case. The mixed-case alias and scoped IPv6 cases both fail without the fix and 
pass with it. The standard FE matrix passes all 156 cases, and the FE build and 
strict Checkstyle pass.



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