Modifiers¶
The modifiers module implements Sigma detection value modifiers that transform values during rule parsing.
Base Classes¶
- class sigma.modifiers.SigmaModifier[source]¶
Bases:
ABC,Generic[T,R]Base class for all Sigma modifiers
- __init__(detection_item, applied_modifiers, source=None)[source]¶
- Parameters:
detection_item (SigmaDetectionItem)
applied_modifiers (list[Type['SigmaModifier[T, R]']])
source (SigmaRuleLocation | None)
- detection_item: SigmaDetectionItem¶
- applied_modifiers: list[Type['SigmaModifier[T, R]']]¶
- type_check(val, explicit_type=None)[source]¶
- Parameters:
val (Any)
explicit_type (Type[Any] | None)
- Return type:
bool
- class sigma.modifiers.SigmaValueModifier[source]¶
Bases:
SigmaModifier[T,R]Base class for all modifiers that handle each value for the modifier scope separately
- class sigma.modifiers.SigmaListModifier[source]¶
Bases:
SigmaModifier[T,R]Base class for all modifiers that handle all values for the modifier scope as a whole.
Modifier Classes¶
- class sigma.modifiers.SigmaContainsModifier[source]¶
Bases:
SigmaValueModifier[SigmaString|SigmaRegularExpression|SigmaFieldReference,SigmaString|SigmaRegularExpression|SigmaFieldReference]Puts wildcards around a string to match it somewhere inside another string instead of as a whole.
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString | SigmaRegularExpression | SigmaFieldReference)
- Return type:
- class sigma.modifiers.SigmaStartswithModifier[source]¶
Bases:
SigmaValueModifier[SigmaString|SigmaRegularExpression|SigmaFieldReference,SigmaString|SigmaRegularExpression|SigmaFieldReference]Puts a wildcard at the end of a string to match arbitrary values after the given prefix.
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString | SigmaRegularExpression | SigmaFieldReference)
- Return type:
- class sigma.modifiers.SigmaEndswithModifier[source]¶
Bases:
SigmaValueModifier[SigmaString|SigmaRegularExpression|SigmaFieldReference,SigmaString|SigmaRegularExpression|SigmaFieldReference]Puts a wildcard before a string to match arbitrary values before it.
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString | SigmaRegularExpression | SigmaFieldReference)
- Return type:
- class sigma.modifiers.SigmaBase64Modifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaString]Encode string as Base64 value.
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaBase64OffsetModifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaExpansion]Encode string as Base64 value with different offsets to match it at different locations in encoded form.
- start_offsets = (0, 2, 3)¶
- end_offsets = (None, -3, -2)¶
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaWideModifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaString]Encode string as wide string (UTF-16LE).
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaUTF16BEModifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaString]Encode string as wide string (UTF-16BE).
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaUTF16Modifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaString]Encode string as wide string with BOM (UTF-16LE with BOM prefix).
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaWindowsDashModifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaExpansion]Expand parameter characters / and - that are often interchangeable in Windows into the other form if it appears between word boundaries. E.g. in -param-name the first dash will be expanded into /param-name while the second dash is left untouched.
- en_dash = '–'¶
- em_dash = '—'¶
- horizontal_bar = '―'¶
- max_expanded_dashes = 3¶
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaRegularExpressionModifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaRegularExpression]Treats string value as (case-sensitive) regular expression.
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaRegularExpressionFlagModifier[source]¶
Bases:
SigmaValueModifier[SigmaRegularExpression,SigmaRegularExpression]Generic base class for setting a regular expression flag including checks
- flag: ClassVar[SigmaRegularExpressionFlag]¶
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaRegularExpression)
- Return type:
- class sigma.modifiers.SigmaRegularExpressionIgnoreCaseFlagModifier[source]¶
Bases:
SigmaRegularExpressionFlagModifierMatch regular expression case-insensitive.
- flag: ClassVar[SigmaRegularExpressionFlag] = 1¶
- class sigma.modifiers.SigmaRegularExpressionMultilineFlagModifier[source]¶
Bases:
SigmaRegularExpressionFlagModifierMatch regular expression across multiple lines.
- flag: ClassVar[SigmaRegularExpressionFlag] = 2¶
- class sigma.modifiers.SigmaRegularExpressionDotAllFlagModifier[source]¶
Bases:
SigmaRegularExpressionFlagModifierRegular expression dot matches all characters.
- flag: ClassVar[SigmaRegularExpressionFlag] = 3¶
- class sigma.modifiers.SigmaCaseSensitiveModifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaCasedString]- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaCIDRModifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaCIDRExpression]Treat value as IP (v4 or v6) CIDR network.
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaAllModifier[source]¶
Bases:
SigmaListModifier[Any,Any]Match all values of a list instead of any pf them.
- class sigma.modifiers.SigmaNegateModifier[source]¶
Bases:
SigmaListModifier[Any,Any]Negate the match - turns the detection item into a NOT match.
- class sigma.modifiers.SigmaCompareModifier[source]¶
Bases:
SigmaValueModifier[SigmaNumber,SigmaCompareExpression]Base class for numeric comparison operator modifiers.
- op: ClassVar[CompareOperators]¶
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaNumber)
- Return type:
- class sigma.modifiers.SigmaLessThanModifier[source]¶
Bases:
SigmaCompareModifierNumeric less than (<) matching.
- op: ClassVar[CompareOperators] = 1¶
- class sigma.modifiers.SigmaLessThanEqualModifier[source]¶
Bases:
SigmaCompareModifierNumeric less than or equal (<=) matching.
- op: ClassVar[CompareOperators] = 2¶
- class sigma.modifiers.SigmaGreaterThanModifier[source]¶
Bases:
SigmaCompareModifierNumeric greater than (>) matching.
- op: ClassVar[CompareOperators] = 3¶
- class sigma.modifiers.SigmaGreaterThanEqualModifier[source]¶
Bases:
SigmaCompareModifierNumeric greater than or equal (>=) matching.
- op: ClassVar[CompareOperators] = 4¶
- class sigma.modifiers.SigmaNotEqualModifier[source]¶
Bases:
SigmaCompareModifierNumeric not equal (!=) matching.
- op: ClassVar[CompareOperators] = 5¶
- class sigma.modifiers.SigmaFieldReferenceModifier[source]¶
Bases:
SigmaValueModifier[SigmaString,SigmaFieldReference]Modifiers a plain string into the field reference type.
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString)
- Return type:
- class sigma.modifiers.SigmaExistsModifier[source]¶
Bases:
SigmaValueModifier[SigmaBool,SigmaExists]Modifies to check if the field name provided as value exists in the matched event.
- class sigma.modifiers.SigmaExpandModifier[source]¶
Bases:
SigmaValueModifier[SigmaString|SigmaRegularExpression,SigmaString|SigmaRegularExpression]Modifier for expansion of placeholders in values. It replaces placeholder strings (%something%) with stub objects that are later expanded to one or multiple strings or replaced with some SIEM specific list item or lookup by the processing pipeline.
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaString | SigmaRegularExpression)
- Return type:
- class sigma.modifiers.SigmaTimestampModifier[source]¶
Bases:
SigmaValueModifier[SigmaNumber,SigmaTimestampPart]Base class for timestamp modifiers that parse the field as a datetime/timestamp and transform it to a specific part.
- time_part_unit: ClassVar[TimestampPart]¶
- modify(val)[source]¶
This method should be overridden with the modifier implementation.
- Parameters:
val (SigmaNumber)
- Return type:
- class sigma.modifiers.SigmaTimestampMinuteModifier[source]¶
Bases:
SigmaTimestampModifierModifier that parses the field as a datetime/timestamp and transforms it to the minute number. Between 0 and 59.
- time_part_unit: ClassVar[TimestampPart] = 1¶
- class sigma.modifiers.SigmaTimestampHourModifier[source]¶
Bases:
SigmaTimestampModifierModifier that parses the field as a datetime/timestamp and transforms it to the hour number. Between 0 and 23.
- time_part_unit: ClassVar[TimestampPart] = 2¶
- class sigma.modifiers.SigmaTimestampDayModifier[source]¶
Bases:
SigmaTimestampModifierModifier that parses the field as a datetime/timestamp and transforms it to the day of the month number. Between 1 and 31.
- time_part_unit: ClassVar[TimestampPart] = 3¶
- class sigma.modifiers.SigmaTimestampWeekModifier[source]¶
Bases:
SigmaTimestampModifierModifier that parses the field as a datetime/timestamp and transforms it to the week of the year number. Between 1 and 52.
- time_part_unit: ClassVar[TimestampPart] = 4¶
- class sigma.modifiers.SigmaTimestampMonthModifier[source]¶
Bases:
SigmaTimestampModifierModifier that parses the field as a datetime/timestamp and transforms it to the month of the year number. Between 1 and 12.
- time_part_unit: ClassVar[TimestampPart] = 5¶
- class sigma.modifiers.SigmaTimestampYearModifier[source]¶
Bases:
SigmaTimestampModifierModifier that parses the field as a datetime/timestamp and transforms it to the year number.
- time_part_unit: ClassVar[TimestampPart] = 6¶