parser: Check for tag markup in the metadata fields
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.
Signed-off-by Michael Wood <[email protected]>
--- Post/parser.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Post/parser.py +13 -0
@@ -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