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


##########
fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorSecuritySurface.java:
##########
@@ -146,15 +159,65 @@ public ConnectorSecuritySurface 
withSensitiveKeyPrefix(String prefix, String...
         merged.add(new SensitiveKeyPrefix(prefix,
                 Collections.unmodifiableList(new 
ArrayList<>(Arrays.asList(markers)))));
         return new ConnectorSecuritySurface(ssrfEndpointKeys, 
jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey,
-                sensitiveKeys, Collections.unmodifiableList(merged));
+                sensitiveKeys, Collections.unmodifiableList(merged), 
ssrfDefaultPorts, ssrfEndpointPrefixes);
     }
 
     /** Adds endpoint checks without dropping existing driver-url or 
secret-masking declarations. */
     public ConnectorSecuritySurface withSsrfEndpoints(String... keys) {
         Set<String> endpoints = new LinkedHashSet<>(ssrfEndpointKeys);
         endpoints.addAll(Arrays.asList(keys));
         return new ConnectorSecuritySurface(Collections.unmodifiableList(new 
ArrayList<>(endpoints)),
-                jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey, sensitiveKeys, 
sensitiveKeyPrefixes);
+                jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey, sensitiveKeys, 
sensitiveKeyPrefixes,
+                ssrfDefaultPorts, ssrfEndpointPrefixes);
+    }
+
+    /** Declares the port used by the client when these endpoint properties 
omit their scheme and port. */
+    public ConnectorSecuritySurface withSsrfEndpoints(int defaultPort, 
String... keys) {
+        if (defaultPort < 1 || defaultPort > 65535) {
+            throw new IllegalArgumentException("Invalid endpoint default 
port");
+        }
+        ConnectorSecuritySurface extended = withSsrfEndpoints(keys);
+        Map<String, Integer> ports = new LinkedHashMap<>(ssrfDefaultPorts);
+        for (String key : keys) {
+            ports.put(key, defaultPort);
+        }
+        return new ConnectorSecuritySurface(extended.ssrfEndpointKeys, 
jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey,
+                sensitiveKeys, sensitiveKeyPrefixes, 
Collections.unmodifiableMap(ports), ssrfEndpointPrefixes);
+    }
+
+    /**
+     * Declares HTTP(S) URLs and endpoint-named options in an SDK's open-ended 
property namespace.
+     * An unknown scheme-less endpoint requires an explicit port rather than 
guessing the SDK's default;
+     * credentials and ordinary filesystem paths are not interpreted as hosts.
+     */
+    public ConnectorSecuritySurface withSsrfEndpointPrefixes(String... 
prefixes) {
+        Set<String> merged = new LinkedHashSet<>(ssrfEndpointPrefixes);
+        merged.addAll(Arrays.asList(prefixes));
+        return new ConnectorSecuritySurface(ssrfEndpointKeys, 
jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey,
+                sensitiveKeys, sensitiveKeyPrefixes, ssrfDefaultPorts,
+                Collections.unmodifiableList(new ArrayList<>(merged)));
+    }
+
+    /** Includes URL-valued and endpoint-named SDK options whose names can 
evolve independently of Doris. */
+    public List<String> ssrfEndpointKeys(Map<String, String> properties) {
+        Set<String> keys = new LinkedHashSet<>(ssrfEndpointKeys);
+        properties.forEach((key, value) -> {
+            String normalized = value == null ? "" : 
value.trim().toLowerCase(Locale.ROOT);
+            String lowerKey = key.toLowerCase(Locale.ROOT);
+            boolean endpointName = lowerKey.endsWith(".uri") || 
lowerKey.endsWith(".url")
+                    || lowerKey.endsWith(".endpoint") || 
lowerKey.endsWith("-uri")
+                    || lowerKey.endsWith("-url") || 
lowerKey.endsWith("-endpoint");
+            if ((normalized.startsWith("http://";) || 
normalized.startsWith("https://";) || endpointName)

Review Comment:
   Fixed in `d0fae50b911c`. Explicit endpoints and endpoint-named options 
retain precedence, while value-only inference excludes known opaque 
credentials. Underscore suffixes preserve ADBC token_uri endpoints. The Paimon 
bearer token is declared opaque/sensitive, and shared Hadoop inference reuses 
existing credential-key rules without an API-to-core dependency. Tests cover 
URL-shaped passwords/tokens/secrets and ensure real token URLs remain checked; 
SQL acceptance cases cover opaque credentials.



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