Skip to content

Commit

Permalink
fix: Check for permissions in FilterBox (apache#13859)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Ritter authored and Allan Caetano de Oliveira committed May 21, 2021
1 parent d746159 commit 31da47e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
NullValueException,
QueryObjectValidationError,
SpatialException,
SupersetSecurityException,
)
from superset.extensions import cache_manager, security_manager
from superset.models.cache import CacheKey
Expand Down Expand Up @@ -439,7 +440,13 @@ def cache_key(self, query_obj: QueryObjectDict, **extra: Any) -> str:
def get_payload(self, query_obj: Optional[QueryObjectDict] = None) -> VizPayload:
"""Returns a payload of metadata and data"""

self.run_extra_queries()
try:
self.run_extra_queries()
except SupersetSecurityException as ex:
error = dataclasses.asdict(ex.error)
self.errors.append(error)
self.status = utils.QueryStatus.FAILED

payload = self.get_df_payload(query_obj)

df = payload.get("df")
Expand Down Expand Up @@ -2037,6 +2044,8 @@ def query_obj(self) -> QueryObjectDict:
return {}

def run_extra_queries(self) -> None:
from superset.common.query_context import QueryContext

qry = super().query_obj()
filters = self.form_data.get("filter_configs") or []
qry["row_limit"] = self.filter_row_limit
Expand All @@ -2050,6 +2059,10 @@ def run_extra_queries(self) -> None:
qry["groupby"] = [col]
metric = flt.get("metric")
qry["metrics"] = [metric] if metric else []
QueryContext(
datasource={"id": self.datasource.id, "type": self.datasource.type},
queries=[qry],
).raise_for_access()
df = self.get_df_payload(query_obj=qry).get("df")
self.dataframes[col] = df

Expand Down

0 comments on commit 31da47e

Please sign in to comment.