@@ -1516,6 +1516,66 @@ def test_addconditiontransformation_negated(dummy_pipeline, sigma_rule: SigmaRul
15161516 )
15171517
15181518
1519+ def test_addconditiontransformation_empty_condition (dummy_pipeline , sigma_rule : SigmaRule ):
1520+ """Test that AddConditionTransformation correctly handles empty conditions (e.g., when all query terms are deferred)"""
1521+ # Manually set condition to empty string to simulate deferred query scenario
1522+ sigma_rule .detection .parsed_condition [0 ].condition = ""
1523+
1524+ transformation = AddConditionTransformation (
1525+ {
1526+ "newfield1" : "test" ,
1527+ },
1528+ "additional" ,
1529+ )
1530+ transformation .set_processing_item (
1531+ ProcessingItem (
1532+ transformation ,
1533+ identifier = "test" ,
1534+ )
1535+ )
1536+ transformation .set_pipeline (dummy_pipeline )
1537+ transformation .apply (sigma_rule )
1538+
1539+ # When condition is empty, should result in just "additional", not "additional and ()"
1540+ assert (
1541+ sigma_rule .detection .parsed_condition [0 ].condition == "additional"
1542+ and sigma_rule .detection .detections ["additional" ]
1543+ == SigmaDetection (
1544+ [
1545+ SigmaDetectionItem ("newfield1" , [], [SigmaString ("test" )]),
1546+ ]
1547+ )
1548+ and sigma_rule .was_processed_by ("test" )
1549+ )
1550+
1551+
1552+ def test_addconditiontransformation_empty_condition_negated (dummy_pipeline , sigma_rule : SigmaRule ):
1553+ """Test that AddConditionTransformation correctly handles empty conditions with negation"""
1554+ # Manually set condition to empty string to simulate deferred query scenario
1555+ sigma_rule .detection .parsed_condition [0 ].condition = ""
1556+
1557+ transformation = AddConditionTransformation (
1558+ {
1559+ "newfield1" : "test" ,
1560+ },
1561+ "additional" ,
1562+ negated = True ,
1563+ )
1564+ transformation .set_processing_item (
1565+ ProcessingItem (
1566+ transformation ,
1567+ identifier = "test" ,
1568+ )
1569+ )
1570+ transformation .set_pipeline (dummy_pipeline )
1571+ transformation .apply (sigma_rule )
1572+
1573+ # When condition is empty and negated, should result in just "not additional", not "not additional and ()"
1574+ assert sigma_rule .detection .parsed_condition [
1575+ 0
1576+ ].condition == "not additional" and sigma_rule .was_processed_by ("test" )
1577+
1578+
15191579### ChangeLogsourceTransformation ###
15201580def test_changelogsource (dummy_pipeline , sigma_rule : SigmaRule ):
15211581 processing_item = ProcessingItem (
0 commit comments