Skip to content

Commit

Permalink
Add is_safe check for parameterized query based
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldutra committed Feb 21, 2020
1 parent bdd7b14 commit e555642
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions redash/models/parameterized_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,16 @@ def _valid(self, name, value):

@property
def is_safe(self):
# TODO: make query_parameters with parameters on its own unsafe
text_parameters = [param for param in self.schema if param["type"] == "text"]
return not any(text_parameters)
for param in self.schema:
if param["type"] == "text":
return False
if param["type"] == "query":
query_id = param.get("queryId")
query = models.Query.get_by_id_and_org(query_id, self.org)

if query.parameters:
return False
return True

@property
def missing_params(self):
Expand Down

0 comments on commit e555642

Please sign in to comment.