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