From 53dfe40c3047429cd6e6d376186f9e679e80664c Mon Sep 17 00:00:00 2001 From: Rich Piazza Date: Fri, 5 Jun 2020 09:25:06 -0400 Subject: [PATCH] only test start/stop timestamps if they are strings (2.0) --- stix2/pattern_visitor.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/stix2/pattern_visitor.py b/stix2/pattern_visitor.py index 17e4b3b..4ec2b20 100644 --- a/stix2/pattern_visitor.py +++ b/stix2/pattern_visitor.py @@ -219,11 +219,14 @@ class STIXPatternVisitorForSTIX2(): # Visit a parse tree produced by STIXPatternParser#startStopQualifier. def visitStartStopQualifier(self, ctx): children = self.visitChildren(ctx) - # parser will accept any string, need to make sure it is a full STIX timestamp - t1 = check_for_valid_timetamp_syntax(children[1].value) - t2 = check_for_valid_timetamp_syntax(children[3].value) - if not t1 or not t2: - raise(ValueError("Not a legal timestamp")) + # 2.0 parser will accept any string, need to make sure it is a full STIX timestamp + if isinstance(children[1], StringConstant): + if not check_for_valid_timetamp_syntax(children[1].value): + raise (ValueError("Start time is not a legal timestamp")) + if isinstance(children[3], StringConstant): + if not check_for_valid_timetamp_syntax(children[3].value): + raise (ValueError("Stop time is not a legal timestamp")) + return StartStopQualifier(children[1], children[3]) # Visit a parse tree produced by STIXPatternParser#withinQualifier.