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


##########
fe/fe-core/src/main/java/org/apache/doris/connector/JdbcEndpointParser.java:
##########
@@ -0,0 +1,728 @@
+// 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.foundation.security.JdbcProxyPropertySecurity;
+import org.apache.doris.foundation.security.JdbcTlsStoreUrlSecurity;
+
+import com.google.common.net.HostAndPort;
+
+import java.net.URI;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Extracts literal destinations without loading the user-selected JDBC 
driver during admission. */
+final class JdbcEndpointParser {
+    private static final Pattern ORACLE_SID = 
Pattern.compile("^(\\[[^\\]]+\\]|[^:/?]+):(\\d+):([^:/?]+)$");
+    private static final Pattern MYSQL_HOST_PORT = 
Pattern.compile("^(\\[[^\\]]+\\]|[^:]*)(?::([^:]*))?$");
+
+    private JdbcEndpointParser() {
+    }
+
+    static List<HostAndPort> sap(String url) {
+        String proxyHostName = "";
+        int query = url.indexOf('?');
+        if (query >= 0) {
+            // HANA selects the last value of a canonical raw key; bare 
options do not clear a value.
+            // Its driver splits before value decoding, and a nonempty proxy 
host is active in both modes.
+            for (String token : url.substring(query + 1).split("&")) {
+                int equals = token.indexOf('=');
+                if (equals >= 0 && 
JdbcProxyPropertySecurity.isHanaProxyHostProperty(token.substring(0, equals))) {
+                    proxyHostName = token.substring(equals + 1);
+                }
+            }
+        }
+        List<HostAndPort> result = new ArrayList<>();
+        for (String endpoint : 
JdbcProxyPropertySecurity.hanaProxyEndpointValues("proxyHostName", 
proxyHostName)) {
+            result.addAll(CatalogEndpointSecurity.parseEndpoints(endpoint, 
-1));
+        }
+        // The remaining query options (including URL-shaped WebSocket paths 
and passwords) keep the base peer.
+        result.addAll(CatalogEndpointSecurity.parseEndpoints(url.substring(5), 
-1));
+        return result;
+    }
+
+    static List<HostAndPort> oceanbase(String url) {
+        String prefix = "jdbc:oceanbase://";
+        if (!url.startsWith(prefix)) {
+            throw new IllegalArgumentException("Unsupported OceanBase 
discovery or connection form");
+        }
+        int query = url.indexOf('?', prefix.length());
+        Map<String, String> properties = oceanbaseProperties(query < 0 ? "" : 
url.substring(query + 1));
+        // These transports can select a peer independently of the URL's 
literal database authorities.
+        for (String key : new String[] {"socksProxyHost", "socketFactory", 
"pipe", "localSocket",
+                "sharedMemory", "obProxySocket"}) {
+            if (properties.containsKey(key)) {
+                throw new IllegalArgumentException("Unsupported OceanBase 
socket routing");
+            }
+        }
+        Integer overridePort = properties.containsKey("port") ? 
Integer.parseInt(properties.get("port")) : null;
+        int slash = url.indexOf('/', prefix.length());
+        int end = slash < 0 ? url.length() : slash;
+        if (query >= 0) {
+            end = Math.min(end, query);
+        }
+        String authority = url.substring(prefix.length(), end);
+        if (authority.contains("(") || authority.contains(")") || 
authority.contains("@")) {
+            throw new IllegalArgumentException("Unsupported OceanBase 
authority");
+        }
+        List<HostAndPort> result = new ArrayList<>();
+        for (String value : authority.trim().split(",")) {
+            String address = value.trim();
+            if (!address.startsWith("[") && address.indexOf(':') != 
address.lastIndexOf(':')) {
+                throw new IllegalArgumentException("OceanBase IPv6 requires a 
literal port");
+            }
+            String host;
+            int literalPort;
+            if (address.startsWith("[")) {
+                int closing = address.indexOf(']');
+                if (closing < 0 || (closing + 1 < address.length() && 
address.charAt(closing + 1) != ':')) {
+                    throw new IllegalArgumentException("Invalid OceanBase IPv6 
authority");
+                }
+                host = address.substring(1, closing);
+                // Bracketed IPv6 defaults to zero in this driver; only a 
query override can make it valid.
+                literalPort = closing + 1 == address.length() ? 0
+                        : Integer.parseInt(address.substring(closing + 2));
+            } else {
+                int colon = address.indexOf(':');
+                host = colon < 0 ? address : address.substring(0, colon);
+                literalPort = colon < 0 ? 3306 : 
Integer.parseInt(address.substring(colon + 1));
+            }
+            // OceanBase's query port replaces even explicit per-host ports, 
rather than acting as a fallback.
+            result.add(endpoint(host, overridePort == null ? literalPort : 
overridePort));
+        }
+        if (result.isEmpty()) {
+            throw new IllegalArgumentException("Missing OceanBase peer");
+        }
+        return result;
+    }
+
+    private static Map<String, String> oceanbaseProperties(String query) {
+        Map<String, String> properties = new LinkedHashMap<>();
+        char quote = 0;
+        // The driver uses this initial lookbehind and asymmetric quote rules, 
even for an unknown first key.
+        char previous = query.isEmpty() ? 0 : query.charAt(0);
+        int start = 0;
+        for (int position = 0; position <= query.length(); position++) {
+            if (position == query.length() || (query.charAt(position) == '&' 
&& quote == 0)) {
+                String token = query.substring(start, position);
+                int equals = token.indexOf('=');
+                String key = equals < 0 ? token : token.substring(0, equals);
+                String value = equals < 0 ? "" : token.substring(equals + 1);
+                // Keys/values stay undecoded, '#' is literal, and the first 
exact-key occurrence wins.
+                properties.putIfAbsent(key, value);
+                start = position + 1;
+            }
+            if (position == query.length()) {
+                break;
+            }
+            char character = query.charAt(position);
+            if (quote == 0) {
+                if ((character == '\'' && previous != '\\') || (character == 
'"' && previous != '"')) {
+                    quote = character;
+                }
+            } else if (character == quote && previous != '\\') {
+                quote = 0;
+            }
+            previous = character;
+        }
+        return properties;
+    }
+
+    static List<HostAndPort> trinoOrPresto(String url) {
+        URI uri = URI.create(url.substring("jdbc:".length()));
+        if (uri.getHost() == null || uri.getPort() < 1) {
+            throw new IllegalArgumentException("Trino/Presto require a literal 
coordinator and port");
+        }
+        // Trino/Presto decode the entire query before splitting; an encoded 
'&' can introduce a proxy option.
+        String query = uri.getQuery();
+        if (query != null) {
+            for (String token : query.split("&")) {
+                String key = token.split("=", 2)[0];
+                if (key.equals("httpProxy") || key.equals("socksProxy")) {
+                    throw new IllegalArgumentException("Unsupported 
Trino/Presto proxy routing");
+                }
+            }
+        }
+        return List.of(endpoint(uri.getHost(), uri.getPort()));
+    }
+
+    static List<HostAndPort> clickhouse(String url) {
+        // The driver selects its legacy grammar by raw substring, even inside 
a path or fragment.
+        if (url.contains("clickhouse.jdbc.v1=true") || 
url.contains("clickhouse.jdbc.v2=false")
+                || Boolean.getBoolean("clickhouse.jdbc.v1")) {
+            throw new IllegalArgumentException("Legacy ClickHouse routing 
requires a separate parser");
+        }
+        String body = url.substring(url.startsWith("jdbc:ch:") ? 
"jdbc:ch:".length() : "jdbc:clickhouse:".length());
+        URI uri = URI.create(body.startsWith("//") ? "http:" + body : body);
+        if (!("http".equals(uri.getScheme()) || 
"https".equals(uri.getScheme())) || uri.getHost() == null) {
+            throw new IllegalArgumentException("Unsupported ClickHouse 
transport or authority");
+        }
+        Map<String, String> properties = new LinkedHashMap<>();
+        if (uri.getRawQuery() != null) {
+            for (String token : uri.getRawQuery().split("&")) {
+                String[] pair = token.split("=", 2);
+                if (pair.length != 2) {
+                    throw new IllegalArgumentException("Invalid ClickHouse URL 
property");
+                }
+                String key = URLDecoder.decode(pair[0], 
StandardCharsets.UTF_8).trim();
+                String value = URLDecoder.decode(pair[1], 
StandardCharsets.UTF_8);
+                // connection_url replaces the whole authority; proxy settings 
select another network peer.
+                if (key.equals("connection_url") || key.equals("proxy_host") 
|| key.equals("proxy_port")
+                        || key.equals("proxy_type")) {
+                    throw new IllegalArgumentException("Unsupported ClickHouse 
URL routing");
+                }
+                properties.put(key, value);
+            }
+        }
+        // ClickHouse's implicit HTTP(S) ports differ from the generic URI 
defaults, including ssl=true.
+        boolean secure = "https".equals(uri.getScheme()) || 
Boolean.parseBoolean(properties.get("ssl"));
+        return List.of(endpoint(uri.getHost(), uri.getPort() < 0 ? (secure ? 
8443 : 8123) : uri.getPort()));
+    }
+
+    static List<HostAndPort> db2(String url) {
+        String prefix = "jdbc:db2://";
+        if (!url.startsWith(prefix)) {
+            throw new IllegalArgumentException("Unsupported DB2 connection 
form or alias");
+        }
+        int slash = url.indexOf('/', prefix.length());
+        if (slash < 0) {
+            throw new IllegalArgumentException("Missing DB2 database");
+        }
+        int separator = url.indexOf(':', slash);
+        if (separator >= 0) {
+            for (String token : url.substring(separator + 1).split(";")) {
+                int equals = token.indexOf('=');
+                String key = (equals < 0 ? token : token.substring(0, 
equals)).trim().toLowerCase(Locale.ROOT);
+                // JCC can route through configured alternate servers or a 
JNDI list without server discovery.
+                if (key.equals("clientreroutealternateservername") || 
key.equals("clientreroutealternateportnumber")
+                        || key.equals("alternategroupservername") || 
key.equals("alternategroupportnumber")
+                        || key.equals("clientrerouteserverlistjndiname")) {
+                    throw new IllegalArgumentException("Unsupported DB2 client 
reroute");
+                }
+            }
+        }
+        return 
List.of(CatalogEndpointSecurity.parseAuthority(url.substring(prefix.length(), 
slash), 446));
+    }
+
+    static List<HostAndPort> mariaDb(String url) {
+        String prefix = "jdbc:mariadb://";
+        if (!url.startsWith(prefix)) {
+            throw new IllegalArgumentException("Unsupported MariaDB connection 
form");
+        }
+        int query = url.indexOf('?');
+        String server = url.substring(prefix.length(), query < 0 ? 
url.length() : query);
+        int slash = server.indexOf('/');
+        String authority = slash < 0 ? server : server.substring(0, slash);
+        if (authority.contains("(") || authority.contains(")") || 
authority.contains("@")) {
+            throw new IllegalArgumentException("Unsupported MariaDB host 
descriptor");
+        }
+        List<HostAndPort> result = new ArrayList<>();
+        for (String host : authority.split(",", -1)) {
+            result.add(CatalogEndpointSecurity.parseAuthority(host.trim(), 
3306));
+        }
+        Map<String, String> properties = new LinkedHashMap<>();
+        if (query >= 0) {
+            // MariaDB splits raw options before case-insensitive binding, 
without URI decoding or
+            // fragment removal. Only duplicates with the exact same spelling 
replace one another.
+            for (String token : url.substring(query + 1).split("&")) {
+                int equals = token.indexOf('=');
+                String key = equals < 0 ? token : token.substring(0, equals);
+                if (JdbcTlsStoreUrlSecurity.isMariaDbStoreUrlProperty(key)) {
+                    properties.put(key, equals < 0 ? "" : 
token.substring(equals + 1));
+                }
+            }
+        }
+        for (String value : properties.values()) {
+            for (String endpoint : 
JdbcTlsStoreUrlSecurity.mariaDbEndpointValues(value)) {
+                result.addAll(CatalogEndpointSecurity.parseEndpoints(endpoint, 
-1));
+            }
+        }
+        return result;
+    }
+
+    static List<HostAndPort> mysql(String url) {
+        String prefix = "jdbc:mysql://";
+        if (!url.regionMatches(true, 0, prefix, 0, prefix.length())) {
+            throw new IllegalArgumentException("Unsupported MySQL discovery or 
connection scheme");
+        }
+        int fragment = url.indexOf('#');
+        String literal = fragment < 0 ? url : url.substring(0, fragment);
+        int query = literal.indexOf('?');
+        Map<String, String> properties = mysqlProperties(query < 0 ? "" : 
literal.substring(query + 1));
+        // Connector/J converts bare host tokens to empty strings and still 
selects its SOCKS factory.
+        // Probing only the database authority cannot admit this different 
transport destination.
+        String discovery = properties.get("dnsSrv");
+        if (properties.containsKey("socksProxyHost") || (discovery != null && 
!discovery.isEmpty()
+                && !discovery.equalsIgnoreCase("false") && 
!discovery.equalsIgnoreCase("no"))) {
+            throw new IllegalArgumentException("MySQL proxy and DNS discovery 
require literal destinations");
+        }
+        List<String> fallbackPorts = new ArrayList<>();
+        properties.forEach((key, value) -> {
+            if (key.equalsIgnoreCase("port")) {
+                fallbackPorts.add(value);
+            }
+        });
+        String server = literal.substring(prefix.length(), query < 0 ? 
literal.length() : query);
+        int slash = server.indexOf('/');
+        String authority = slash < 0 ? server : server.substring(0, slash);
+        if (authority.contains("(") || authority.contains(")")) {
+            throw new IllegalArgumentException("Unsupported MySQL host 
descriptor");
+        }
+        Integer fallbackPort = null;
+        List<HostAndPort> result = new ArrayList<>();
+        // MySQL credentials belong to each host segment; authority-wide 
stripping hides earlier hosts.
+        for (String segment : authority.split(",", -1)) {
+            int userinfo = segment.indexOf('@');
+            if (userinfo >= 0) {
+                URLDecoder.decode(segment.substring(0, userinfo), 
StandardCharsets.UTF_8);
+            }
+            String target = segment.substring(userinfo + 1).trim();
+            Matcher address = MYSQL_HOST_PORT.matcher(target);
+            if (!address.matches()) {
+                throw new IllegalArgumentException("Unsupported MySQL host 
list");
+            }
+            String host = URLDecoder.decode(address.group(1).trim(), 
StandardCharsets.UTF_8);
+            String rawPort = address.group(2);
+            String decodedPort = rawPort == null ? "" : 
URLDecoder.decode(rawPort.trim(), StandardCharsets.UTF_8);
+            int port = decodedPort.isEmpty() ? -1 : 
Integer.parseInt(decodedPort);
+            if (port == -1 && fallbackPort == null) {
+                // The driver normalizes case after HashMap collection, so 
mixed-case aliases have no
+                // token-order precedence. Only an unambiguous fallback can 
select a literal destination.
+                if (fallbackPorts.size() > 1) {
+                    throw new IllegalArgumentException("Ambiguous MySQL port 
aliases");
+                }
+                String fallback = fallbackPorts.isEmpty() ? null : 
fallbackPorts.get(0);
+                int configuredPort = fallback == null || fallback.isEmpty() ? 
3306 : Integer.parseInt(fallback);
+                // Connector/J treats -1 as an omitted port even when 
explicitly supplied in the URL.
+                fallbackPort = configuredPort == -1 ? 3306 : configuredPort;
+            }
+            result.add(endpoint(host, port == -1 ? fallbackPort : port));
+        }
+        // Supplied driver Properties can replace URL TLS mode/type, so check 
every configured store location.
+        for (Map.Entry<String, String> entry : properties.entrySet()) {
+            if (JdbcTlsStoreUrlSecurity.isStoreUrlProperty(entry.getKey())) {
+                for (String endpoint : 
JdbcTlsStoreUrlSecurity.endpointValues(entry.getValue())) {
+                    
result.addAll(CatalogEndpointSecurity.parseEndpoints(endpoint, -1));
+                }
+            }
+        }
+        if (url.startsWith("jdbc:mysql:") && 
url.contains("permitMysqlScheme")) {
+            // MariaDB also accepts this literal marker in a MySQL URL. Check 
both drivers' peers:
+            // MariaDB neither applies Connector/J's query port fallback nor 
discards text after '#'.
+            result.addAll(mariaDb("jdbc:mariadb:" + 
url.substring("jdbc:mysql:".length())));
+        }
+        return result;
+    }
+
+    private static Map<String, String> mysqlProperties(String query) {
+        Map<String, String> properties = new LinkedHashMap<>();
+        for (String token : query.split("&")) {
+            int equals = token.indexOf('=');
+            String key = URLDecoder.decode((equals < 0 ? token : 
token.substring(0, equals)).trim(),
+                    StandardCharsets.UTF_8);
+            String value = equals < 0 ? null : 
URLDecoder.decode(token.substring(equals + 1).trim(),
+                    StandardCharsets.UTF_8);
+            if (key.equalsIgnoreCase("port") || key.equals("socksProxyHost") 
|| key.equals("dnsSrv")
+                    || JdbcTlsStoreUrlSecurity.isStoreUrlProperty(key)) {
+                properties.put(key, value);
+            }
+        }
+        return properties;
+    }
+
+    static List<HostAndPort> postgresql(String url) {
+        int query = url.indexOf('?');
+        String server = url.substring("jdbc:postgresql:".length(), query < 0 ? 
url.length() : query);
+        Map<String, String> properties = new LinkedHashMap<>();
+        if (server.startsWith("//") && !server.equals("//") && 
!server.equals("///")) {
+            int slash = server.indexOf('/', 2);
+            if (slash < 0 || server.indexOf('/', slash + 1) >= 0) {
+                throw new IllegalArgumentException("Invalid PostgreSQL 
authority");
+            }
+            List<String> hosts = new ArrayList<>();
+            List<String> ports = new ArrayList<>();
+            for (String address : server.substring(2, slash).split(",", -1)) {
+                int colon = address.lastIndexOf(':');
+                if (colon >= 0 && address.lastIndexOf(']') < colon) {
+                    hosts.add(colon == 0 ? "localhost" : address.substring(0, 
colon));
+                    ports.add(address.substring(colon + 1));
+                } else {
+                    hosts.add(address);
+                    ports.add("5432");
+                }
+            }
+            properties.put("PGHOST", String.join(",", hosts));
+            properties.put("PGPORT", String.join(",", ports));
+        } else if (server.startsWith("/") && !server.equals("//") && 
!server.equals("///")) {
+            throw new IllegalArgumentException("Invalid PostgreSQL 
destination");
+        }
+        if (query >= 0) {
+            for (String token : url.substring(query + 1).split("&")) {
+                int equals = token.indexOf('=');
+                String key = equals < 0 ? token : token.substring(0, equals);
+                // pgJDBC decodes values only, translates aliases only for 
key=value, and uses the last key.
+                if (equals >= 0) {
+                    if (key.equalsIgnoreCase("host")) {
+                        key = "PGHOST";
+                    } else if (key.equalsIgnoreCase("port")) {
+                        key = "PGPORT";
+                    }
+                }
+                String decoded = equals < 0 ? "" : 
URLDecoder.decode(token.substring(equals + 1),
+                        StandardCharsets.UTF_8);
+                if (equals >= 0 && key.equals("service")) {
+                    throw new IllegalArgumentException("PostgreSQL service 
discovery requires literal destinations");
+                }
+                if (key.equals("PGHOST") || key.equals("PGPORT")) {
+                    properties.put(key, decoded);
+                }
+            }
+        }
+        String[] hosts = properties.getOrDefault("PGHOST", 
"localhost").split(",", -1);

Review Comment:
   [P2] Include supplied PostgreSQL address properties before filling defaults
   
   With Iceberg JDBC and pgJDBC 42.7.13, a database-name-only URL leaves the 
address to the driver properties. Iceberg passes those properties through, but 
this parser fills missing host and port with `localhost:5432` using only the 
URL. Enabled admission can check a different peer from the driver or reject a 
permitted database. Match pgJDBC’s precedence of URL, supplied properties, and 
driver defaults. Cover the database-name-only case and retain the 
explicit-authority behavior. [Iceberg JDBC 
pool](https://github.com/apache/iceberg/blob/apache-iceberg-1.12.0/core/src/main/java/org/apache/iceberg/jdbc/JdbcClientPool.java#L77-L83),
 [pgJDBC URL and property 
merge](https://github.com/pgjdbc/pgjdbc/blob/REL42.7.13/pgjdbc/src/main/java/org/postgresql/Driver.java#L512-L616).



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorProvider.java:
##########
@@ -95,11 +99,149 @@ public ConnectorSecuritySurface securitySurface() {
         // Keep secret masking and JDBC restrictions when REST decryption adds 
a KMS endpoint check.
         return 
ConnectorSecuritySurface.ofJdbcDriverUrls("iceberg.catalog.type", 
"iceberg.jdbc.driver_url")
                 .withSensitiveKeys(MetaStoreProviders.sensitivePropertyKeys())
+                
.withSensitiveKeys(JdbcTlsStoreUrlSecurity.sensitivePropertyKeys("jdbc."))
                 // Protect inline SDK credentials even when the additional 
name-pattern rule is disabled.
                 .withSensitiveKeys(List.of("gcp.auth.credentials-json", 
"gcs.oauth2.token",
                         "gcs.encryption-key", "gcs.decryption-key"))
-                // Standalone DLF proxies open HMS clients too; Hive's surface 
only covers HMS catalogs.
-                .withSsrfEndpoints("kms.endpoint", "hive.metastore.uris", 
"uri", "metastore.thrift.uris")
+                .withSensitiveKeyPrefix("client.credentials-provider.",
+                        "credential", "password", "secret", "token", "key", 
"authorization", "header")
+                .withSsrfEndpoints("kms.endpoint", "iceberg.rest.uri", "uri",
+                        "hive.metastore.uris", "metastore.thrift.uris", 
"s3tables.endpoint", "iceberg.jdbc.uri",
+                        "dynamodb.endpoint",
+                        "http-client.proxy-endpoint", "signer.uri")
+                // Native GCS overrides its storage service host independently 
of the catalog's REST URI.
+                .withSsrfEndpoints("gcs.service.host")
+                .withSsrfEndpoints("glue.endpoint", "aws.endpoint", 
"aws.glue.endpoint")
+                // DLF accepts bare hosts and uses HTTPS, including on its 
standalone HMS proxy path.

Review Comment:
   [P2] Admit the S3-compatible OSS host used by Iceberg DLF
   
   For DLF-backed Iceberg, shared storage admission checks the bound native 
`oss-*` host. `DLFCatalog.initializeFileIO` passes that endpoint through 
`toS3CompatibleEndpoint`, which adds the `s3.` prefix before handing it to 
`S3Client.endpointOverride`. The CREATE storage connectivity probe applies the 
same rewrite. The configured policy therefore evaluates a different host from 
the one Iceberg uses for this storage path. Reuse the S3-compatible endpoint 
derivation in this flavor’s admission and test the two hosts independently.



##########
fe/fe-connector/fe-connector-maxcompute/src/main/java/org/apache/doris/connector/maxcompute/MaxComputeNetworkSecurity.java:
##########
@@ -0,0 +1,78 @@
+// 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.maxcompute;
+
+import org.apache.doris.connector.spi.ConnectorContext;
+import org.apache.doris.connector.spi.DorisConnectorException;
+import org.apache.doris.connector.spi.scan.ConnectorSplitSource;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.concurrent.Callable;
+
+/** Brackets complete SDK calls, including credential acquisition, retries and 
lazy metadata reads. */
+final class MaxComputeNetworkSecurity {
+    private MaxComputeNetworkSecurity() {
+    }
+
+    static <T> T call(ConnectorContext context, Callable<T> task) {
+        try {
+            return context.executeNetworkChecked(task);
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new DorisConnectorException("MaxCompute network security 
check failed", e);
+        }
+    }
+
+    static <T> T wrap(Class<T> contract, T target, ConnectorContext context) {
+        return contract.cast(Proxy.newProxyInstance(contract.getClassLoader(), 
new Class<?>[] {contract},

Review Comment:
   [P2] Preserve the MaxCompute plugin classloader on scan workers
   
   The proxy is defined in the shared SPI loader. For a directory-loaded 
plugin, `PluginDrivenScanNode.onPluginClassLoader` now installs the FE loader 
as the thread context loader when it runs `streamSplits` and later pulls 
splits. The delegated MaxCompute code opens the ODPS read session under that 
loader, even with endpoint checking disabled. Define the proxy in the target’s 
plugin loader or pin the target loader across the delegated calls. The current 
same-loader test cannot catch the regression.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/StorageEndpointProperties.java:
##########
@@ -0,0 +1,252 @@
+// 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.ArrayList;
+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) {
+        Map<String, List<String>> result = new 
LinkedHashMap<>(derivedS3EndpointValues(properties));

Review Comment:
   [P2] Skip S3 defaults when explicit storage selection disables S3
   
   An OSS-only catalog can use `AWS_REGION` through the shared OSS region 
aliases. `FileSystemPluginManager.bindAll` disables guessing when 
`fs.oss.support=true`, so without an explicit S3 provider the binder only 
selects OSS. This call still derives the regional AWS S3 host. An operator 
policy that permits the OSS peer and denies the unused AWS peer rejects the 
catalog. Apply the effective provider selection to the derived S3 default and 
cover the inverse of 
`explicitS3SelectionDoesNotProbeAnInactiveNativeOssDefault`.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/OssEndpointProperties.java:
##########
@@ -0,0 +1,198 @@
+// 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 org.apache.doris.foundation.property.ConnectorPropertiesUtils;
+
+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.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Pure OSS routing rules shared by property binding, provider selection and 
endpoint admission. */
+public final class OssEndpointProperties {
+    private static final List<String> ENDPOINT_ALIASES = 
List.of("oss.endpoint", "s3.endpoint", "AWS_ENDPOINT",
+            "endpoint", "ENDPOINT", "dlf.endpoint", "dlf.catalog.endpoint", 
"fs.oss.endpoint", "OSS_ENDPOINT");
+    private static final List<String> REGION_ALIASES = List.of("oss.region", 
"s3.region", "AWS_REGION", "region",
+            "REGION", "dlf.region", "dlf.catalog.region", 
"iceberg.rest.signing-region", "OSS_REGION");
+    private static final List<String> HDFS_ENDPOINT_ALIASES = 
List.of("oss.hdfs.endpoint", "oss.endpoint",
+            "dlf.endpoint", "dlf.catalog.endpoint", "fs.oss.endpoint");
+    private static final Pattern OSS_ENDPOINT =
+            
Pattern.compile("^(?:https?://)?(?:s3\\.)?oss-([a-z0-9-]+?)(?:-internal)?\\.aliyuncs\\.com$");
+    private static final Pattern DLF_ENDPOINT =
+            
Pattern.compile("^(?:https?://)?dlf(?:-vpc)?\\.([a-z0-9-]+)\\.aliyuncs\\.com(?:/.*)?$");
+
+    private OssEndpointProperties() {
+    }
+
+    public static boolean isDlfEndpoint(String endpoint) {
+        return endpoint != null && 
DLF_ENDPOINT.matcher(endpoint.toLowerCase(Locale.ROOT)).matches();
+    }
+
+    public static Optional<String> regionFromEndpoint(String endpoint) {
+        if (endpoint == null) {
+            return Optional.empty();
+        }
+        String lower = endpoint.toLowerCase(Locale.ROOT);
+        for (Pattern pattern : List.of(OSS_ENDPOINT, DLF_ENDPOINT)) {
+            Matcher matcher = pattern.matcher(lower);
+            if (matcher.matches()) {
+                return Optional.of(matcher.group(1));
+            }
+        }
+        return Optional.empty();
+    }
+
+    /** Inputs are bound String fields; standard-endpoint matching 
deliberately retains its case semantics. */
+    public static String normalizeNativeEndpoint(String endpoint, String 
region, boolean publicAccess) {
+        if (region == null || region.isBlank()) {
+            return endpoint;
+        }
+        if (endpoint == null || endpoint.isBlank() || 
!OSS_ENDPOINT.matcher(endpoint).matches()) {
+            // A configured region rewrites every nonstandard endpoint, 
including custom DLF service URLs.
+            return "oss-" + region + (publicAccess ? "" : "-internal") + 
".aliyuncs.com";
+        }
+        return endpoint;
+    }
+
+    public static boolean matchesNativeGuess(Map<String, String> properties) {
+        // Guessing uses the first non-null alias, whereas field binding uses 
the first nonblank alias.
+        for (String key : List.of("oss.endpoint", "s3.endpoint", 
"AWS_ENDPOINT", "endpoint", "ENDPOINT",
+                "dlf.endpoint", "dlf.catalog.endpoint", "fs.oss.endpoint", 
"fs.oss.accessKeyId")) {
+            String value = properties.get(key);
+            if (value != null) {
+                if (!value.isBlank()) {
+                    return !value.contains("oss-dls.aliyuncs") && 
value.contains("aliyuncs.com");
+                }
+                break;
+            }
+        }
+        String region = properties.get("oss.region");
+        if (region != null && !region.isBlank()) {
+            return true;
+        }
+        for (String key : List.of("hive.metastore.type", 
"iceberg.catalog.type", "paimon.catalog.type")) {
+            if ("dlf".equalsIgnoreCase(properties.get(key))) {
+                return true;
+            }
+        }
+        for (Map.Entry<String, String> entry : properties.entrySet()) {
+            String value = entry.getValue();
+            if (("uri".equalsIgnoreCase(entry.getKey()) || 
"warehouse".equalsIgnoreCase(entry.getKey()))
+                    && value != null && !value.contains("oss-dls.aliyuncs")
+                    && (value.startsWith("oss://")
+                    || (value.contains("aliyuncs.com") && 
(value.contains("oss-") || value.contains("s3."))))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static boolean matchesHdfsGuess(Map<String, String> properties) {
+        if (properties.entrySet().stream().anyMatch(entry -> 
"oss.hdfs.".equalsIgnoreCase(entry.getKey())
+                && Boolean.parseBoolean(entry.getValue()))) {
+            return true;
+        }
+        // These are the legacy guess aliases; fs.oss.endpoint remains a 
binding alias after explicit selection.
+        return List.of("oss.hdfs.endpoint", "oss.endpoint", "dlf.endpoint", 
"dlf.catalog.endpoint").stream()
+                .map(properties::get).anyMatch(value -> value != null && 
!value.isBlank()
+                        && value.endsWith(".oss-dls.aliyuncs.com"));
+    }
+
+    static Map<String, List<String>> derivedEndpointValues(Map<String, String> 
properties) {
+        boolean guess = !hasExplicitFilesystem(properties);
+        boolean hdfs = 
Boolean.parseBoolean(properties.get("fs.oss-hdfs.support"))
+                || Boolean.parseBoolean(properties.get("oss.hdfs.enabled"))
+                || (guess && matchesHdfsGuess(properties));
+        if (hdfs) {
+            String key = firstNonblankKey(properties, HDFS_ENDPOINT_ALIASES);
+            if (key != null && isDlfEndpoint(properties.get(key).trim())) {
+                // Jindo receives a bare rewritten OSS-DLS host; do not invent 
its unmodeled transport port.
+                throw new IllegalArgumentException(
+                        "DLF-derived OSS-HDFS routing requires an explicit 
storage endpoint");
+            }
+            return Map.of();
+        }
+        // Raw catalog binding skips native OSS after an OSS-HDFS match.
+        // Any explicit filesystem flag also disables heuristic provider 
selection.
+        if (!Boolean.parseBoolean(properties.get("fs.oss.support")) && !(guess 
&& matchesNativeGuess(properties))) {
+            return Map.of();
+        }
+        String endpointKey = firstNonblankKey(properties, ENDPOINT_ALIASES);
+        Map<String, String> candidates = new LinkedHashMap<>();
+        if (endpointKey != null) {
+            candidates.put(endpointKey, properties.get(endpointKey).trim());
+        } else {
+            String pathKey = firstNonblankKey(properties, 
List.of("use_path_style", "s3.path-style-access"));

Review Comment:
   [P2] Use the bound OSS URI parsing options in admission
   
   `OssFileSystemProperties` gives `oss.use_path_style` and 
`oss.force_parsing_by_standard_uri` precedence over the generic spellings. This 
projection omits both. For a bucket-qualified HTTPS resource URI, the bound 
path-style option can retain the complete authority and trigger a rewrite to 
the configured region. Admission can instead drop the bucket and recognize the 
URI’s original region as a standard endpoint. Share the binder’s option 
selection and assert the checked peer against the bound endpoint.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorProvider.java:
##########
@@ -95,11 +99,149 @@ public ConnectorSecuritySurface securitySurface() {
         // Keep secret masking and JDBC restrictions when REST decryption adds 
a KMS endpoint check.
         return 
ConnectorSecuritySurface.ofJdbcDriverUrls("iceberg.catalog.type", 
"iceberg.jdbc.driver_url")
                 .withSensitiveKeys(MetaStoreProviders.sensitivePropertyKeys())
+                
.withSensitiveKeys(JdbcTlsStoreUrlSecurity.sensitivePropertyKeys("jdbc."))
                 // Protect inline SDK credentials even when the additional 
name-pattern rule is disabled.
                 .withSensitiveKeys(List.of("gcp.auth.credentials-json", 
"gcs.oauth2.token",
                         "gcs.encryption-key", "gcs.decryption-key"))
-                // Standalone DLF proxies open HMS clients too; Hive's surface 
only covers HMS catalogs.
-                .withSsrfEndpoints("kms.endpoint", "hive.metastore.uris", 
"uri", "metastore.thrift.uris")
+                .withSensitiveKeyPrefix("client.credentials-provider.",
+                        "credential", "password", "secret", "token", "key", 
"authorization", "header")
+                .withSsrfEndpoints("kms.endpoint", "iceberg.rest.uri", "uri",
+                        "hive.metastore.uris", "metastore.thrift.uris", 
"s3tables.endpoint", "iceberg.jdbc.uri",

Review Comment:
   [P2] Admit the effective metastore JDBC URI in Iceberg and Paimon
   
   The JDBC holders for both connectors bind the first nonblank alias, with 
`uri` ahead of the connector-specific JDBC URI. Admission checks both and also 
considers both when choosing TLS store grammar. An old lower-priority URI can 
therefore block an unrelated ALTER or lazy reconstruction even when the 
selected JDBC peer is allowed. Derive service and driver-option admission from 
the holder’s selected URI and keep any independent storage interpretation of 
`uri`.



##########
fe/fe-connector/fe-connector-fluss/src/main/java/org/apache/doris/connector/fluss/FlussConnectorProvider.java:
##########
@@ -51,16 +56,92 @@ 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);
+        // The storage sibling binds canonical names after translating Hadoop 
lake aliases.
+        Map<String, String> storage = 
LakeStorageOptions.toStorageProperties(lake);
+        // Connector storage is published as defaults: even a blank direct key 
remains authoritative.
+        storage.forEach(context::putIfAbsent);
+        // Unmapped sibling aliases cannot replace either direct properties or 
translated storage defaults.
+        lake.forEach(context::putIfAbsent);

Review Comment:
   [P2] Keep translated Fluss storage aliases out of the sibling fallback
   
   `LakeStorageOptions` translates lake `fs.oss.endpoint` to `oss.endpoint`, 
and the runtime sibling removes the original storage option. A directly 
supplied blank `oss.endpoint` suppresses that translated default, letting 
native OSS use the configured region. This fallback copies the nested alias 
back under `fs.oss.endpoint`, so admission can select and reject a peer the 
runtime ignores. Add only unmapped sibling options to the fallback and test a 
blank direct canonical key with a translated nested alias.



##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonConnectorProvider.java:
##########
@@ -106,7 +110,69 @@ 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's scheme-less metadata aliases retain the HTTPS default 
of the shared HMS path.
+                .withSsrfEndpoints(443, "dlf.endpoint", "dlf.catalog.endpoint")
+                .withSsrfEndpointPrefixes("paimon.rest.");
     }
 
+    @Override
+    public ConnectorSecuritySurface securitySurface(Map<String, String> 
properties) {
+        ConnectorSecuritySurface surface = securitySurface();
+        String flavor = properties.getOrDefault("paimon.catalog.type", 
"filesystem").trim();
+        String metastore = properties.get("hive.metastore.uris");
+        boolean canonicalHmsUri = !"jdbc".equalsIgnoreCase(flavor) && 
!"rest".equalsIgnoreCase(flavor)
+                && metastore != null && !metastore.isBlank();
+        // A complete ALTER can switch either URI alias or driver and activate 
stored native options.
+        boolean mariaDb = 
JdbcTlsStoreUrlSecurity.mayUseMariaDb(properties.get("uri"),
+                properties.get("paimon.jdbc.driver_class"))
+                || 
JdbcTlsStoreUrlSecurity.mayUseMariaDb(properties.get("paimon.jdbc.uri"),
+                        properties.get("jdbc.driver_class"));
+        boolean connectorJ = JdbcTlsStoreUrlSecurity.mayUseConnectorJ(
+                properties.get("uri"), properties.get("paimon.jdbc.uri"));
+        List<String> suppliedPorts = new ArrayList<>();
+        for (Map.Entry<String, String> entry : 
PaimonCatalogFactory.jdbcDriverOptionKeys(properties).entrySet()) {
+            String key = entry.getValue();
+            String option = entry.getKey();
+            String value = properties.get(key);
+            if (option.startsWith("jdbc.") && 
option.substring(5).equalsIgnoreCase("port")) {
+                suppliedPorts.add(value);
+            }
+            if (option.startsWith("jdbc.") && 
(JdbcTlsStoreUrlSecurity.isStoreUrlProperty(option.substring(5))
+                    || (mariaDb && 
JdbcTlsStoreUrlSecurity.isMariaDbStoreUrlProperty(option.substring(5))))) {
+                // ALTER resolves the complete candidate again, including a 
newly activated stored fallback.
+                surface = surface.withSsrfEndpointValues(key,
+                        JdbcTlsStoreUrlSecurity.storePropertyEndpointValues(
+                                option.substring(5), value, connectorJ, 
mariaDb).toArray(new String[0]));
+            }
+            if (option.startsWith("jdbc.")) {
+                // Common aliases can independently select proxy/discovery 
routes absent from the URL.
+                List<String> proxy = 
JdbcProxyPropertySecurity.driverPropertyEndpointValues(
+                        option.substring(5), value);
+                if (!proxy.isEmpty()) {
+                    surface = surface.withSsrfEndpointValues(key, 
proxy.toArray(new String[0]));
+                }
+            }
+        }
+        if (!suppliedPorts.isEmpty()) {
+            for (String uriKey : new String[] {"uri", "paimon.jdbc.uri"}) {
+                if (properties.containsKey(uriKey)) {
+                    surface = surface.withSsrfEndpointValues(uriKey,
+                            
JdbcProxyPropertySecurity.mysqlPortEndpointValues(properties.get(uriKey), 
suppliedPorts)
+                                    .toArray(new String[0]));
+                }
+            }
+        }
+        // The canonical HMS alias retires uri only for metadata, including 
after JDBC option projection.
+        // Shared storage admission independently keeps the raw URI's 
filesystem role.
+        return canonicalHmsUri ? surface.withSsrfEndpointValues("uri") : 
surface;

Review Comment:
   [P2] Treat the Paimon filesystem URI as a storage alias
   
   The filesystem flavor builds its catalog from the warehouse and bound Hadoop 
configuration. An ordinary force-standard `s3://` legacy `uri` can supply that 
configuration’s storage endpoint, which shared admission correctly derives and 
checks via HTTPS. This branch also sends the raw `uri` through service 
admission unless an HMS key is present. On the filesystem flavor the second 
interpretation rejects the same valid URI for having no port. Suppress that 
interpretation for the filesystem flavor and preserve the shared storage check.



##########
fe/fe-connector/fe-connector-es/src/main/java/org/apache/doris/connector/es/EsConnectorProvider.java:
##########
@@ -61,6 +61,15 @@ public Connector create(Map<String, String> properties, 
ConnectorContext context
     /** The engine masks the sensitive properties (the password) wherever it 
shows catalog properties. */
     @Override
     public ConnectorSecuritySurface securitySurface() {
-        return 
ConnectorSecuritySurface.EMPTY.withSensitiveKeys(EsCatalogProperties.sensitiveKeys());
+        return 
ConnectorSecuritySurface.EMPTY.withSensitiveKeys(EsCatalogProperties.sensitiveKeys())
+                .withSsrfEndpoints(80, "hosts", "elasticsearch.hosts")
+                // ES splits every comma, including a bare node following a 
URI with a path.
+                .withCommaSeparatedSsrfEndpoints("hosts", 
"elasticsearch.hosts");
+    }
+
+    @Override
+    public ConnectorSecuritySurface securitySurface(Map<String, String> 
properties) {
+        return 
securitySurface().withSsrfEndpoints(EsCatalogProperties.of(properties).isHttpSslEnabled()
 ? 443 : 80,
+                "hosts", "elasticsearch.hosts");

Review Comment:
   [P2] Admit the selected Elasticsearch hosts after alias resolution
   
   `EsCatalogProperties.stripEsPrefix` gives the unprefixed `hosts` key 
precedence. This surface still probes the old `elasticsearch.hosts` list after 
an ALTER adds a permitted canonical list, so a retired address denied by policy 
can prevent the change. Project the selected host list from the holder and 
preserve its comma splitting and SSL defaults. An enabled-policy ALTER test can 
verify that only the selected hosts are probed.



##########
fe/fe-core/src/main/java/org/apache/doris/connector/CatalogEndpointSecurity.java:
##########
@@ -0,0 +1,420 @@
+// 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;
+import java.util.Set;
+
+/** 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 {
+        validateAndRemember(catalogName, surface, properties, null);
+    }
+
+    /** A receipt is valid only within one CREATE statement and for the same 
checker instance. */
+    static final class Admission {
+        private final SecurityChecker checker;
+        private final boolean enabled;
+        private final Set<HostAndPort> destinations;
+
+        private Admission(SecurityChecker checker, Set<HostAndPort> 
destinations) {
+            this.checker = checker;
+            this.enabled = checker.isEnabled();
+            this.destinations = Set.copyOf(destinations);
+        }
+    }
+
+    static Admission validateAndRemember(String catalogName, 
ConnectorSecuritySurface surface,
+            Map<String, String> properties, Admission previous) throws 
DdlException {
+        SecurityChecker checker = SecurityChecker.getInstance();
+        DebugPoint rejection = DebugPointUtil.getDebugPoint(REJECT_HOST_POINT);
+        if (!checker.isEnabled() && rejection == null) {
+            return null;
+        }
+        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, List<HostAndPort>> parsedEndpoints = new LinkedHashMap<>();
+        Map<String, Integer> storageKeys = new 
LinkedHashMap<>(storageEndpoints);
+        derivedStorageEndpoints.keySet().forEach(key -> 
storageKeys.putIfAbsent(key, -1));
+        for (Map.Entry<String, Integer> entry : storageKeys.entrySet()) {
+            String key = entry.getKey();
+            int port = entry.getValue() < 0 ? 
surface.ssrfEndpointDefaultPort(key) : entry.getValue();
+            List<String> values = derivedStorageEndpoints.getOrDefault(key,
+                    properties.get(key) == null ? List.of() : 
List.of(properties.get(key)));
+            appendEndpoints(catalogName, key, values, port, entry.getValue() 
== 8020, properties, parsedEndpoints);
+        }
+        Map<String, Integer> serviceKeys = new LinkedHashMap<>();
+        for (String key : surface.ssrfEndpointKeys(properties)) {
+            serviceKeys.put(key, surface.ssrfEndpointDefaultPort(key));
+        }
+        // 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://";)) {
+                    serviceKeys.put(key, -1);

Review Comment:
   [P2] Check the selected standalone JDBC driver download URL
   
   When both driver URL spellings are set, 
`JdbcCatalogProperties.stripJdbcPrefix` binds `driver_url` and keeps the 
inactive `jdbc.driver_url` in the property map. This loop can reject a valid 
local driver at CREATE or lazy initialization because it probes the unused 
remote alias. Apply the holder’s precedence when projecting the SSRF download 
peer while retaining the existing artifact-policy declarations. The earlier 
standalone JDBC fix handles the database URL separately.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/OssEndpointProperties.java:
##########
@@ -0,0 +1,198 @@
+// 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 org.apache.doris.foundation.property.ConnectorPropertiesUtils;
+
+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.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Pure OSS routing rules shared by property binding, provider selection and 
endpoint admission. */
+public final class OssEndpointProperties {
+    private static final List<String> ENDPOINT_ALIASES = 
List.of("oss.endpoint", "s3.endpoint", "AWS_ENDPOINT",
+            "endpoint", "ENDPOINT", "dlf.endpoint", "dlf.catalog.endpoint", 
"fs.oss.endpoint", "OSS_ENDPOINT");
+    private static final List<String> REGION_ALIASES = List.of("oss.region", 
"s3.region", "AWS_REGION", "region",
+            "REGION", "dlf.region", "dlf.catalog.region", 
"iceberg.rest.signing-region", "OSS_REGION");
+    private static final List<String> HDFS_ENDPOINT_ALIASES = 
List.of("oss.hdfs.endpoint", "oss.endpoint",
+            "dlf.endpoint", "dlf.catalog.endpoint", "fs.oss.endpoint");
+    private static final Pattern OSS_ENDPOINT =
+            
Pattern.compile("^(?:https?://)?(?:s3\\.)?oss-([a-z0-9-]+?)(?:-internal)?\\.aliyuncs\\.com$");
+    private static final Pattern DLF_ENDPOINT =
+            
Pattern.compile("^(?:https?://)?dlf(?:-vpc)?\\.([a-z0-9-]+)\\.aliyuncs\\.com(?:/.*)?$");
+
+    private OssEndpointProperties() {
+    }
+
+    public static boolean isDlfEndpoint(String endpoint) {
+        return endpoint != null && 
DLF_ENDPOINT.matcher(endpoint.toLowerCase(Locale.ROOT)).matches();
+    }
+
+    public static Optional<String> regionFromEndpoint(String endpoint) {
+        if (endpoint == null) {
+            return Optional.empty();
+        }
+        String lower = endpoint.toLowerCase(Locale.ROOT);
+        for (Pattern pattern : List.of(OSS_ENDPOINT, DLF_ENDPOINT)) {
+            Matcher matcher = pattern.matcher(lower);
+            if (matcher.matches()) {
+                return Optional.of(matcher.group(1));
+            }
+        }
+        return Optional.empty();
+    }
+
+    /** Inputs are bound String fields; standard-endpoint matching 
deliberately retains its case semantics. */
+    public static String normalizeNativeEndpoint(String endpoint, String 
region, boolean publicAccess) {
+        if (region == null || region.isBlank()) {
+            return endpoint;
+        }
+        if (endpoint == null || endpoint.isBlank() || 
!OSS_ENDPOINT.matcher(endpoint).matches()) {
+            // A configured region rewrites every nonstandard endpoint, 
including custom DLF service URLs.
+            return "oss-" + region + (publicAccess ? "" : "-internal") + 
".aliyuncs.com";
+        }
+        return endpoint;
+    }
+
+    public static boolean matchesNativeGuess(Map<String, String> properties) {
+        // Guessing uses the first non-null alias, whereas field binding uses 
the first nonblank alias.
+        for (String key : List.of("oss.endpoint", "s3.endpoint", 
"AWS_ENDPOINT", "endpoint", "ENDPOINT",
+                "dlf.endpoint", "dlf.catalog.endpoint", "fs.oss.endpoint", 
"fs.oss.accessKeyId")) {
+            String value = properties.get(key);
+            if (value != null) {
+                if (!value.isBlank()) {
+                    return !value.contains("oss-dls.aliyuncs") && 
value.contains("aliyuncs.com");
+                }
+                break;
+            }
+        }
+        String region = properties.get("oss.region");
+        if (region != null && !region.isBlank()) {
+            return true;
+        }
+        for (String key : List.of("hive.metastore.type", 
"iceberg.catalog.type", "paimon.catalog.type")) {
+            if ("dlf".equalsIgnoreCase(properties.get(key))) {
+                return true;
+            }
+        }
+        for (Map.Entry<String, String> entry : properties.entrySet()) {
+            String value = entry.getValue();
+            if (("uri".equalsIgnoreCase(entry.getKey()) || 
"warehouse".equalsIgnoreCase(entry.getKey()))
+                    && value != null && !value.contains("oss-dls.aliyuncs")
+                    && (value.startsWith("oss://")
+                    || (value.contains("aliyuncs.com") && 
(value.contains("oss-") || value.contains("s3."))))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static boolean matchesHdfsGuess(Map<String, String> properties) {
+        if (properties.entrySet().stream().anyMatch(entry -> 
"oss.hdfs.".equalsIgnoreCase(entry.getKey())
+                && Boolean.parseBoolean(entry.getValue()))) {
+            return true;
+        }
+        // These are the legacy guess aliases; fs.oss.endpoint remains a 
binding alias after explicit selection.
+        return List.of("oss.hdfs.endpoint", "oss.endpoint", "dlf.endpoint", 
"dlf.catalog.endpoint").stream()
+                .map(properties::get).anyMatch(value -> value != null && 
!value.isBlank()
+                        && value.endsWith(".oss-dls.aliyuncs.com"));
+    }
+
+    static Map<String, List<String>> derivedEndpointValues(Map<String, String> 
properties) {
+        boolean guess = !hasExplicitFilesystem(properties);
+        boolean hdfs = 
Boolean.parseBoolean(properties.get("fs.oss-hdfs.support"))
+                || Boolean.parseBoolean(properties.get("oss.hdfs.enabled"))
+                || (guess && matchesHdfsGuess(properties));
+        if (hdfs) {
+            String key = firstNonblankKey(properties, HDFS_ENDPOINT_ALIASES);
+            if (key != null && isDlfEndpoint(properties.get(key).trim())) {
+                // Jindo receives a bare rewritten OSS-DLS host; do not invent 
its unmodeled transport port.
+                throw new IllegalArgumentException(
+                        "DLF-derived OSS-HDFS routing requires an explicit 
storage endpoint");
+            }
+            return Map.of();
+        }
+        // Raw catalog binding skips native OSS after an OSS-HDFS match.
+        // Any explicit filesystem flag also disables heuristic provider 
selection.
+        if (!Boolean.parseBoolean(properties.get("fs.oss.support")) && !(guess 
&& matchesNativeGuess(properties))) {
+            return Map.of();
+        }
+        String endpointKey = firstNonblankKey(properties, ENDPOINT_ALIASES);
+        Map<String, String> candidates = new LinkedHashMap<>();
+        if (endpointKey != null) {
+            candidates.put(endpointKey, properties.get(endpointKey).trim());
+        } else {
+            String pathKey = firstNonblankKey(properties, 
List.of("use_path_style", "s3.path-style-access"));
+            String forceKey = firstNonblankKey(properties, 
List.of("force_parsing_by_standard_uri"));
+            Map<String, String> raw = new HashMap<>(properties);
+            String uriKey = raw.keySet().stream().filter(key -> 
key.equalsIgnoreCase("uri")).findFirst().orElse(null);
+            String derived = LegacyS3Uri.deriveEndpointQuietly(raw,
+                    pathKey == null ? "false" : properties.get(pathKey).trim(),
+                    forceKey == null ? "false" : 
properties.get(forceKey).trim());
+            if (derived != null && !derived.isBlank()) {
+                candidates.put(uriKey, derived);
+            }
+        }
+        String regionKey = firstNonblankKey(properties, REGION_ALIASES);
+        if (candidates.isEmpty() && regionKey != null) {
+            candidates.put(regionKey, "");
+        }
+        Map<String, List<String>> result = new LinkedHashMap<>();
+        String publicKey = firstNonblankKey(properties, 
List.of("dlf.access.public", "dlf.catalog.accessPublic"));
+        boolean publicAccess = publicKey != null && 
ConnectorPropertiesUtils.parseBooleanProperty(
+                properties.get(publicKey).trim(), "dlf.access.public");
+        for (Map.Entry<String, String> entry : candidates.entrySet()) {
+            String region = regionKey == null ? 
regionFromEndpoint(entry.getValue()).orElse("")
+                    : properties.get(regionKey).trim();
+            if (region.isEmpty()) {
+                continue;
+            }
+            if (!region.matches("[A-Za-z0-9-]+")) {
+                throw new IllegalArgumentException("OSS region must be a 
literal hostname component");
+            }
+            String endpoint = normalizeNativeEndpoint(entry.getValue(), 
region, publicAccess);
+            // aliyun-sdk-oss 3.15.0 defaults bare endpoint authorities to 
HTTP, even for HTTPS resource URIs.
+            String peer = endpoint.contains("://") ? endpoint : "http://"; + 
endpoint;
+            result.put(entry.getKey(), endpointKey == null ? List.of(peer)
+                    : List.of(properties.get(endpointKey), peer));

Review Comment:
   [P2] Admit a bare native OSS endpoint at its effective port
   
   A selected native OSS provider accepts a standard hostname in `oss.endpoint` 
without a scheme or port, as 
`OssFileSystemPropertiesTest.uriPlusExplicitEndpoint_explicitEndpointWins` 
demonstrates. This result sends both the original bare value and the normalized 
HTTP peer to admission. The original value has no default port in 
`StorageEndpointProperties`, so parsing rejects the catalog before the 
normalized peer is probed. Keep raw metadata endpoints where they have an 
independent consumer and use the normalized peer for the native OSS endpoint.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/HdfsEndpointProperties.java:
##########
@@ -0,0 +1,88 @@
+// 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.net.URI;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/** Resolves inline HDFS storage authorities without depending on a filesystem 
implementation. */
+public final class HdfsEndpointProperties {
+    private HdfsEndpointProperties() {
+    }
+
+    /** Logical and inherited authorities are checked through their separately 
selected physical properties. */
+    public static List<String> authorities(String value, Map<String, String> 
properties) {
+        URI uri = URI.create(value.regionMatches(true, 0, "hdfs:", 0, 5) ? 
value : "hdfs://" + value);
+        String authority = uri.getRawAuthority();
+        if (authority == null || authority.isEmpty()) {
+            // Hadoop inherits the default authority even for hdfs:/path and 
hdfs:///path.
+            // The default's own property enters admission separately; never 
invent localhost here.
+            for (String key : List.of("fs.defaultFS", "fs.default.name", 
"oss.hdfs.fs.defaultFS")) {

Review Comment:
   [P2] Allow an authorityless HDFS warehouse to inherit the legacy URI default
   
   `HdfsProperties` derives `fs.defaultFS` from a physical HDFS-valued `uri` 
when the explicit default is absent. A Paimon HMS catalog can supply that 
storage alias separately from its metastore and use an authorityless HDFS 
warehouse. Admission checks the physical legacy URI independently, but rejects 
the warehouse because this inheritance loop considers only the explicit default 
aliases. Reuse the binder’s effective default selection and retain the 
physical-peer policy check.



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