Skip to content

Commit 615dfc4

Browse files
committed
cleanup
1 parent 4cace27 commit 615dfc4

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66
* add support for python 3.14
7+
* allow pre-detector to copy a configurable list of fields from log to detection event
78

89
### Improvements
910
* add workflow to partially run & check the compose example
@@ -15,6 +16,7 @@
1516
* fix docker-compose and k8s example setups
1617
* fix handling of non-string values (e.g. int) as replacement argument for `generic_resolver`
1718
* fix documentation for `generic_resolver` rule `append_to_list -> merge_with_target` option
19+
* fix grokker using a fixed directory for downloaded patterns, potentially leading to conflicts between processes
1820

1921
## 17.0.3
2022
### Breaking

logprep/ng/processor/pre_detector/processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def _generate_detection_result(
149149
copy_fields_to_event(
150150
target_event=detection_result,
151151
source_event=event,
152-
dotted_field_names=rule.copy_fields_to_detector_event,
152+
dotted_field_names=rule.copy_fields_to_detection_event,
153153
rule=rule,
154154
skip_missing=True,
155155
)

logprep/processor/pre_detector/processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def _generate_detection_result(
160160
copy_fields_to_event(
161161
target_event=detection_result,
162162
source_event=event,
163-
dotted_field_names=rule.copy_fields_to_detector_event,
163+
dotted_field_names=rule.copy_fields_to_detection_event,
164164
rule=rule,
165165
skip_missing=True,
166166
)

logprep/processor/pre_detector/rule.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@
136136
"target_timezone",
137137
"timestamp_field",
138138
"failure_tags",
139-
"copy_fields_to_detector_event",
139+
"copy_fields_to_detection_event",
140140
}
141141

142142

143-
def _validate_copy_fields_to_detector_event(config: "PreDetectorRule.Config", _, value: set[str]):
143+
def _validate_copy_fields_to_detection_event(config: "PreDetectorRule.Config", _, value: set[str]):
144144
field_names_set_by_processor = {"rule_filter", "description", "pre_detection_id"}
145145

146146
rule_config_field_names = set(f.name for f in fields(type(config)))
@@ -150,7 +150,7 @@ def _validate_copy_fields_to_detector_event(config: "PreDetectorRule.Config", _,
150150

151151
if value & illegal_field_names:
152152
raise ValueError(
153-
f"Illegal fields specified for `copy_fields_to_detector_event`. "
153+
f"Illegal fields specified for `copy_fields_to_detection_event`. "
154154
f"Fields ({', '.join(value & illegal_field_names)}) are not allowed. "
155155
)
156156

@@ -206,15 +206,15 @@ class Config(Rule.Config): # pylint: disable=too-many-instance-attributes
206206
validator=validators.instance_of(list), default=["pre_detector_failure"]
207207
)
208208
""" tags to be added if processing of the rule fails"""
209-
copy_fields_to_detector_event: set[str] = field(
209+
copy_fields_to_detection_event: set[str] = field(
210210
validator=[
211211
validators.deep_iterable(
212212
member_validator=validators.instance_of(str),
213213
iterable_validator=validators.or_(
214214
validators.instance_of(set), validators.instance_of(list)
215215
),
216216
),
217-
_validate_copy_fields_to_detector_event,
217+
_validate_copy_fields_to_detection_event,
218218
],
219219
converter=set,
220220
default={"host.name"},
@@ -274,7 +274,7 @@ def timestamp_field(self) -> str:
274274
return self.config.timestamp_field
275275

276276
@property
277-
def copy_fields_to_detector_event(self) -> set[str]:
278-
return self.config.copy_fields_to_detector_event
277+
def copy_fields_to_detection_event(self) -> set[str]:
278+
return self.config.copy_fields_to_detection_event
279279

280280
# pylint: enable=C0111

tests/unit/processor/pre_detector/test_pre_detector.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def test_perform_successful_pre_detection_with_custom_field_copied(self):
501501
"severity": "critical",
502502
"mitre": ["attack.test1", "attack.test2"],
503503
"case_condition": "directly",
504-
"copy_fields_to_detector_event": {"custom", "winlog.custom"},
504+
"copy_fields_to_detection_event": {"custom", "winlog.custom"},
505505
},
506506
"description": "Test rule one",
507507
}
@@ -547,7 +547,7 @@ def test_perform_successful_pre_detection_with_nothing_extra_copied(self):
547547
"severity": "critical",
548548
"mitre": ["attack.test1", "attack.test2"],
549549
"case_condition": "directly",
550-
"copy_fields_to_detector_event": set(),
550+
"copy_fields_to_detection_event": set(),
551551
},
552552
"description": "Test rule one",
553553
}
@@ -581,7 +581,7 @@ def test_perform_successful_pre_detection_with_nothing_extra_copied(self):
581581
document, expected, detection_results.data, expected_detection_results
582582
)
583583

584-
def test_copy_fields_to_detector_event_validation_supports_lists(self):
584+
def test_copy_fields_to_detection_event_validation_supports_lists(self):
585585
self._load_rule(
586586
{
587587
"filter": "*",
@@ -591,13 +591,13 @@ def test_copy_fields_to_detector_event_validation_supports_lists(self):
591591
"severity": "critical",
592592
"mitre": ["attack.test1", "attack.test2"],
593593
"case_condition": "directly",
594-
"copy_fields_to_detector_event": ["host.name"],
594+
"copy_fields_to_detection_event": ["host.name"],
595595
},
596596
"description": "Test rule one",
597597
}
598598
)
599599

600-
def test_copy_fields_to_detector_event_validation_supports_sets(self):
600+
def test_copy_fields_to_detection_event_validation_supports_sets(self):
601601
self._load_rule(
602602
{
603603
"filter": "*",
@@ -607,7 +607,7 @@ def test_copy_fields_to_detector_event_validation_supports_sets(self):
607607
"severity": "critical",
608608
"mitre": ["attack.test1", "attack.test2"],
609609
"case_condition": "directly",
610-
"copy_fields_to_detector_event": {"host.name"},
610+
"copy_fields_to_detection_event": {"host.name"},
611611
},
612612
"description": "Test rule one",
613613
}
@@ -627,7 +627,7 @@ def test_copy_fields_to_detector_event_validation_supports_sets(self):
627627
"link",
628628
],
629629
)
630-
def test_copy_fields_to_detector_event_fails_on_illegal_fields(self, field_name: str):
630+
def test_copy_fields_to_detection_event_fails_on_illegal_fields(self, field_name: str):
631631
with pytest.raises(ValueError, match="Illegal fields") as exc_info:
632632
self._load_rule(
633633
{
@@ -638,7 +638,7 @@ def test_copy_fields_to_detector_event_fails_on_illegal_fields(self, field_name:
638638
"severity": "critical",
639639
"mitre": ["attack.test1", "attack.test2"],
640640
"case_condition": "directly",
641-
"copy_fields_to_detector_event": {field_name},
641+
"copy_fields_to_detection_event": {field_name},
642642
},
643643
"description": "Test rule one",
644644
}

0 commit comments

Comments
 (0)