mistercrunch closed pull request #3720: Validate JSON in slice's params on save
URL: https://github.com/apache/incubator-superset/pull/3720
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/models/core.py b/superset/models/core.py
index 7392e8796a..b426849e70 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -193,7 +193,12 @@ def json_data(self):
 
     @property
     def form_data(self):
-        form_data = json.loads(self.params)
+        form_data = {}
+        try:
+            form_data = json.loads(self.params)
+        except Exception as e:
+            logging.error("Malformed json in slice's params")
+            logging.exception(e)
         form_data.update({
             'slice_id': self.id,
             'viz_type': self.viz_type,
diff --git a/superset/views/core.py b/superset/views/core.py
index 7d6db40abe..c38fe128e2 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -386,7 +386,11 @@ class SliceModelView(SupersetModelView, DeleteMixin):  # 
noqa
         'viz_type': _("Visualization Type"),
     }
 
+    def pre_add(self, obj):
+        utils.validate_json(obj.params)
+
     def pre_update(self, obj):
+        utils.validate_json(obj.params)
         check_ownership(obj)
 
     def pre_delete(self, obj):


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to