Skip to content

Commit

Permalink
Fixed severity mapping.
Browse files Browse the repository at this point in the history
Signed-off-by: DerekRushton <[email protected]>
  • Loading branch information
DerekRushton committed Aug 15, 2024
1 parent aea948c commit 4d9148e
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import regex
from stix_shifter_modules.tanium.stix_translation.transformers import ConvertTextSeverityToNumberValue
from stix_shifter_utils.stix_translation.src.patterns.pattern_objects import ObservationExpression, ComparisonExpression, \
Pattern,\
CombinedComparisonExpression, CombinedObservationExpression
Expand Down Expand Up @@ -27,14 +28,27 @@ def _format_start_stop_qualifier(self, expression, qualifier) -> str:
stop = qualifier_split[3]
qualified_query = f"{expression}&alertedAtFrom={start}&alertedAtUntil={stop}"
return qualified_query

@staticmethod
def _format_severity(self, value):
if(value < 40):
return "info"
elif(value >= 40 and value < 80):
return "low"
elif(value >= 80):
return "high"

@staticmethod
def _parse_mapped_fields(self, value, comparator, mapped_fields_array):
{}
if(mapped_fields_array[0] == "severity"):
value = QueryStringPatternTranslator._format_severity(self, value)
parsed_fields = f"{mapped_fields_array[0]}{comparator}{value}"

if(comparator == "IN"):
parsed_fields = ""
for current_value in value.values:
if(mapped_fields_array[0] == "severity"):
value = QueryStringPatternTranslator._format_severity(self, value)
parsed_fields += f"{mapped_fields_array[0]}={current_value}&"
parsed_fields = parsed_fields[:-1]
return parsed_fields
Expand Down

0 comments on commit 4d9148e

Please sign in to comment.