Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/detectmatelibrary/parsers/template_matcher/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MatcherParserConfig(CoreParserConfig):
remove_punctuation: bool = True
lowercase: bool = True

path_templates: str = "<PLACEHOLDER>"
path_templates: str | None = None


class MatcherParser(CoreParser):
Expand All @@ -67,8 +67,11 @@ def __init__(
super().__init__(name=name, config=config)
self.config: MatcherParserConfig

templates = load_templates(
self.config.path_templates
) if self.config.path_templates is not None else []
self.template_matcher = TemplateMatcher(
template_list=load_templates(self.config.path_templates),
template_list=templates,
remove_spaces=self.config.remove_spaces,
remove_punctuation=self.config.remove_punctuation,
lowercase=self.config.lowercase,
Expand Down
18 changes: 18 additions & 0 deletions tests/test_parsers/test_template_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@


class TestMatcherParserBasic:
def test_no_path_templates(self):
config_dict = {
"parsers": {
"MatcherParser": {
"auto_config": True,
"method_type": "matcher_parser",
}
}
}
parser = MatcherParser(name="MatcherParser", config=config_dict)
input_log = schemas.LogSchema({"log": test_log_match})
output_data = schemas.ParserSchema()
parser.parse(input_log, output_data)

assert output_data.template == "<Not Found>"
assert output_data.EventID == -1
assert output_data.variables == []

def test_templates_not_found(self):
config_dict = {
"parsers": {
Expand Down
Loading