You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/07/07 00:49:21 UTC

[superset] branch fix_dos updated: Address comments

This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch fix_dos
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/fix_dos by this push:
     new 6f248cd4d3 Address comments
6f248cd4d3 is described below

commit 6f248cd4d3df8d58a5d3da033324c0f6cb6d19ec
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu Jul 6 17:47:52 2023 -0700

    Address comments
---
 superset/config.py                        | 2 +-
 superset/dashboards/api.py                | 2 +-
 superset/models/dashboard.py              | 5 +++--
 superset/utils/dashboard_import_export.py | 4 ++--
 superset/views/dashboard/views.py         | 2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/superset/config.py b/superset/config.py
index ae426a08fc..7ccb3a57fb 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -264,7 +264,7 @@ PROXY_FIX_CONFIG = {"x_for": 1, "x_proto": 1, "x_host": 1, "x_port": 1, "x_prefi
 # Configuration for scheduling queries from SQL Lab.
 SCHEDULED_QUERIES: dict[str, Any] = {}
 
-# Rate limiting
+# FAB Rate limiting
 RATELIMIT_ENABLED = True
 AUTH_RATE_LIMITED = True
 AUTH_RATE_LIMIT = "2 per 5 second"
diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py
index be248f7877..1de27dfe58 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -826,7 +826,7 @@ class DashboardRestApi(BaseSupersetModelRestApi):
             Dashboard.id.in_(requested_ids)
         )
         query = self._base_filters.apply_all(query)
-        ids = [item.id for item in query.all()]
+        ids = {item.id for item in query.all()}
         if not ids:
             return self.response_404()
         export = Dashboard.export_dashboards(ids)
diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py
index 757a97d06e..5eb4500116 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -378,11 +378,12 @@ class Dashboard(Model, AuditMixinNullable, ImportExportMixin):
 
     @classmethod
     def export_dashboards(  # pylint: disable=too-many-locals
-        cls, dashboard_ids: list[int]
+        cls,
+        dashboard_ids: set[int],
     ) -> str:
         copied_dashboards = []
         datasource_ids = set()
-        for dashboard_id in set(dashboard_ids):
+        for dashboard_id in dashboard_ids:
             # make sure that dashboard_id is an integer
             dashboard_id = int(dashboard_id)
             dashboard = (
diff --git a/superset/utils/dashboard_import_export.py b/superset/utils/dashboard_import_export.py
index fc61d0a422..eef8cbe6df 100644
--- a/superset/utils/dashboard_import_export.py
+++ b/superset/utils/dashboard_import_export.py
@@ -27,8 +27,8 @@ def export_dashboards(session: Session) -> str:
     """Returns all dashboards metadata as a json dump"""
     logger.info("Starting export")
     dashboards = session.query(Dashboard)
-    dashboard_ids = []
+    dashboard_ids = set()
     for dashboard in dashboards:
-        dashboard_ids.append(dashboard.id)
+        dashboard_ids.add(dashboard.id)
     data = Dashboard.export_dashboards(dashboard_ids)
     return data
diff --git a/superset/views/dashboard/views.py b/superset/views/dashboard/views.py
index 71ef212f6d..ba8b8b2fb3 100644
--- a/superset/views/dashboard/views.py
+++ b/superset/views/dashboard/views.py
@@ -78,7 +78,7 @@ class DashboardModelView(
     @expose("/export_dashboards_form")
     def download_dashboards(self) -> FlaskResponse:
         if request.args.get("action") == "go":
-            ids = request.args.getlist("id")
+            ids = set(request.args.getlist("id"))
             return Response(
                 DashboardModel.export_dashboards(ids),
                 headers=generate_download_headers("json"),