villebro commented on a change in pull request #10645:
URL: 
https://github.com/apache/incubator-superset/pull/10645#discussion_r474541861



##########
File path: superset/connectors/sqla/models.py
##########
@@ -629,12 +636,38 @@ def sql_url(self) -> str:
         return self.database.sql_url + "?table_name=" + str(self.table_name)
 
     def external_metadata(self) -> List[Dict[str, str]]:
-        cols = self.database.get_columns(self.table_name, schema=self.schema)
-        for col in cols:
-            try:
-                col["type"] = str(col["type"])
-            except CompileError:
-                col["type"] = "UNKNOWN"
+        db_engine_spec = self.database.db_engine_spec
+        if self.sql:
+            engine = self.database.get_sqla_engine()
+            parsed_query = ParsedQuery(self.sql)
+            if not parsed_query.is_readonly():
+                raise SupersetSecurityException(
+                    _("Only `SELECT` statements are allowed")
+                )
+            statements = parsed_query.get_statements()
+            if len(statements) > 1:
+                raise SupersetSecurityException(_("Only single queries 
supported"))

Review comment:
       While this checking isn't being done when rendering the query in 
`get_sqla_query()`, I doubt anyone should be attempting DML or multiple queries 
here. It's possible that someone _might_ be executing stored procedures or 
similar here on an engine that supports it, but we can deal with that later 
when the use case comes to light.




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

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