rusackas commented on code in PR #42936:
URL: https://github.com/apache/superset/pull/42936#discussion_r3744925860


##########
superset/views/datasource/views.py:
##########
@@ -83,13 +83,29 @@ def save(self) -> FlaskResponse:
         orm_datasource = DatasourceDAO.get_datasource(
             DatasourceType(datasource_type), datasource_id
         )
-        orm_datasource.database_id = database_id
 
         try:
             security_manager.raise_for_editorship(orm_datasource)
         except SupersetSecurityException as ex:
             raise DatasetForbiddenError() from ex
 
+        if database_id != orm_datasource.database_id:
+            new_database = DatasetDAO.get_database_by_id(database_id)
+            if new_database is None:
+                return json_error_response(_("Database not found."), 
status=422)
+            try:
+                security_manager.raise_for_access(
+                    database=new_database,
+                    table=Table(
+                        orm_datasource.table_name,
+                        orm_datasource.schema,
+                        orm_datasource.catalog,
+                    ),
+                )

Review Comment:
   Good catch — fixed in abaec3cf42: the access check now uses 
`datasource_dict.get("table_name"/"schema"/"catalog", ...)` (the values 
`update_from_object` will actually apply) instead of the dataset's stale ones.



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