|
21 | 21 | SigmaRegularExpression, |
22 | 22 | SigmaTimestampPart, |
23 | 23 | TimestampPart, |
| 24 | + SigmaCompareExpression, |
24 | 25 | ) |
25 | 26 | from sigma.modifiers import ( |
26 | 27 | SigmaBase64Modifier, |
@@ -1692,7 +1693,7 @@ def test_sigmarule_bad_scope(): |
1692 | 1693 | ) |
1693 | 1694 |
|
1694 | 1695 |
|
1695 | | -def test_sigmarule_timestamp_modifiers(): |
| 1696 | +def test_sigmarule_timestamp_modifiers_equals(): |
1696 | 1697 | rule = SigmaRule.from_dict( |
1697 | 1698 | { |
1698 | 1699 | "title": "Test", |
@@ -1721,3 +1722,35 @@ def test_sigmarule_timestamp_modifiers(): |
1721 | 1722 | assert detection_items[3].value[0] == SigmaTimestampPart(TimestampPart.WEEK, 4) |
1722 | 1723 | assert detection_items[4].value[0] == SigmaTimestampPart(TimestampPart.MONTH, 5) |
1723 | 1724 | assert detection_items[5].value[0] == SigmaTimestampPart(TimestampPart.YEAR, 6) |
| 1725 | + |
| 1726 | + |
| 1727 | +def test_sigmarule_timestamp_modifiers_greater_than(): |
| 1728 | + rule = SigmaRule.from_dict( |
| 1729 | + { |
| 1730 | + "title": "Test", |
| 1731 | + "logsource": { |
| 1732 | + "category": "process_creation", |
| 1733 | + "product": "windows", |
| 1734 | + }, |
| 1735 | + "detection": { |
| 1736 | + "selection": { |
| 1737 | + "timestamp|minute|gt": 1, |
| 1738 | + "timestamp|hour|gte": 2, |
| 1739 | + "timestamp|day|lt": 3, |
| 1740 | + "timestamp|week|lte": 4, |
| 1741 | + "timestamp|month|gt": 5, |
| 1742 | + "timestamp|year|gte": 6, |
| 1743 | + }, |
| 1744 | + "condition": "selection", |
| 1745 | + }, |
| 1746 | + }, |
| 1747 | + source=sigma_exceptions.SigmaRuleLocation("test.yml"), |
| 1748 | + ) |
| 1749 | + detection_items = rule.detection["selection"].detection_items |
| 1750 | + assert isinstance(detection_items[0].value[0], SigmaCompareExpression) |
| 1751 | + assert detection_items[0].value[0].number == SigmaTimestampPart(TimestampPart.MINUTE, 1) |
| 1752 | + assert detection_items[1].value[0].number == SigmaTimestampPart(TimestampPart.HOUR, 2) |
| 1753 | + assert detection_items[2].value[0].number == SigmaTimestampPart(TimestampPart.DAY, 3) |
| 1754 | + assert detection_items[3].value[0].number == SigmaTimestampPart(TimestampPart.WEEK, 4) |
| 1755 | + assert detection_items[4].value[0].number == SigmaTimestampPart(TimestampPart.MONTH, 5) |
| 1756 | + assert detection_items[5].value[0].number == SigmaTimestampPart(TimestampPart.YEAR, 6) |
0 commit comments