924060929 commented on code in PR #70903:
URL: https://github.com/apache/doris/pull/70903#discussion_r4675740308


##########
fe/fe-core/src/main/java/org/apache/doris/tablefunction/S3TableValuedFunction.java:
##########
@@ -54,7 +54,14 @@ public S3TableValuedFunction(Map<String, String> properties, 
List<TBrokerFileSta
         String uri = storageAdapter.validateAndGetUri(props);
         filePath = storageAdapter.validateAndNormalizeUri(uri);
         this.backendConnectProperties.put(URI_KEY, filePath);
-        if (!FeConstants.runningUnitTest) {
+        if (isPluginFormat()) {
+            // The data set at the uri is read as a whole; a streaming job's 
list of files has no meaning for it.
+            if (files != null) {
+                throw new AnalysisException("Format " + 
fileFormatProperties.getFormatName()
+                        + " reads the data set at the uri as a whole, not a 
list of files");
+            }
+            readPluginFormat();

Review Comment:
   [P1] Check the bound filesystem before handing this URI to the plugin. 
`file()` also delegates Azure to `S3TableValuedFunction`, whose 
`getTFileType()` always returns `FILE_S3`. With Azure shared-key properties, I 
verified that `wasbs://[email protected]/test.lance` becomes 
`s3://warehouse/test.lance` and 
`LanceStorageOptions.fromDorisStorageProperties` returns an empty map. Lance 
then tries S3 without the Azure endpoint or credentials. A lookup can fail or 
resolve a different dataset if that S3 location exists and is accessible. 
Please require `storageAdapter.getSpiProperties() instanceof 
S3CompatibleFileSystemProperties` before calling `readPluginFormat()` and cover 
the Azure `file()` case.



##########
fe/fe-core/src/main/java/org/apache/doris/tablefunction/ExternalFileTableValuedFunction.java:
##########
@@ -214,6 +223,55 @@ protected void parseFile(List<TBrokerFileStatus> files) 
throws AnalysisException
     }
 
 
+    /**
+     * The endpoint white list and SSRF check of an object-storage location, 
which the FE reaches before any BE
+     * does: listing its files, or a plugin reading the data set there.
+     */
+    private static void validateEndpoint(BrokerDesc brokerDesc) throws 
UserException {
+        // "Object storage" here means an S3-compatible binding 
(S3/OSS/OBS/COS/GCS/MinIO/
+        // Ozone) — the exact implementor set of the legacy object-storage 
marker interface;
+        // Azure deliberately stays excluded, matching the legacy instanceof 
check.
+        StorageAdapter storageAdapter = brokerDesc.getStorageAdapter();
+        if (storageAdapter != null
+                && storageAdapter.getSpiProperties() instanceof 
S3CompatibleFileSystemProperties) {
+            S3Util.validateAndTestEndpoint(
+                    ((S3CompatibleFileSystemProperties) 
storageAdapter.getSpiProperties()).getEndpoint());
+        }
+    }
+
+    /** Whether a connector plugin reads this table function's format; see 
{@link #readPluginFormat}. */
+    public boolean isPluginFormat() {
+        return pluginFormat != null;
+    }
+
+    /**
+     * Hands the location to the plugin that reads this table function's 
format, after the endpoint check a listing
+     * gets, and takes the columns from what the plugin resolved. The plugin 
interprets the data set as a whole, so
+     * nothing is listed, and it pins what the statement reads.
+     */
+    protected void readPluginFormat() throws AnalysisException {
+        long startAt = System.currentTimeMillis();
+        try {
+            validateEndpoint(getBrokerDesc());
+            ConnectorFileSource source = new 
ConnectorFileSource(pluginFormat.getFormat(), filePath,
+                    
Collections.singletonList(storageAdapter.getSpiProperties()), 
backendConnectProperties);
+            ConnectorSession session = pluginFormat.buildSession();
+            ConnectorMetadata metadata = PluginDrivenMetadata.get(session, 
pluginFormat.getConnector());
+            pluginTableHandle = ((ConnectorFileSourceOps) 
metadata).getFileTableHandle(session, source);
+            columns = ConnectorColumnConverter.convertColumns(

Review Comment:
   [P2] Reject case-insensitive duplicate column names before exposing the 
plugin schema. I created and reopened a Lance dataset with top-level fields 
`id` and `ID`. This conversion keeps both, but the resulting 
`FunctionGenTable.getColumn("id")` and `getColumn("ID")` both return the second 
field. `DESC FUNCTION` can therefore advertise two columns that Doris cannot 
address independently. The 4.2 Lance TVF and the ordinary file TVF both reject 
this schema during analysis. Please share that uniqueness check with the plugin 
path and add a regression case that also verifies a single mixed-case name 
keeps its original spelling.



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