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/08/10 01:04:42 UTC

[superset] 02/03: 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

commit 546230402ae4a925dcf6014bade9a3a58645ff73
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 d430273008..18cbccfd05 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -266,7 +266,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 1602c8e2f9..b2aa43b0ee 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -817,7 +817,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 18aab8f9e6..54aee779d2 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -373,11 +373,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 a96d56fc14..ce5e8f1e07 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"),