File tree 3 files changed +34
-4
lines changed
3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -454,6 +454,10 @@ def __post_init__(self):
454
454
raise sigma_exceptions .SigmaDetectionError (
455
455
"No detections defined in Sigma rule" , source = self .source
456
456
)
457
+ if self .condition == [] or self .condition is None :
458
+ raise sigma_exceptions .SigmaConditionError (
459
+ "Sigma rule must contain at least one condition" , source = self .source
460
+ )
457
461
self .parsed_condition = [SigmaCondition (cond , self , self .source ) for cond in self .condition ]
458
462
459
463
@classmethod
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def sigma_simple_detections():
45
45
]
46
46
),
47
47
},
48
- list () ,
48
+ condition = [ "any of them" ] ,
49
49
)
50
50
51
51
@@ -142,7 +142,7 @@ def sigma_detections():
142
142
]
143
143
),
144
144
},
145
- list () ,
145
+ condition = [ "any of them" ] ,
146
146
)
147
147
148
148
@@ -156,7 +156,7 @@ def sigma_invalid_detections():
156
156
]
157
157
),
158
158
},
159
- list () ,
159
+ condition = [ "any of them" ] ,
160
160
)
161
161
162
162
@@ -180,7 +180,7 @@ def sigma_underscore_detections():
180
180
]
181
181
),
182
182
},
183
- list () ,
183
+ condition = [ "any of them" ] ,
184
184
)
185
185
186
186
Original file line number Diff line number Diff line change @@ -622,6 +622,32 @@ def test_sigmadetections_fromdict_no_condition():
622
622
)
623
623
624
624
625
+ def test_sigmadetections_empty_condition_list ():
626
+ with pytest .raises (
627
+ sigma_exceptions .SigmaConditionError , match = "at least one condition.*test.yml"
628
+ ):
629
+ SigmaDetections (
630
+ detections = {
631
+ "selection" : SigmaDetection ([SigmaDetectionItem ("key" , [], [SigmaString ("value" )])])
632
+ },
633
+ condition = [],
634
+ source = sigma_exceptions .SigmaRuleLocation ("test.yml" ),
635
+ )
636
+
637
+
638
+ def test_sigmadetections_none_condition ():
639
+ with pytest .raises (
640
+ sigma_exceptions .SigmaConditionError , match = "at least one condition.*test.yml"
641
+ ):
642
+ SigmaDetections (
643
+ detections = {
644
+ "selection" : SigmaDetection ([SigmaDetectionItem ("key" , [], [SigmaString ("value" )])])
645
+ },
646
+ condition = None ,
647
+ source = sigma_exceptions .SigmaRuleLocation ("test.yml" ),
648
+ )
649
+
650
+
625
651
def test_detectionitem_all_modified_key_plain_values_postprocess ():
626
652
"""
627
653
Test if postprocessed condition result of an all-modified field-bound value list results in an
You can’t perform that action at this time.
0 commit comments