Skip to contentSkip to conversation

parser: Check for tag markup in the metadata fields

PATCH New Michael Wood 1 participant 1 message Oct 27, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parser: Check for tag markup in the metadata fields

Before we commit the error report metadata to the database do a rudimentary check on all fields that are passed to the graphs page to avoid any XSS happening.

---
 Post/parser.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Post/parser.py +13 -0
index fae9194..b180165 100644
@@ -18,8 +18,21 @@ class Parser:
     def __init__(self, data):
         self.data = data
 
+    # returns true if the values contain '<' char
+    # Ignore the failures field (which is an array anyway)
+    def contains_tags (self, data):
+        for key,val in data.items():
+            if key == 'failures':
+                continue
+
+            if '<' in val:
+                return True
+        return False
+
     def parse(self):
         jsondata = json.loads(self.data)
+        if self.contains_tags(jsondata) == True:
+            return
 
         MACHINE_NAME = str(jsondata['machine'])
         NATIVELSBSTRING = str(jsondata['nativelsb'])
Signature · 1 line
1.9.1