Processing Conditions¶
Conditions control when processing transformations are applied.
Base Classes¶
- class sigma.processing.conditions.base.ProcessingCondition[source]¶
Bases:
ProcessingRegularExpressionMixin,ABCAnchor base class for all processing condition types.
- set_pipeline(pipeline)[source]¶
- Parameters:
pipeline (ProcessingPipeline)
- Return type:
None
- __init__()¶
- Return type:
None
- class sigma.processing.conditions.base.RuleProcessingCondition[source]¶
Bases:
ProcessingCondition,ABCBase for Sigma rule processing condition classes used in processing pipelines.
- abstractmethod match(rule)[source]¶
Match condition on Sigma rule.
- Parameters:
rule (SigmaRule | SigmaCorrelationRule)
- Return type:
bool
- __init__()¶
- Return type:
None
- class sigma.processing.conditions.base.DetectionItemProcessingCondition[source]¶
Bases:
ProcessingCondition,ABCBase for Sigma detection item processing condition classes used in processing pipelines.
- abstractmethod match(detection_item)[source]¶
Match condition on Sigma rule.
- Parameters:
detection_item (SigmaDetectionItem)
- Return type:
bool
- __init__()¶
- Return type:
None
- class sigma.processing.conditions.base.FieldNameProcessingCondition[source]¶
Bases:
ProcessingCondition,ABCBase class for conditions on field names in detection items, Sigma rule field lists and other use cases that require matching on field names without detection item context.
- abstractmethod match_field_name(field)[source]¶
The method match is called for each field name and must return a bool result.
- Parameters:
field (str | None)
- Return type:
bool
- match_detection_item(detection_item)[source]¶
Field names can be contained in the detection item field as well as in field references in detection item values. The detection item matching returns True for both cases, but in subsequent processing it has to be verified which part of the detection item has matched and should be subject of processing actions (e.g. field name mapping). This can be done with the methods
match_detection_item_field for the field of a detection item
match_detection_item_value for the whole value list of a detection item and
match_value for single detection items values.
- Parameters:
detection_item (SigmaDetectionItem)
- Return type:
bool
- match_detection_item_field(detection_item)[source]¶
Returns True if the field of the detection item matches the implemented field name condition.
- Parameters:
detection_item (SigmaDetectionItem)
- Return type:
bool
- match_detection_item_value(detection_item)[source]¶
Returns True if any value of a detection item contains a field reference to a field name matching the implemented field name condition. Processing actions must only be applied to matching individual values determined by match_value.
- Parameters:
detection_item (SigmaDetectionItem)
- Return type:
bool
- class sigma.processing.conditions.base.ValueProcessingCondition[source]¶
Bases:
DetectionItemProcessingConditionBase class for conditions on values in detection items. The ‘cond’ parameter determines if any or all values of a multivalued detection item must match to result in an overall match.
The method match_value is called for each value and must return a bool result. It should reject values which are incompatible with the condition with a False return value.
- cond: Literal['any', 'all']¶
- match(detection_item)[source]¶
Match condition on Sigma rule.
- Parameters:
detection_item (SigmaDetectionItem)
- Return type:
bool
- abstractmethod match_value(value)[source]¶
Match condition on detection item values.
- Parameters:
value (SigmaType)
- Return type:
bool
- __init__(cond)¶
- Parameters:
cond (Literal['any', 'all'])
- Return type:
None
Rule Conditions¶
- class sigma.processing.conditions.rule.LogsourceCondition[source]¶
Bases:
RuleProcessingConditionMatches log source on rule. Not specified log source fields are ignored. For Correlation rules, the condition returns true if any of the associated rules have the required log source fields.
- category: str | None = None¶
- product: str | None = None¶
- service: str | None = None¶
- match(rule)[source]¶
Match condition on Sigma rule.
- Parameters:
rule (SigmaRule | SigmaCorrelationRule)
- Return type:
bool
- __init__(category=None, product=None, service=None)¶
- Parameters:
category (str | None)
product (str | None)
service (str | None)
- Return type:
None
- class sigma.processing.conditions.rule.RuleContainsFieldCondition[source]¶
Bases:
RuleDetectionItemConditionReturns True if rule contains a field that matches the given field name.
- field: str | None¶
- find_detection_item(detection)[source]¶
- Parameters:
detection (SigmaDetectionItem | SigmaDetection)
- Return type:
bool
- __init__(field)¶
- Parameters:
field (str | None)
- Return type:
None
- class sigma.processing.conditions.rule.RuleContainsDetectionItemCondition[source]¶
Bases:
RuleDetectionItemConditionReturns True if rule contains a detection item that matches the given field name and value.
- field: str | None¶
- value: str | int | float | bool¶
- find_detection_item(detection)[source]¶
- Parameters:
detection (SigmaDetectionItem | SigmaDetection)
- Return type:
bool
- __init__(field, value)¶
- Parameters:
field (str | None)
value (str | int | float | bool)
- Return type:
None
- class sigma.processing.conditions.rule.IsSigmaRuleCondition[source]¶
Bases:
RuleProcessingConditionChecks if rule is a SigmaRule.
- match(rule)[source]¶
Match condition on Sigma rule.
- Parameters:
rule (SigmaRule | SigmaCorrelationRule)
- Return type:
bool
- __init__()¶
- Return type:
None
- class sigma.processing.conditions.rule.IsSigmaCorrelationRuleCondition[source]¶
Bases:
RuleProcessingConditionChecks if rule is a SigmaCorrelationRule.
- match(rule)[source]¶
Match condition on Sigma rule.
- Parameters:
rule (SigmaRule | SigmaCorrelationRule)
- Return type:
bool
- __init__()¶
- Return type:
None
- class sigma.processing.conditions.rule.RuleAttributeCondition[source]¶
Bases:
RuleProcessingConditionGeneric match on rule attributes with supported types:
strings (exact matches with eq/ne)
UUIDs (exact matches with eq/ne)
lists (membership checks with in/not_in; eq/gte/gt/lte/lt always return False, ne always returns True)
numbers (relations: eq, ne, gte, ge, lte, le)
dates (relations: eq, ne, gte, ge, lte, le)
Rule severity levels (relations: eq, ne, gte, ge, lte, le)
Rule statuses (relations: eq, ne, gte, ge, lte, le)
Fields that contain maps or other complex data structures are not supported and raise a SigmaConfigurationError. If the type of the value doesn’t allows a particular relation, the condition also raises a SigmaConfigurationError on match.
- attribute: str¶
- value: str | int | float¶
- op: Literal['eq', 'ne', 'gte', 'gt', 'lte', 'lt', 'in', 'not_in'] = 'eq'¶
- op_methods: ClassVar[dict[str, str]] = {'eq': '__eq__', 'gt': '__gt__', 'gte': '__ge__', 'lt': '__lt__', 'lte': '__le__', 'ne': '__ne__'}¶
- match(rule)[source]¶
Match condition on Sigma rule.
- Parameters:
rule (SigmaRule | SigmaCorrelationRule)
- Return type:
bool
- __init__(attribute, value, op='eq')¶
- Parameters:
attribute (str)
value (str | int | float)
op (Literal['eq', 'ne', 'gte', 'gt', 'lte', 'lt', 'in', 'not_in'])
- Return type:
None
- class sigma.processing.conditions.rule.RuleTagCondition[source]¶
Bases:
RuleProcessingConditionMatches if rule is tagged with a specific tag.
- tag: str¶
- match(rule)[source]¶
Match condition on Sigma rule.
- Parameters:
rule (SigmaRule | SigmaCorrelationRule)
- Return type:
bool
- __init__(tag)¶
- Parameters:
tag (str)
- Return type:
None
Field Name Conditions¶
- class sigma.processing.conditions.fields.IncludeFieldCondition[source]¶
Bases:
FieldNameProcessingConditionMatches on field name if it is contained in fields list. The parameter ‘mode’ determines if field names are matched as plain string (“plain”) or regular expressions (“re”).
- fields: list[str]¶
- mode: Literal['plain', 're'] = 'plain'¶
- patterns: list[RegexPattern]¶
- match_field_name(field)[source]¶
The method match is called for each field name and must return a bool result.
- Parameters:
field (str | None)
- Return type:
bool
- __init__(fields, mode='plain')¶
- Parameters:
fields (list[str])
mode (Literal['plain', 're'])
- Return type:
None
- class sigma.processing.conditions.fields.ExcludeFieldCondition[source]¶
Bases:
IncludeFieldConditionMatches on field name if it is not contained in fields list.
- match_field_name(field)[source]¶
The method match is called for each field name and must return a bool result.
- Parameters:
field (str | None)
- Return type:
bool
- __init__(fields, mode='plain')¶
- Parameters:
fields (list[str])
mode (Literal['plain', 're'])
- Return type:
None
Value Conditions¶
- class sigma.processing.conditions.values.MatchStringCondition[source]¶
Bases:
ValueProcessingConditionMatch string values with a regular expression ‘pattern’. The parameter ‘cond’ determines for detection items with multiple values if any or all strings must match. Generally, values which aren’t strings are skipped in any mode or result in a false result in all match mode.
- pattern: str¶
- negate: bool = False¶
- match_value(value)[source]¶
Match condition on detection item values.
- Parameters:
value (SigmaType)
- Return type:
bool
- __init__(cond, pattern, negate=False)¶
- Parameters:
cond (Literal['any', 'all'])
pattern (str)
negate (bool)
- Return type:
None
- class sigma.processing.conditions.values.MatchValueCondition[source]¶
Bases:
ValueProcessingConditionExact match of a value with an arbitrary Sigma type.
- value: str | int | float | bool¶
- match_value(value)[source]¶
Match condition on detection item values.
- Parameters:
value (SigmaType)
- Return type:
bool
- __init__(cond, value)¶
- Parameters:
cond (Literal['any', 'all'])
value (str | int | float | bool)
- Return type:
None
- class sigma.processing.conditions.values.ContainsWildcardCondition[source]¶
Bases:
ValueProcessingConditionEvaluates to True if the value contains a wildcard character.
- class sigma.processing.conditions.values.IsNullCondition[source]¶
Bases:
ValueProcessingConditionMatch null values. The parameter ‘cond’ determines for detection items with multiple values if any or all strings must match. Generally, values which aren’t strings are skipped in any mode or result in a false result in all match mode.
- match_value(value)[source]¶
Match condition on detection item values.
- Parameters:
value (SigmaType)
- Return type:
bool
- __init__(cond)¶
- Parameters:
cond (Literal['any', 'all'])
- Return type:
None
State Conditions¶
- class sigma.processing.conditions.state.RuleProcessingItemAppliedCondition[source]¶
Bases:
RuleProcessingConditionChecks if processing item was applied to rule.
- processing_item_id: str¶
- match(rule)[source]¶
Match condition on Sigma rule.
- Parameters:
rule (SigmaRule | SigmaCorrelationRule)
- Return type:
bool
- __init__(processing_item_id)¶
- Parameters:
processing_item_id (str)
- Return type:
None
- class sigma.processing.conditions.state.ProcessingStateConditionBase[source]¶
Bases:
objectBase class for processing pipeline state matching. The method match_state can be used by the matching method of the derived condition classes to match the state condition.
- key: str¶
- val: str | int | float | bool¶
- op: Literal['eq', 'ne', 'gte', 'gt', 'lte', 'lt'] = 'eq'¶
- match_state(processing_pipeline)[source]¶
- Parameters:
processing_pipeline (ProcessingPipeline)
- Return type:
bool
- __init__(key, val, op='eq')¶
- Parameters:
key (str)
val (str | int | float | bool)
op (Literal['eq', 'ne', 'gte', 'gt', 'lte', 'lt'])
- Return type:
None
- class sigma.processing.conditions.state.RuleProcessingStateCondition[source]¶
Bases:
RuleProcessingCondition,ProcessingStateConditionBaseMatches on processing pipeline state.
- match(rule)[source]¶
Match condition on Sigma rule.
- Parameters:
rule (SigmaRule | SigmaCorrelationRule)
- Return type:
bool
- __init__(key, val, op='eq')¶
- Parameters:
key (str)
val (str | int | float | bool)
op (Literal['eq', 'ne', 'gte', 'gt', 'lte', 'lt'])
- Return type:
None
- class sigma.processing.conditions.state.FieldNameProcessingStateCondition[source]¶
Bases:
FieldNameProcessingCondition,ProcessingStateConditionBaseMatches on processing pipeline state in context of a field name condition.
- match_field_name(field)[source]¶
The method match is called for each field name and must return a bool result.
- Parameters:
field (str | None)
- Return type:
bool
- __init__(key, val, op='eq')¶
- Parameters:
key (str)
val (str | int | float | bool)
op (Literal['eq', 'ne', 'gte', 'gt', 'lte', 'lt'])
- Return type:
None
- class sigma.processing.conditions.state.DetectionItemProcessingItemAppliedCondition[source]¶
Bases:
DetectionItemProcessingConditionChecks if processing item was applied to detection item.
- processing_item_id: str¶
- match(detection_item)[source]¶
Match condition on Sigma rule.
- Parameters:
detection_item (SigmaDetectionItem)
- Return type:
bool
- __init__(processing_item_id)¶
- Parameters:
processing_item_id (str)
- Return type:
None
- class sigma.processing.conditions.state.DetectionItemProcessingStateCondition[source]¶
Bases:
DetectionItemProcessingCondition,ProcessingStateConditionBaseMatches on processing pipeline state in context of a detection item condition.
- match(detection_item)[source]¶
Match condition on Sigma rule.
- Parameters:
detection_item (SigmaDetectionItem)
- Return type:
bool
- __init__(key, val, op='eq')¶
- Parameters:
key (str)
val (str | int | float | bool)
op (Literal['eq', 'ne', 'gte', 'gt', 'lte', 'lt'])
- Return type:
None
- class sigma.processing.conditions.state.FieldNameProcessingItemAppliedCondition[source]¶
Bases:
FieldNameProcessingConditionChecks if processing item was applied to a field name.
- processing_item_id: str¶
- match_field_name(field)[source]¶
The method match is called for each field name and must return a bool result.
- Parameters:
field (str | None)
- Return type:
bool
- match_detection_item(detection_item)[source]¶
Field names can be contained in the detection item field as well as in field references in detection item values. The detection item matching returns True for both cases, but in subsequent processing it has to be verified which part of the detection item has matched and should be subject of processing actions (e.g. field name mapping). This can be done with the methods
match_detection_item_field for the field of a detection item
match_detection_item_value for the whole value list of a detection item and
match_value for single detection items values.
- Parameters:
detection_item (SigmaDetectionItem)
- Return type:
bool
- __init__(processing_item_id)¶
- Parameters:
processing_item_id (str)
- Return type:
None