Skip to content

Commit

Permalink
Fixed stix parsing with setvalue types (#907)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Muradyan authored Apr 26, 2022
1 parent 159f936 commit 268aa38
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from stix_shifter_utils.stix_translation.src.patterns.pattern_objects import ObservationExpression, ComparisonExpression, \
ComparisonExpressionOperators, ComparisonComparators, Pattern, \
ComparisonExpressionOperators, ComparisonComparators, Pattern, SetValue, \
CombinedComparisonExpression, CombinedObservationExpression, ObservationOperators
import datetime
from stix_shifter_utils.stix_translation.src.utils.transformers import DateTimeToUnixTimestamp
Expand Down Expand Up @@ -27,6 +27,7 @@ class PatternTranslator:
ComparisonComparators.IsSubSet: 'ISSUBSET'
}


def __init__(self, pattern: Pattern, time_range):
self.parsed_pattern = []
# Set times based on default time_range or what is in the options
Expand All @@ -48,6 +49,10 @@ def _parse_expression(self, expression, qualifier=None) -> str:
comparator = 'NOT ' + comparator
if qualifier is not None:
self._convert_qualifier_times_to_unix_times(qualifier)

if (expression.comparator == ComparisonComparators.In and isinstance(expression.value, SetValue)):
expression.value = list(expression.value.element_iterator())

self.parsed_pattern.append({'attribute': expression.object_path, 'comparison_operator': comparator, 'value': expression.value})
elif isinstance(expression, CombinedComparisonExpression):
if qualifier is not None:
Expand Down

0 comments on commit 268aa38

Please sign in to comment.