hello-stephen commented on code in PR #71205:
URL: https://github.com/apache/doris/pull/71205#discussion_r4780752131


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/plugin/PluginDrivenExternalCatalog.java:
##########
@@ -484,6 +363,8 @@ private void checkHiveParquetTimeZone(CatalogProperty 
property) throws DdlExcept
 
     @Override
     public void checkWhenCreating() throws DdlException {
+        // Pre-validation may download drivers or open connections even when 
test_connection is false.
+        checkEndpointsAgainstSsrf(catalogProperty.getProperties());

Review Comment:
   [P2] Probe catalog endpoints once per CREATE
   
   `CatalogFactory.createCatalog` already calls `createCatalogConnector(..., 
true)`, which runs endpoint admission before constructing the provider. 
`finishCatalogCreation` then calls this method and probes the same destinations 
again. The intervening defaults only change cache and compatibility properties 
for the in-tree connectors. With an enabled checker, a permitted but 
unreachable peer can now consume two consecutive five-second connect timeouts 
even with `test_connection=false`. Keep the pre-construction gate for 
interactive CREATE and cover the full factory path with a test that counts 
probes.



##########
fe/fe-core/src/main/java/org/apache/doris/connector/DefaultConnectorContext.java:
##########
@@ -211,9 +211,19 @@ public ConnectorHttpSecurityHook getHttpSecurityHook() {
 
     /** Constructs the root connector under the same ownership boundary used 
by its later siblings. */
     public Connector createCatalogConnector(String catalogType, Map<String, 
String> properties) {
+        return createCatalogConnector(catalogType, properties, true);
+    }
+
+    /** Replay must reconstruct metadata without probing the network; later 
user access is checked again. */
+    public Connector createCatalogConnector(String catalogType, Map<String, 
String> properties,
+            boolean checkEndpoints) {
         try {
-            return cacheOwner.create(() -> 
ConnectorFactory.createStandaloneCatalogConnector(
-                    catalogType, properties, this));
+            return cacheOwner.create(() -> {
+                if (checkEndpoints) {
+                    validateConnectorEndpoints(catalogType, properties);

Review Comment:
   [P2] Keep lazy endpoint probes from stalling ALTER under the catalog manager 
lock
   
   Lazy reconstruction reaches this call from synchronized 
`ExternalCatalog.makeSureInitialized` and holds the catalog monitor through 
every TCP probe. If an ALTER replaces an unavailable endpoint with a healthy 
one while that initialization is in progress, it can finish candidate 
validation, acquire `CatalogMgr`'s global write lock, and then wait for the 
catalog monitor in `resetToUninitialized`. Other catalog operations wait behind 
the old endpoint's timeouts. Keep validation ahead of connector construction 
and avoid waiting for lazy admission under the global lock, for example by 
following the wait-and-recheck pattern already used by `withCatalogForRemoval`.



##########
fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcConnectorProvider.java:
##########
@@ -56,6 +56,9 @@ public ConnectorSecuritySurface securitySurface() {
         // the engine's operator gate applies jdbc_driver_secure_path / the 
mandatory rule on CREATE + ALTER.
         // The engine masks passwords and complete JDBC connection URLs 
wherever it shows catalog properties.
         return ConnectorSecuritySurface.ofJdbcDriverUrls(null, "driver_url", 
"jdbc.driver_url")
-                .withSensitiveKeys(JdbcCatalogProperties.sensitiveKeys());
+                .withSensitiveKeys(JdbcCatalogProperties.sensitiveKeys())
+                // Admission sees the raw map before the property holder 
strips the documented prefix.
+                .withSsrfEndpoints(JdbcCatalogProperties.JDBC_URL,

Review Comment:
   [P2] Admit the effective standalone JDBC URL
   
   `JdbcCatalogProperties.stripJdbcPrefix` gives `jdbc_url` precedence and 
retains the original `jdbc.jdbc_url` key. This declaration probes both, so an 
ALTER that switches a legacy catalog to an allowed canonical URL can still fail 
on the retired alias. The same mismatch affects normalization. 
`JdbcUrlNormalizer` removes ASCII spaces before the client sees a URL, but a 
supported ClickHouse URL with a space before the query separator fails the raw 
`URI.create` call before admission tries the normalized form. Project the 
selected, normalized URL from the standalone provider and keep the raw 
interpretation for metastore consumers that use it.



##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonConnectorProvider.java:
##########
@@ -106,7 +110,61 @@ public ConnectorSecuritySurface securitySurface() {
         // The secrets are those of every metastore flavor: the engine masks 
by key name alone.
         return ConnectorSecuritySurface.ofJdbcDriverUrls(
                 "paimon.catalog.type", "paimon.jdbc.driver_url", 
"jdbc.driver_url")
-                .withSensitiveKeys(MetaStoreProviders.sensitivePropertyKeys());
+                .withSensitiveKeys(MetaStoreProviders.sensitivePropertyKeys())
+                
.withSensitiveKeys(JdbcTlsStoreUrlSecurity.sensitivePropertyKeys("jdbc."))
+                
.withSensitiveKeys(JdbcTlsStoreUrlSecurity.sensitivePropertyKeys("paimon.jdbc."))
+                // The pass-through bearer token is opaque even when its bytes 
look like an HTTP URL.
+                .withSensitiveKeys("paimon.rest.token")
+                // REST token providers also perform HTTP calls; checking only 
the catalog URI misses them.
+                .withSsrfEndpoints("paimon.rest.uri", "uri", 
"paimon.rest.dlf.token-ecs-metadata-url",
+                        "hive.metastore.uris", "metastore.thrift.uris", 
"paimon.jdbc.uri")
+                .withSsrfEndpoints("paimon.rest.dlf.oss-endpoint", 
"dlf.endpoint", "dlf.catalog.endpoint")

Review Comment:
   [P2] Preserve hostname-only Paimon DLF endpoints
   
   The shared DLF holder accepts bare `dlf.endpoint` and `dlf.catalog.endpoint` 
hostnames and passes them to the same HTTPS DLF proxy used by Hive. Here both 
aliases get the unspecified port, so enabled admission rejects a valid 
hostname-only endpoint before the connector starts. Hive and Iceberg already 
declare port 443 for these keys. Give the Paimon DLF aliases the same default 
and exercise a hostname-only CREATE and ALTER with a recording checker.



##########
fe/fe-connector/fe-connector-fluss/src/main/java/org/apache/doris/connector/fluss/FlussConnectorProvider.java:
##########
@@ -51,16 +56,79 @@ public Connector create(Map<String, String> properties, 
ConnectorContext context
     }
 
     /**
-     * The fluss client's SASL credentials, a small and stable set of keys, 
and the lake options under
-     * {@link FlussCatalogProperties#LAKE_OPTION_PREFIX}: those are open-ended 
(new paimon / filesystem
+     * The fluss client's SASL and direct gateway REST credentials use stable 
keys. Lake options under
+     * {@link FlussCatalogProperties#LAKE_OPTION_PREFIX} are open-ended (new 
paimon / filesystem
      * credential names may arrive without a Doris release), so a lake option 
is a secret when its name
      * carries a credential-like word, and endpoints and other operational 
settings stay visible.
      */
     @Override
     public ConnectorSecuritySurface securitySurface() {
+        return 
baseSecuritySurface().withSsrfEndpointPrefixes(FlussCatalogProperties.LAKE_OPTION_PREFIX);
+    }
+
+    private static ConnectorSecuritySurface baseSecuritySurface() {
         return 
ConnectorSecuritySurface.ofSensitiveKeys("fluss.client.security.sasl.username",
                         "fluss.client.security.sasl.password", 
"fluss.client.security.sasl.jaas.config")
+                // Direct gateway REST options reach the sibling through a 
separate namespace on first lake access.
+                .withSsrfEndpointPrefixes("paimon.rest.")
+                .withSensitiveKeys("paimon.rest.token", 
"paimon.rest.dlf.access-key-id",
+                        "paimon.rest.dlf.access-key-secret")
+                .withSsrfEndpoints(FlussCatalogProperties.BOOTSTRAP_SERVERS)
+                .withSsrfEndpoints(FlussCatalogProperties.LAKE_OPTION_PREFIX + 
"hive.metastore.uris",
+                        FlussCatalogProperties.LAKE_OPTION_PREFIX + 
"metastore.thrift.uris")
                 
.withSensitiveKeyPrefix(FlussCatalogProperties.LAKE_OPTION_PREFIX,
                         "key", "secret", "password", "token", "credential");
     }
+
+    @Override
+    public ConnectorSecuritySurface securitySurface(Map<String, String> 
properties) {
+        ConnectorSecuritySurface base = baseSecuritySurface();
+        ConnectorSecuritySurface surface = base;
+        Map<String, String> lake = 
FlussCatalogProperties.extractLakeOverrides(properties);
+        Map<String, String> context = new HashMap<>(properties);
+        context.putAll(lake);
+        // The storage sibling binds canonical names after translating Hadoop 
lake aliases.
+        Map<String, String> storage = 
LakeStorageOptions.toStorageProperties(lake);
+        context.putAll(storage);

Review Comment:
   [P2] Use Fluss's runtime storage precedence during admission
   
   `FlussConnector.deriveStorageProperties` returns lake settings as defaults, 
and `CatalogProperty.mergeDerivedStorageDefaults` preserves an exact key 
supplied directly by the catalog. Here the translated lake map overwrites it. 
With different direct and nested `s3.region` values and no explicit S3 
endpoint, admission can reject the inactive nested region's derived service 
even though the filesystem binds the direct region. Apply the runtime merge 
rule and add a recording-checker test for conflicting direct and nested regions.



##########
fe/fe-core/src/main/java/org/apache/doris/connector/CatalogEndpointSecurity.java:
##########
@@ -0,0 +1,388 @@
+// 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.common.util.DatasourcePrintableMap;
+import org.apache.doris.common.util.DebugPointUtil;
+import org.apache.doris.common.util.DebugPointUtil.DebugPoint;
+import org.apache.doris.connector.spi.ConnectorSecuritySurface;
+import org.apache.doris.filesystem.properties.HdfsEndpointProperties;
+import org.apache.doris.filesystem.properties.StorageEndpointProperties;
+
+import com.google.common.net.HostAndPort;
+import com.google.common.net.InetAddresses;
+import okhttp3.HttpUrl;
+
+import java.net.IDN;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/** Shared endpoint admission for root and indirectly created catalog 
connectors. */
+public final class CatalogEndpointSecurity {
+    private static final String REJECT_HOST_POINT = 
"CatalogEndpointSecurity.reject_host";
+
+    private CatalogEndpointSecurity() {
+    }
+
+    public static boolean isEnabled() {
+        return SecurityChecker.getInstance().isEnabled() || 
DebugPointUtil.isEnable(REJECT_HOST_POINT);
+    }
+
+    public static void validate(String catalogName, ConnectorSecuritySurface 
surface, Map<String, String> properties)
+            throws DdlException {
+        SecurityChecker checker = SecurityChecker.getInstance();
+        DebugPoint rejection = DebugPointUtil.getDebugPoint(REJECT_HOST_POINT);
+        if (!checker.isEnabled() && rejection == null) {
+            return;
+        }
+        Map<String, Integer> storageEndpoints;
+        Map<String, List<String>> derivedStorageEndpoints;
+        try {
+            storageEndpoints = StorageEndpointProperties.endpoints(properties, 
DatasourcePrintableMap::isSensitiveKey);
+            derivedStorageEndpoints = 
StorageEndpointProperties.derivedEndpointValues(properties);
+        } catch (IllegalArgumentException e) {
+            // Storage routing can fail before URI parsing; never expose 
credential-bearing option values.
+            throw new DdlException("Cannot validate shared storage routing 
against the SSRF policy");
+        }
+        Map<String, Integer> endpoints = new LinkedHashMap<>(storageEndpoints);
+        derivedStorageEndpoints.keySet().forEach(key -> 
endpoints.putIfAbsent(key, -1));
+        for (String key : surface.ssrfEndpointKeys(properties)) {
+            int defaultPort = surface.ssrfEndpointDefaultPort(key);
+            endpoints.put(key, defaultPort < 0 ? endpoints.getOrDefault(key, 
-1) : defaultPort);
+        }
+        // Driver downloads can connect during pre-validation, before a 
connector's connectivity test.
+        String flavor = surface.jdbcDriverUrlFlavorKey();
+        String flavorValue = flavor == null ? "jdbc" : 
properties.getOrDefault(flavor, "").trim();
+        if ("jdbc".equalsIgnoreCase(flavorValue)) {
+            for (String key : surface.jdbcDriverUrlKeys()) {
+                String value = properties.getOrDefault(key, 
"").trim().toLowerCase(Locale.ROOT);
+                if (value.startsWith("http://";) || 
value.startsWith("https://";)) {
+                    endpoints.put(key, -1);
+                }
+            }
+        }
+        // Validate every candidate on ALTER: a flavor/authentication change 
can activate a stored address
+        // without modifying its key. Replays never enter this statement-time 
path.
+        Map<String, List<HostAndPort>> parsedEndpoints = new LinkedHashMap<>();
+        for (Map.Entry<String, Integer> entry : endpoints.entrySet()) {
+            String key = entry.getKey();
+            String value = properties.get(key);
+            List<HostAndPort> destinations;
+            try {
+                destinations = new ArrayList<>();
+                List<String> values = derivedStorageEndpoints.containsKey(key)
+                        ? derivedStorageEndpoints.get(key) : 
surface.ssrfEndpointValues(key, value);
+                for (String endpoint : values) {
+                    // A provider can derive destinations even when this raw 
property is absent.
+                    if (endpoint == null || endpoint.trim().isEmpty()) {
+                        continue;
+                    }
+                    if (endpoint.contains("${")) {
+                        throw new DdlException("Endpoint property '" + key + 
"' must be literal under the SSRF policy; "
+                                + "a placeholder can change its destination 
after validation");
+                    }
+                    if (storageEndpoints.getOrDefault(key, -1) == 8020) {
+                        for (String authority : 
HdfsEndpointProperties.authorities(endpoint.trim(), properties)) {
+                            destinations.add(parseAuthority(authority, 8020));
+                        }
+                    } else {
+                        destinations.addAll(parseEndpoints(endpoint.trim(), 
entry.getValue()));
+                    }
+                }
+            } catch (IllegalArgumentException e) {
+                // Do not echo URLs: their authority or query can carry 
credentials.
+                throw new DdlException("Cannot validate endpoint property '" + 
key + "' of catalog '"
+                        + catalogName + "' against the SSRF policy: use an 
explicit network URI or host:port");
+            }
+            parsedEndpoints.put(key, destinations);
+        }
+        int rejectedPort = rejection == null ? -1 : rejection.param("port", 
-1);
+        for (Map.Entry<String, List<HostAndPort>> entry : 
parsedEndpoints.entrySet()) {
+            String key = entry.getKey();
+            for (HostAndPort destination : entry.getValue()) {
+                // A fail-only seam lets SQL regression tests exercise routing 
without the optional SDK.
+                // It cannot bypass a real policy rejection or allow a 
connection.
+                // Optional port matching distinguishes peers on one host; 
every real checker call remains below.
+                if (rejection != null && 
destination.getHost().equals(rejection.param("host", "127.0.0.1"))
+                        && (rejectedPort < 0 || destination.getPort() == 
rejectedPort)) {
+                    throw new DdlException("Endpoint property '" + key + "' is 
rejected by the SSRF policy");
+                }
+                checker.checkEndpointForSsrf(destination.getHost(), 
destination.getPort());
+            }
+        }
+    }
+
+    /** Parses URI lists, multi-host authorities and scheme-less endpoints 
without splitting URL path commas. */
+    public static List<HostAndPort> parseEndpoints(String value, int 
defaultPort) {
+        String normalized = value.trim();
+        List<HostAndPort> result = parseUnnormalizedEndpoints(normalized, 
defaultPort);
+        if (normalized.regionMatches(true, 0, "jdbc:", 0, 5) && 
normalized.contains(" ")) {
+            // Standalone JDBC strips spaces; Paimon and Iceberg pass the raw 
URL to their drivers.
+            // Checking both interpretations prevents normalization from 
hiding an active host override.
+            LinkedHashSet<HostAndPort> destinations = new 
LinkedHashSet<>(result);
+            
destinations.addAll(parseUnnormalizedEndpoints(normalized.replace(" ", ""), 
defaultPort));
+            return new ArrayList<>(destinations);
+        }
+        return result;
+    }
+
+    private static List<HostAndPort> parseUnnormalizedEndpoints(String 
normalized, int defaultPort) {
+        List<HostAndPort> result = new ArrayList<>();
+        // An SRV seed is a discovery name, not a server at MongoDB's ordinary 
default port.
+        // Until discovery peers are modeled, require literal mongodb:// 
authorities under enforcement.
+        if (normalized.startsWith("mongodb+srv://")) {
+            throw new IllegalArgumentException("Unsupported MongoDB SRV 
discovery routing");
+        }
+        if (normalized.startsWith("mongodb://")) {
+            int authorityEnd = normalized.indexOf('/', "mongodb://".length());
+            authorityEnd = authorityEnd < 0 ? normalized.length() : 
authorityEnd;
+            int query = normalized.indexOf('?');
+            if (query >= 0) {
+                authorityEnd = Math.min(authorityEnd, query);
+            }
+            // MongoDB treats '#' in userinfo as ordinary bytes; Java URI ends 
its authority there.
+            // Reject that disagreement before either the database or proxy 
endpoint is probed.
+            int fragment = normalized.indexOf('#');
+            if (fragment >= 0 && fragment < authorityEnd) {
+                throw new IllegalArgumentException("Ambiguous MongoDB URI 
authority");
+            }
+            parseSingle(normalized, defaultPort, result);
+            addMongoProxy(normalized, result);
+            return result;
+        }
+        // JDBC-specific parameters and Oracle descriptors are not ordinary 
URI authorities.
+        if (normalized.regionMatches(true, 0, "jdbc:mysql:", 0, 11)
+                || normalized.regionMatches(true, 0, "jdbc:mysql+srv:", 0, 
15)) {
+            return JdbcEndpointParser.mysql(normalized);
+        }
+        if (normalized.startsWith("jdbc:mariadb:")) {
+            return JdbcEndpointParser.mariaDb(normalized);
+        }
+        if (normalized.startsWith("jdbc:oceanbase:")) {
+            return JdbcEndpointParser.oceanbase(normalized);
+        }
+        if (normalized.startsWith("jdbc:postgresql:")) {
+            return JdbcEndpointParser.postgresql(normalized);
+        }
+        if (normalized.startsWith("jdbc:sqlserver://")) {
+            return JdbcEndpointParser.sqlServer(normalized);
+        }
+        if (normalized.startsWith("jdbc:oracle:thin:")) {
+            return JdbcEndpointParser.oracle(normalized);
+        }
+        if (normalized.startsWith("jdbc:clickhouse:") || 
normalized.startsWith("jdbc:ch:")) {
+            return JdbcEndpointParser.clickhouse(normalized);
+        }
+        if (normalized.startsWith("jdbc:trino:") || 
normalized.startsWith("jdbc:presto:")) {
+            return JdbcEndpointParser.trinoOrPresto(normalized);
+        }
+        if (normalized.startsWith("jdbc:sap:")) {
+            return JdbcEndpointParser.sap(normalized);
+        }
+        if (normalized.startsWith("jdbc:db2:") || 
normalized.startsWith("jdbc:ibmdb:")
+                || normalized.startsWith("jdbc:ids:") || 
normalized.startsWith("jdbc:informix-sqli:")
+                || normalized.startsWith("jdbc:db2os390:") || 
normalized.startsWith("jdbc:db2os390sqlj:")) {
+            return JdbcEndpointParser.db2(normalized);
+        }
+        if (normalized.startsWith("postgresql://") || 
normalized.startsWith("postgres://")) {
+            validateNativePostgresql(normalized);
+            parseSingle(normalized, defaultPort, result);
+            return result;
+        }
+        if (normalized.startsWith("jdbc:")) {
+            normalized = normalized.substring(5);
+        }
+        for (String endpoint : 
normalized.split(",(?=\\s*[A-Za-z][A-Za-z0-9+.-]*://)", -1)) {
+            parseSingle(endpoint.trim(), defaultPort, result);
+        }
+        return result;
+    }
+
+    private static void addMongoProxy(String uri, List<HostAndPort> result) {
+        int query = uri.indexOf('?');
+        if (query < 0) {
+            return;
+        }
+        Map<String, String> proxy = new LinkedHashMap<>();
+        for (String part : uri.substring(query + 1).split("[&;]")) {
+            String[] pair = part.split("=", 2);
+            String key = pair[0].toLowerCase(Locale.ROOT);
+            if (key.equals("proxyhost") || key.equals("proxyport")
+                    || key.equals("proxyusername") || 
key.equals("proxypassword")) {
+                // The driver rejects every repeated proxy option and decodes 
values exactly once.
+                if (pair.length != 2 || proxy.containsKey(key)) {
+                    throw new IllegalArgumentException("Ambiguous MongoDB 
proxy routing");
+                }
+                proxy.put(key, URLDecoder.decode(pair[1], 
StandardCharsets.UTF_8));
+            }
+        }
+        if (proxy.isEmpty()) {
+            return;
+        }
+        String host = proxy.get("proxyhost");
+        if (host == null || host.isBlank()) {
+            throw new IllegalArgumentException("MongoDB proxy requires a 
literal host");
+        }
+        // MongoDB ProxySettings uses 1080 when the URI omits proxyPort; 
authentication stays opaque.
+        int port = Integer.parseInt(proxy.getOrDefault("proxyport", "1080"));
+        result.add(parseAuthority(HostAndPort.fromParts(host, 
port).toString(), -1));
+    }
+
+    private static void validateNativePostgresql(String value) {
+        int start = value.indexOf("://") + 3;
+        int slash = value.indexOf('/', start);
+        int query = value.indexOf('?', start);
+        int at = value.indexOf('@', start);
+        int authorityEnd = slash < 0 ? value.length() : slash;
+        if (query >= 0) {
+            authorityEnd = Math.min(authorityEnd, query);
+        }
+        int secondAt = at < 0 ? -1 : value.indexOf('@', at + 1);
+        // libpq has no fragment syntax and scans userinfo up to the first 
slash, even across '?'.
+        // Reject structures whose destination differs from Java URI authority 
parsing.
+        if (value.indexOf('#') >= 0 || (at >= 0 && query >= 0 && query < at && 
(slash < 0 || at < slash))
+                || (at >= 0 && at < authorityEnd && secondAt >= 0 && secondAt 
< authorityEnd)) {
+            throw new IllegalArgumentException("Ambiguous native PostgreSQL 
URI");
+        }
+        if (query >= 0) {
+            for (String token : value.substring(query + 1).split("&")) {
+                String rawKey = token.split("=", 2)[0];
+                // libpq percent-decodes keys once and preserves literal plus 
signs.
+                String key = URLDecoder.decode(rawKey.replace("+", "%2B"), 
StandardCharsets.UTF_8);
+                if (key.equals("host") || key.equals("hostaddr") || 
key.equals("port") || key.equals("service")) {
+                    throw new IllegalArgumentException("Native PostgreSQL 
routing requires literal URI authorities");
+                }
+            }
+        }
+    }
+
+    private static void parseSingle(String endpoint, int defaultPort, 
List<HostAndPort> result) {
+        if (endpoint.isEmpty()) {
+            throw new IllegalArgumentException("Empty endpoint");
+        }
+        if (endpoint.regionMatches(true, 0, "file:", 0, 5)) {
+            try {
+                URI local = new URI(endpoint);
+                String authority = local.getRawAuthority();
+                if (local.isOpaque() || (authority != null && 
!authority.isEmpty()
+                        && !"localhost".equalsIgnoreCase(authority))) {
+                    throw new IllegalArgumentException("Remote or opaque file 
URI");
+                }
+                return;
+            } catch (URISyntaxException e) {
+                throw new IllegalArgumentException("Invalid local file URI");
+            }
+        }
+        // DLF's scheme-less endpoints use URL authority semantics, including 
userinfo and suffixes.
+        if ((defaultPort == 80 || defaultPort == 443)
+                && !endpoint.matches("[A-Za-z][A-Za-z0-9+.-]*://.*")) {
+            endpoint = (defaultPort == 80 ? "http://"; : "https://";) + endpoint;
+        }
+        if (!endpoint.contains("://")) {
+            String authority = endpoint.split("/", 2)[0];
+            for (String host : authority.split(",", -1)) {
+                result.add(parseAuthority(host.trim(), defaultPort));
+            }
+            return;
+        }
+        URI uri;
+        try {
+            uri = new URI(endpoint);
+        } catch (URISyntaxException e) {
+            throw new IllegalArgumentException("Invalid endpoint URI");
+        }
+        String scheme = uri.getScheme().toLowerCase(Locale.ROOT);

Review Comment:
   [P3] Return an admission error for relative endpoint values
   
   A relative URI can contain `://` in its path or query. It reaches this 
branch and parses with a null scheme, so the dereference raises 
`NullPointerException` before the code can issue the sanitized per-property 
validation error. Validate that the URI has a scheme and authority before 
lowercasing the scheme.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/StorageEndpointProperties.java:
##########
@@ -0,0 +1,225 @@
+// 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.filesystem.properties;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Network endpoint aliases consumed by filesystem providers and their 
authentication clients. */
+public final class StorageEndpointProperties {
+    private static final List<String> PAIMON_STORAGE_PREFIXES = List.of(
+            "paimon.s3.", "paimon.s3a.", "paimon.fs.s3.", "paimon.fs.oss.");
+    private static final List<String> S3_REGION_ALIASES = List.of("s3.region", 
"AWS_REGION", "region", "REGION",
+            "aws.region", "glue.region", "aws.glue.region", 
"iceberg.rest.signing-region", "rest.signing-region",
+            "client.region");
+    private static final List<String> S3_ENDPOINT_ALIASES = 
List.of("s3.endpoint", "AWS_ENDPOINT", "endpoint",
+            "ENDPOINT", "aws.endpoint", "glue.endpoint", "aws.glue.endpoint");
+    private static final Pattern[] S3_ENDPOINT_PATTERNS = new Pattern[] {
+            Pattern.compile(
+                    "^(?:https?://)?(?:"
+                            + 
"s3(?:[-.]fips)?(?:[-.]dualstack)?[-.]([a-z0-9-]+)|"
+                            + "s3express-control\\.([a-z0-9-]+)|"
+                            + "s3express-[a-z0-9-]+\\.([a-z0-9-]+)"
+                            + ")\\.amazonaws\\.com(?:/.*)?$",
+                    Pattern.CASE_INSENSITIVE),
+            Pattern.compile(
+                    
"^(?:https?://)?glue(?:-fips)?\\.([a-z0-9-]+)\\.(amazonaws\\.com(?:\\.cn)?|api\\.aws)$",
+                    Pattern.CASE_INSENSITIVE)
+    };
+
+    private StorageEndpointProperties() {
+    }
+
+    public static Map<String, List<String>> derivedEndpointValues(Map<String, 
String> properties) {
+        String regionKey = firstNonblankKey(properties, S3_REGION_ALIASES);
+        String endpointKey = firstNonblankKey(properties, S3_ENDPOINT_ALIASES);
+        String sourceKey = endpointKey;
+        String endpoint = endpointKey == null ? null : 
properties.get(endpointKey).trim();
+        if (regionKey == null && endpointKey == null) {
+            // The binder's legacy URI fallback runs on its HashMap snapshot, 
including URI key aliases.
+            Map<String, String> raw = new HashMap<>(properties);
+            sourceKey = raw.keySet().stream().filter(key -> 
key.equalsIgnoreCase("uri")).findFirst().orElse(null);
+            if (sourceKey == null) {
+                return Map.of();
+            }
+            String pathKey = firstNonblankKey(properties, 
List.of("use_path_style", "s3.path-style-access"));
+            String forceKey = firstNonblankKey(properties, 
List.of("force_parsing_by_standard_uri"));
+            endpoint = LegacyS3Uri.deriveEndpointQuietly(raw,
+                    pathKey == null ? "false" : properties.get(pathKey).trim(),
+                    forceKey == null ? "false" : 
properties.get(forceKey).trim());
+        }
+        if (endpoint != null && 
!endpoint.toLowerCase(Locale.ROOT).contains("glue")) {

Review Comment:
   [P2] Admit ordinary endpoints derived from legacy S3 URIs
   
   The binder's legacy `uri` fallback can turn a resource URI into a concrete 
storage endpoint, and `S3FileSystemProperties` exports that result as 
`fs.s3a.endpoint`. This return discards every non-Glue result. For example, the 
binder's force-standard URI test accepts an `s3://` resource URI with no 
explicit port and derives its service endpoint. When Paimon supplies the 
metastore separately, the raw `uri` still goes through generic endpoint parsing 
and fails for lack of a port. Project the binder's ordinary S3 endpoint with 
its effective transport and port, and cover this supported legacy form.



##########
fe/fe-connector/fe-connector-maxcompute/src/main/java/org/apache/doris/connector/maxcompute/MaxComputeConnectorProvider.java:
##########
@@ -97,6 +97,8 @@ public ConnectorSecuritySurface securitySurface() {
         Set<String> sensitiveKeys = 
ConnectorPropertiesUtils.getSensitiveKeys(MCCatalogProperties.class);
         // Retained token properties must stay masked even though the current 
authentication binder ignores them.
         sensitiveKeys.add("mc.session_token");
-        return ConnectorSecuritySurface.EMPTY.withSensitiveKeys(sensitiveKeys);
+        return ConnectorSecuritySurface.EMPTY.withSensitiveKeys(sensitiveKeys)
+                .withSsrfEndpoints(MCCatalogProperties.ENDPOINT, 
MCCatalogProperties.ODPS_ENDPOINT,

Review Comment:
   [P2] Admit the resolved MaxCompute service endpoint
   
   `MCCatalogProperties.getResolvedEndpoint` selects a canonical endpoint 
first, rewrites a legacy tunnel URL to the ODPS service host, or derives a 
service URL from a legacy region. `MaxComputeDorisConnector` uses that result 
for both ODPS and the Storage API. The raw declarations can reject an inactive 
legacy value when a canonical endpoint is present, and lazy reconstruction of 
stored tunnel- or region-only catalogs does not probe the resolved service 
peer. Reuse the connection holder's endpoint resolution for admission and cover 
both cases.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/StorageEndpointProperties.java:
##########
@@ -0,0 +1,225 @@
+// 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.filesystem.properties;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Network endpoint aliases consumed by filesystem providers and their 
authentication clients. */
+public final class StorageEndpointProperties {
+    private static final List<String> PAIMON_STORAGE_PREFIXES = List.of(
+            "paimon.s3.", "paimon.s3a.", "paimon.fs.s3.", "paimon.fs.oss.");
+    private static final List<String> S3_REGION_ALIASES = List.of("s3.region", 
"AWS_REGION", "region", "REGION",
+            "aws.region", "glue.region", "aws.glue.region", 
"iceberg.rest.signing-region", "rest.signing-region",
+            "client.region");
+    private static final List<String> S3_ENDPOINT_ALIASES = 
List.of("s3.endpoint", "AWS_ENDPOINT", "endpoint",
+            "ENDPOINT", "aws.endpoint", "glue.endpoint", "aws.glue.endpoint");
+    private static final Pattern[] S3_ENDPOINT_PATTERNS = new Pattern[] {
+            Pattern.compile(
+                    "^(?:https?://)?(?:"
+                            + 
"s3(?:[-.]fips)?(?:[-.]dualstack)?[-.]([a-z0-9-]+)|"
+                            + "s3express-control\\.([a-z0-9-]+)|"
+                            + "s3express-[a-z0-9-]+\\.([a-z0-9-]+)"
+                            + ")\\.amazonaws\\.com(?:/.*)?$",
+                    Pattern.CASE_INSENSITIVE),
+            Pattern.compile(
+                    
"^(?:https?://)?glue(?:-fips)?\\.([a-z0-9-]+)\\.(amazonaws\\.com(?:\\.cn)?|api\\.aws)$",
+                    Pattern.CASE_INSENSITIVE)
+    };
+
+    private StorageEndpointProperties() {
+    }
+
+    public static Map<String, List<String>> derivedEndpointValues(Map<String, 
String> properties) {

Review Comment:
   [P2] Include the OSS storage endpoint derived from a DLF alias
   
   The shared gate checks the DLF metadata endpoint as written. When its alias 
also feeds OSS storage binding, `OssFileSystemProperties` and 
`OssHdfsProperties` normalize it to a separate OSS or OSS-HDFS service 
endpoint. Paimon passes the resulting `fs.oss.endpoint` into its Hadoop 
configuration, so admission checks the DLF service without checking the 
normalized storage route. Reuse the bound endpoint derivation to check the 
storage destination as well, and add a test that distinguishes the two peers.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/StorageEndpointProperties.java:
##########
@@ -0,0 +1,225 @@
+// 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.filesystem.properties;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Network endpoint aliases consumed by filesystem providers and their 
authentication clients. */
+public final class StorageEndpointProperties {
+    private static final List<String> PAIMON_STORAGE_PREFIXES = List.of(
+            "paimon.s3.", "paimon.s3a.", "paimon.fs.s3.", "paimon.fs.oss.");
+    private static final List<String> S3_REGION_ALIASES = List.of("s3.region", 
"AWS_REGION", "region", "REGION",
+            "aws.region", "glue.region", "aws.glue.region", 
"iceberg.rest.signing-region", "rest.signing-region",
+            "client.region");
+    private static final List<String> S3_ENDPOINT_ALIASES = 
List.of("s3.endpoint", "AWS_ENDPOINT", "endpoint",
+            "ENDPOINT", "aws.endpoint", "glue.endpoint", "aws.glue.endpoint");
+    private static final Pattern[] S3_ENDPOINT_PATTERNS = new Pattern[] {
+            Pattern.compile(
+                    "^(?:https?://)?(?:"
+                            + 
"s3(?:[-.]fips)?(?:[-.]dualstack)?[-.]([a-z0-9-]+)|"
+                            + "s3express-control\\.([a-z0-9-]+)|"
+                            + "s3express-[a-z0-9-]+\\.([a-z0-9-]+)"
+                            + ")\\.amazonaws\\.com(?:/.*)?$",
+                    Pattern.CASE_INSENSITIVE),
+            Pattern.compile(
+                    
"^(?:https?://)?glue(?:-fips)?\\.([a-z0-9-]+)\\.(amazonaws\\.com(?:\\.cn)?|api\\.aws)$",
+                    Pattern.CASE_INSENSITIVE)
+    };
+
+    private StorageEndpointProperties() {
+    }
+
+    public static Map<String, List<String>> derivedEndpointValues(Map<String, 
String> properties) {
+        String regionKey = firstNonblankKey(properties, S3_REGION_ALIASES);
+        String endpointKey = firstNonblankKey(properties, S3_ENDPOINT_ALIASES);
+        String sourceKey = endpointKey;
+        String endpoint = endpointKey == null ? null : 
properties.get(endpointKey).trim();
+        if (regionKey == null && endpointKey == null) {
+            // The binder's legacy URI fallback runs on its HashMap snapshot, 
including URI key aliases.
+            Map<String, String> raw = new HashMap<>(properties);
+            sourceKey = raw.keySet().stream().filter(key -> 
key.equalsIgnoreCase("uri")).findFirst().orElse(null);
+            if (sourceKey == null) {
+                return Map.of();
+            }
+            String pathKey = firstNonblankKey(properties, 
List.of("use_path_style", "s3.path-style-access"));
+            String forceKey = firstNonblankKey(properties, 
List.of("force_parsing_by_standard_uri"));
+            endpoint = LegacyS3Uri.deriveEndpointQuietly(raw,
+                    pathKey == null ? "false" : properties.get(pathKey).trim(),
+                    forceKey == null ? "false" : 
properties.get(forceKey).trim());
+        }
+        if (endpoint != null && 
!endpoint.toLowerCase(Locale.ROOT).contains("glue")) {
+            return Map.of();
+        }
+        // Glue normalization infers a missing region before rewriting the S3 
endpoint. Reuse the
+        // storage binder's inference and retain the original peer for callers 
that also contact Glue.
+        String region = regionKey == null
+                ? (endpoint == null ? "" : 
s3RegionFromEndpoint(endpoint).orElse(""))
+                : properties.get(regionKey).trim();
+        if (region.isEmpty()) {
+            return Map.of();
+        }
+        if (!region.matches("[A-Za-z0-9-]+")) {
+            throw new IllegalArgumentException("S3 region must be a literal 
hostname component");
+        }
+        String serviceEndpoint = s3EndpointForRegion(region);
+        if (regionKey != null) {
+            return Map.of(regionKey, List.of(serviceEndpoint));
+        }
+        String source = properties.get(sourceKey);
+        String normalized = source.trim().toLowerCase(Locale.ROOT);
+        // An S3 URI is a resource locator; its rewritten endpoint is the 
socket peer. An HTTP URI
+        // can also name the catalog service, so retain that independently 
checked original peer.
+        boolean originalPeer = endpointKey != null || 
normalized.startsWith("http://";)
+                || normalized.startsWith("https://";);
+        return Map.of(sourceKey, originalPeer ? List.of(source, 
serviceEndpoint) : List.of(serviceEndpoint));
+    }
+
+    public static String s3EndpointForRegion(String region) {
+        return "https://s3."; + region + ".amazonaws.com";
+    }
+
+    public static Optional<String> s3RegionFromEndpoint(String endpoint) {
+        String lowerEndpoint = endpoint.toLowerCase(Locale.ROOT);
+        for (Pattern pattern : S3_ENDPOINT_PATTERNS) {
+            Matcher matcher = pattern.matcher(lowerEndpoint);
+            if (matcher.matches()) {
+                for (int i = 1; i <= matcher.groupCount(); i++) {
+                    String group = matcher.group(i);
+                    if (group != null && !group.isBlank()) {
+                        return Optional.of(group);
+                    }
+                }
+            }
+        }
+        return Optional.empty();
+    }
+
+    private static String firstNonblankKey(Map<String, String> properties, 
List<String> aliases) {
+        for (String key : aliases) {
+            String value = properties.get(key);
+            if (value != null && !value.isBlank()) {
+                return key;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Shared aliases can reach different SDKs; require an explicit scheme or 
port instead of guessing it.
+     * @throws IllegalArgumentException if a proxy route cannot be established 
from independent endpoint values
+     */
+    public static Map<String, Integer> endpoints(Map<String, String> 
properties, Predicate<String> opaqueCredential) {
+        Map<String, Integer> endpoints = new LinkedHashMap<>();
+        // OSS-HDFS prefers its specific alias over oss.endpoint before 
emitting fs.oss.endpoint.
+        for (String key : new String[] {"s3.endpoint", "AWS_ENDPOINT", 
"endpoint", "ENDPOINT", "aws.endpoint",
+                "glue.endpoint", "aws.glue.endpoint", "oss.endpoint", 
"oss.hdfs.endpoint", "OSS_ENDPOINT",
+                "dlf.endpoint", "dlf.catalog.endpoint", "fs.oss.endpoint", 
"cos.endpoint", "COS_ENDPOINT",
+                "obs.endpoint", "OBS_ENDPOINT", "azure.endpoint", 
"AZURE_ENDPOINT", "azure.oauth2_server_uri",
+                "azure.oauth2_account_host", "gs.endpoint", "minio.endpoint", 
"ozone.endpoint", "fs.s3a.endpoint",
+                "fs.gs.proxy.address"}) {
+            if (properties.containsKey(key)) {
+                endpoints.put(key, -1);
+            }
+        }
+        // ABFS OAuth always uses HTTPS; this value is a hostname also used in 
Hadoop property keys.
+        if (properties.containsKey("azure.oauth2_account_host")) {
+            endpoints.put("azure.oauth2_account_host", 443);
+        }
+        // Hadoop passes through new client options. Keep URI-valued token and 
service endpoints covered
+        // even when a dependency adds an option that Doris does not bind 
itself yet.
+        properties.forEach((key, value) -> {
+            String trimmed = value == null ? "" : value.trim();
+            String normalized = trimmed.toLowerCase(Locale.ROOT);
+            String lowerKey = key.toLowerCase(Locale.ROOT);
+            boolean endpointName = lowerKey.endsWith(".url") || 
lowerKey.endsWith(".uri")
+                    || lowerKey.endsWith(".endpoint");
+            String storageKey = hadoopStorageKey(key);
+            // Bucket options and aliases can replace a filesystem proxy tuple 
after endpoint checking.
+            // Until those routes are modeled together, reject configured 
proxy hosts before any probe.
+            if (!trimmed.isEmpty() && (storageKey.equals("fs.s3a.proxy.host") 
|| storageKey.equals("fs.obs.proxy.host")
+                    || ((storageKey.startsWith("fs.s3a.bucket.") || 
storageKey.startsWith("fs.obs.bucket."))
+                    && storageKey.endsWith(".proxy.host")))) {
+                throw new IllegalArgumentException("Unsupported filesystem 
proxy routing");
+            }
+            boolean storageOption = storageKey.startsWith("fs.") || 
storageKey.startsWith("dfs.")
+                    || storageKey.startsWith("hadoop.");
+            boolean opaqueValue = opaqueCredential.test(storageKey)
+                    || (!storageKey.equals(key) && opaqueCredential.test(key))
+                    || storageKey.endsWith(".proxy.username") || 
storageKey.endsWith(".access-key")
+                    || storageKey.endsWith(".secret-key") || 
storageKey.endsWith(".session-token");
+            boolean warehouse = key.equals("warehouse") || 
key.endsWith(".warehouse")
+                    || key.equals("hive.metastore.warehouse.dir");
+            if ((storageOption
+                    // URL-shaped passwords stay opaque; explicit aliases and 
endpoint names still win.
+                    && (endpointName || (!opaqueValue
+                    && (normalized.startsWith("http://";) || 
normalized.startsWith("https://";)))))
+                    || (warehouse
+                    && (normalized.startsWith("http://";) || 
normalized.startsWith("https://";)))) {
+                endpoints.put(key, -1);
+            }
+            // Paimon HMS eagerly opens its warehouse, including an inherited 
Hadoop default filesystem.
+            // Keep HDFS separate so admission can expand logical HA 
nameservices to physical RPC nodes.
+            // A preferred storage alias can replace fs.defaultFS during 
binding; retain every raw candidate.
+            boolean defaultFilesystem = key.equals("fs.defaultFS") || 
key.equals("fs.default.name")
+                    || key.equals("oss.hdfs.fs.defaultFS");
+            // HTTP HA/redirects, mount tables, FTP and archive delegates are 
not HDFS RPC routes modeled below.
+            if ((warehouse || defaultFilesystem || (storageOption && 
(endpointName || !opaqueValue)))
+                    && (normalized.startsWith("webhdfs:") || 
normalized.startsWith("swebhdfs:")
+                    || normalized.startsWith("viewfs:") || 
normalized.startsWith("ftp:")
+                    || normalized.startsWith("har:"))) {
+                throw new IllegalArgumentException("Unsupported filesystem 
transport routing");
+            }
+            // Interpolation can supply the scheme itself, so these known 
storage keys must enter
+            // literal validation even when their raw value does not yet start 
with a network scheme.
+            if ((warehouse || defaultFilesystem) && trimmed.contains("${")) {
+                endpoints.put(key, -1);
+            }
+            // Hadoop's lowercase "local" sentinel is special; other bare 
values are HDFS hostnames.
+            if (((warehouse || defaultFilesystem || (storageOption && 
(endpointName || !opaqueValue)))

Review Comment:
   [P2] Include the legacy HDFS uri alias in admission
   
   `HdfsProperties` derives `fs.defaultFS` from an HDFS-valued `uri` when the 
default filesystem is absent. A Paimon HMS catalog can provide 
`hive.metastore.uris` for metadata and use that separate storage alias. This 
condition excludes the alias, so the generic parser rejects an ordinary HDFS 
URI without an explicit port and cannot expand a logical nameservice from that 
property. Route the HDFS-valued storage alias through the same default-port and 
HA handling as `fs.defaultFS`.



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