rusackas commented on code in PR #38584:
URL: https://github.com/apache/superset/pull/38584#discussion_r3662395259
##########
superset/commands/chart/update.py:
##########
@@ -86,6 +87,13 @@ def _validate_new_dashboard_access(
requested_dashboard_ids = {d.id for d in requested_dashboards}
if new_dashboard_ids := requested_dashboard_ids -
existing_dashboard_ids:
+ new_dashboards = [
+ d for d in requested_dashboards if d.id in new_dashboard_ids
+ ]
+ for dash in new_dashboards:
+ if dash.is_managed_externally:
+ raise DashboardsForbiddenError()
+
# For NEW dashboard relationships, verify user has access
accessible_dashboards =
DashboardDAO.find_by_ids(list(new_dashboard_ids))
accessible_dashboard_ids = {d.id for d in accessible_dashboards}
Review Comment:
This already got reordered, access is checked first via the base-filtered
`find_by_ids` call and `is_managed_externally` only gets evaluated on
dashboards the user can already see. Should be covered now.
##########
superset/commands/chart/create.py:
##########
@@ -69,6 +69,8 @@ def validate(self) -> None:
if len(dashboards) != len(dashboard_ids):
exceptions.append(DashboardsNotFoundValidationError())
for dash in dashboards:
+ if dash.is_managed_externally:
+ raise DashboardsForbiddenError()
if not security_manager.is_owner(dash):
raise DashboardsForbiddenError()
Review Comment:
Added a test for this,
`test_create_chart_rejects_externally_managed_dashboard` in commands_tests.py.
##########
superset/commands/chart/update.py:
##########
@@ -86,6 +87,13 @@ def _validate_new_dashboard_access(
requested_dashboard_ids = {d.id for d in requested_dashboards}
if new_dashboard_ids := requested_dashboard_ids -
existing_dashboard_ids:
+ new_dashboards = [
+ d for d in requested_dashboards if d.id in new_dashboard_ids
+ ]
+ for dash in new_dashboards:
+ if dash.is_managed_externally:
+ raise DashboardsForbiddenError()
+
Review Comment:
Same here, covered by
`test_update_chart_rejects_new_externally_managed_dashboard`.
--
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]