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


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/plugin/PluginDrivenExternalCatalog.java:
##########
@@ -341,133 +336,17 @@ private void 
checkDriverUrlsAgainstOperatorGate(Map<String, String> candidate,
      */
     private ConnectorSecuritySurface securitySurface(Map<String, String> 
properties) throws DdlException {
         return ConnectorFactory.findProvider(getType(), properties)
-                .map(ConnectorProvider::securitySurface)
+                .map(provider -> provider.securitySurface(properties))

Review Comment:
   Fixed in ec33088ab4. The mandatory JDBC artifact gate now uses the 
provider’s static security surface; the property-aware endpoint projection is 
evaluated only for enabled SSRF admission. A disabled-policy ALTER test 
reproduces the retained DLF/OSS-HDFS configuration and verifies an unrelated 
update succeeds without endpoint probes. The existing driver URL restrictions 
remain covered. The fresh standard FE selection (157 classes / 2741 tests), 
Checkstyle, FE packaging and both local SQL suites passed.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorProvider.java:
##########
@@ -95,11 +100,168 @@ 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.
                 .withSsrfEndpoints(443, "dlf.endpoint", 
"dlf.catalog.endpoint");
     }
+
+    @Override
+    public ConnectorSecuritySurface securitySurface(Map<String, String> 
properties) {
+        ConnectorSecuritySurface surface = securitySurface();
+        Map<String, String> endpointProperties = new HashMap<>(properties);
+        for (String key : new String[] {"signer.endpoint", 
"rest.remote-signing.endpoint",
+                "client.refresh-credentials-endpoint", 
"iceberg.rest.oauth2.server-uri", "oauth2-server-uri",
+                "client.credentials-provider.oauth2-server-uri", 
"gcs.oauth2.refresh-credentials-endpoint"}) {
+            String value = properties.get(key);
+            if (value != null && key.equals("iceberg.rest.oauth2.server-uri")) 
{
+                // The canonical holder trims Strings before emitting the SDK 
OAuth option; raw aliases do not.
+                value = value.trim();
+            }
+            // Iceberg appends signer, credential-refresh and OAuth paths 
(including GCS refresh) to a checked base.
+            // Only these lowercase absolute forms replace that base with an 
independent destination.
+            if (value != null && (value.startsWith("http://";) || 
value.startsWith("https://";))) {
+                surface = surface.withSsrfEndpoints(key);
+            } else {
+                endpointProperties.remove(key);
+            }
+        }
+        if (properties.containsKey("rest.client.proxy.port")) {
+            // The REST client activates this separate host only when a port 
is supplied, including on ALTER.
+            surface = surface.withSsrfEndpoints("rest.client.proxy.hostname");
+            int port = 
explicitProxyPort(properties.get("rest.client.proxy.port"));
+            if (port > 0) {
+                surface = surface.withSsrfEndpoints(port, 
"rest.client.proxy.hostname");
+            }
+        }
+        surface = withProviderProxyEndpoints(surface, properties);
+        // Google credentials are opaque secrets, but their structured token 
endpoints select independent peers.
+        for (String key : new String[] {"gcp.auth.credentials-json",
+                "client.credentials-provider.gcp.auth.credentials-json"}) {
+            if (properties.containsKey(key)) {
+                surface = surface.withSsrfEndpointValues(key,
+                        
IcebergGoogleCredentialValidator.ssrfTokenEndpoints(properties.get(key))
+                                .toArray(new String[0]));
+            }
+        }
+        // JdbcCatalog forwards these as driver Properties, independently of 
options inside the JDBC URL.
+        // Keep Connector/J's exact option names unless a URI alias or 
selected driver also admits MariaDB.
+        String jdbcUriKey = 
JdbcProxyPropertySecurity.metastoreUriKey(properties, "iceberg.jdbc.uri");
+        String jdbcUri = properties.get(jdbcUriKey);
+        // Retired URI aliases cannot choose either a database peer or another 
driver's TLS-store grammar.
+        boolean mariaDb = JdbcTlsStoreUrlSecurity.mayUseMariaDb(jdbcUri, 
properties.get("iceberg.jdbc.driver_class"));
+        boolean connectorJ = JdbcTlsStoreUrlSecurity.mayUseConnectorJ(jdbcUri);
+        List<String> suppliedPorts = new ArrayList<>();
+        Map<String, String> suppliedProperties = new HashMap<>();
+        for (Map.Entry<String, String> entry : properties.entrySet()) {
+            String key = entry.getKey();
+            if (key.startsWith("jdbc.")) {
+                String option = key.substring(5);
+                suppliedProperties.put(option, entry.getValue());
+                if (option.equalsIgnoreCase("port")) {
+                    suppliedPorts.add(entry.getValue());
+                }
+                if (JdbcTlsStoreUrlSecurity.isStoreUrlProperty(option)
+                        || (mariaDb && 
JdbcTlsStoreUrlSecurity.isMariaDbStoreUrlProperty(option))) {
+                    surface = surface.withSsrfEndpointValues(key,
+                            
JdbcTlsStoreUrlSecurity.storePropertyEndpointValues(
+                                    option, entry.getValue(), connectorJ, 
mariaDb)
+                                    .toArray(new String[0]));
+                }
+                // Supplied properties can select proxy/discovery routes 
absent from the JDBC URL.
+                List<String> proxy = 
JdbcProxyPropertySecurity.driverPropertyEndpointValues(option, 
entry.getValue());
+                if (!proxy.isEmpty()) {
+                    surface = surface.withSsrfEndpointValues(key, 
proxy.toArray(new String[0]));
+                }
+            }
+        }
+        List<String> jdbcEndpoints = new ArrayList<>();
+        for (String endpoint : 
JdbcProxyPropertySecurity.mysqlPortEndpointValues(jdbcUri, suppliedPorts)) {
+            
jdbcEndpoints.add(JdbcProxyPropertySecurity.postgresqlPropertyEndpointValue(endpoint,
 suppliedProperties));
+        }
+        surface = surface.withSsrfEndpointValues(jdbcUriKey, 
jdbcEndpoints.toArray(new String[0]))
+                .withSsrfEndpointValues(jdbcUriKey.equals("uri") ? 
"iceberg.jdbc.uri" : "uri");
+        if (IcebergCatalogProperties.TYPE_DLF.equalsIgnoreCase(
+                properties.getOrDefault("iceberg.catalog.type", 
"hms").trim())) {
+            for (Map.Entry<String, List<String>> entry
+                    : 
OssEndpointProperties.s3CompatibleEndpointValues(properties).entrySet()) {

Review Comment:
   Fixed in ec33088ab4. DLF admission now shares the holder’s pure endpoint 
resolver across Iceberg, Paimon and Hive. It checks region-derived public/VPC 
peers, selects the first nonblank endpoint alias, and observes proxy modes 
without losing the independent OSS or OSS-HDFS storage role. Recording tests 
cover both region aliases, modes and alias reactivation; CREATE/ALTER SQL tests 
deny the exact derived peer and verify rejected activation does not publish the 
new route. The fresh standard FE selection (157 classes / 2741 tests), 
Checkstyle, FE packaging and both local SQL suites passed.



##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonConnectorProvider.java:
##########
@@ -106,7 +110,85 @@ 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 configuredFlavor = properties.get("paimon.catalog.type");
+        String flavor = configuredFlavor == null || configuredFlavor.isBlank() 
? "filesystem" : configuredFlavor.trim();

Review Comment:
   Fixed in ec33088ab4. Paimon now writes the typed metastore after every 
generic and backend-specific option overlay, keeping paimon.catalog.type 
authoritative through SDK dispatch. The factory test tries generic 
REST/JDBC/Hive replacements without constructing a catalog client. SQL also 
covers an accepted filesystem catalog carrying dormant generic options and 
refusal when an explicit REST flavor activates a denied URI. The fresh standard 
FE selection (157 classes / 2741 tests), Checkstyle, FE packaging and both 
local SQL suites passed.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorProvider.java:
##########
@@ -95,11 +100,168 @@ 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.
                 .withSsrfEndpoints(443, "dlf.endpoint", 
"dlf.catalog.endpoint");
     }
+
+    @Override
+    public ConnectorSecuritySurface securitySurface(Map<String, String> 
properties) {
+        ConnectorSecuritySurface surface = securitySurface();
+        Map<String, String> endpointProperties = new HashMap<>(properties);
+        for (String key : new String[] {"signer.endpoint", 
"rest.remote-signing.endpoint",
+                "client.refresh-credentials-endpoint", 
"iceberg.rest.oauth2.server-uri", "oauth2-server-uri",
+                "client.credentials-provider.oauth2-server-uri", 
"gcs.oauth2.refresh-credentials-endpoint"}) {
+            String value = properties.get(key);
+            if (value != null && key.equals("iceberg.rest.oauth2.server-uri")) 
{
+                // The canonical holder trims Strings before emitting the SDK 
OAuth option; raw aliases do not.
+                value = value.trim();
+            }
+            // Iceberg appends signer, credential-refresh and OAuth paths 
(including GCS refresh) to a checked base.
+            // Only these lowercase absolute forms replace that base with an 
independent destination.
+            if (value != null && (value.startsWith("http://";) || 
value.startsWith("https://";))) {
+                surface = surface.withSsrfEndpoints(key);
+            } else {
+                endpointProperties.remove(key);
+            }
+        }
+        if (properties.containsKey("rest.client.proxy.port")) {
+            // The REST client activates this separate host only when a port 
is supplied, including on ALTER.
+            surface = surface.withSsrfEndpoints("rest.client.proxy.hostname");
+            int port = 
explicitProxyPort(properties.get("rest.client.proxy.port"));
+            if (port > 0) {
+                surface = surface.withSsrfEndpoints(port, 
"rest.client.proxy.hostname");
+            }
+        }
+        surface = withProviderProxyEndpoints(surface, properties);
+        // Google credentials are opaque secrets, but their structured token 
endpoints select independent peers.
+        for (String key : new String[] {"gcp.auth.credentials-json",
+                "client.credentials-provider.gcp.auth.credentials-json"}) {
+            if (properties.containsKey(key)) {
+                surface = surface.withSsrfEndpointValues(key,
+                        
IcebergGoogleCredentialValidator.ssrfTokenEndpoints(properties.get(key))
+                                .toArray(new String[0]));
+            }
+        }
+        // JdbcCatalog forwards these as driver Properties, independently of 
options inside the JDBC URL.
+        // Keep Connector/J's exact option names unless a URI alias or 
selected driver also admits MariaDB.
+        String jdbcUriKey = 
JdbcProxyPropertySecurity.metastoreUriKey(properties, "iceberg.jdbc.uri");
+        String jdbcUri = properties.get(jdbcUriKey);
+        // Retired URI aliases cannot choose either a database peer or another 
driver's TLS-store grammar.
+        boolean mariaDb = JdbcTlsStoreUrlSecurity.mayUseMariaDb(jdbcUri, 
properties.get("iceberg.jdbc.driver_class"));
+        boolean connectorJ = JdbcTlsStoreUrlSecurity.mayUseConnectorJ(jdbcUri);
+        List<String> suppliedPorts = new ArrayList<>();
+        Map<String, String> suppliedProperties = new HashMap<>();
+        for (Map.Entry<String, String> entry : properties.entrySet()) {
+            String key = entry.getKey();
+            if (key.startsWith("jdbc.")) {
+                String option = key.substring(5);
+                suppliedProperties.put(option, entry.getValue());
+                if (option.equalsIgnoreCase("port")) {
+                    suppliedPorts.add(entry.getValue());
+                }
+                if (JdbcTlsStoreUrlSecurity.isStoreUrlProperty(option)
+                        || (mariaDb && 
JdbcTlsStoreUrlSecurity.isMariaDbStoreUrlProperty(option))) {
+                    surface = surface.withSsrfEndpointValues(key,
+                            
JdbcTlsStoreUrlSecurity.storePropertyEndpointValues(
+                                    option, entry.getValue(), connectorJ, 
mariaDb)
+                                    .toArray(new String[0]));
+                }
+                // Supplied properties can select proxy/discovery routes 
absent from the JDBC URL.
+                List<String> proxy = 
JdbcProxyPropertySecurity.driverPropertyEndpointValues(option, 
entry.getValue());
+                if (!proxy.isEmpty()) {
+                    surface = surface.withSsrfEndpointValues(key, 
proxy.toArray(new String[0]));
+                }
+            }
+        }
+        List<String> jdbcEndpoints = new ArrayList<>();
+        for (String endpoint : 
JdbcProxyPropertySecurity.mysqlPortEndpointValues(jdbcUri, suppliedPorts)) {
+            
jdbcEndpoints.add(JdbcProxyPropertySecurity.postgresqlPropertyEndpointValue(endpoint,
 suppliedProperties));
+        }
+        surface = surface.withSsrfEndpointValues(jdbcUriKey, 
jdbcEndpoints.toArray(new String[0]))

Review Comment:
   Fixed in ec33088ab4. Iceberg Hadoop, DLF-only modes, and Hive/Iceberg HMS 
with a selected dedicated metastore URI now retire only the unused service 
interpretation of uri. Shared storage still admits its HDFS peer at port 8020. 
Recording and SQL tests cover allowed portless storage, denied storage 
replacement, and clearing a dedicated HMS alias to reactivate the stored 
metadata fallback. The fresh standard FE selection (157 classes / 2741 tests), 
Checkstyle, FE packaging and both local SQL suites passed.



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