From 0a55953d245d6a403e8388e790f87f2c8d8c0596 Mon Sep 17 00:00:00 2001 From: viktorbeck98 Date: Mon, 30 Mar 2026 12:26:36 +0200 Subject: [PATCH] path_templates is not longer required by the MatcherParser --- .../parsers/template_matcher/_parser.py | 7 +++++-- tests/test_parsers/test_template_matcher.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/detectmatelibrary/parsers/template_matcher/_parser.py b/src/detectmatelibrary/parsers/template_matcher/_parser.py index 3192a84..67fb5a8 100644 --- a/src/detectmatelibrary/parsers/template_matcher/_parser.py +++ b/src/detectmatelibrary/parsers/template_matcher/_parser.py @@ -52,7 +52,7 @@ class MatcherParserConfig(CoreParserConfig): remove_punctuation: bool = True lowercase: bool = True - path_templates: str = "" + path_templates: str | None = None class MatcherParser(CoreParser): @@ -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, diff --git a/tests/test_parsers/test_template_matcher.py b/tests/test_parsers/test_template_matcher.py index c5c892e..04e4bdc 100644 --- a/tests/test_parsers/test_template_matcher.py +++ b/tests/test_parsers/test_template_matcher.py @@ -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 == "" + assert output_data.EventID == -1 + assert output_data.variables == [] + def test_templates_not_found(self): config_dict = { "parsers": {