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
12 changes: 12 additions & 0 deletions config/pipeline_config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,25 @@ parsers:
lowercase: True
path_templates: tests/test_folder/audit_templates.txt

JsonMatcherParser:
method_type: matcher_parser
auto_config: False
log_format: "<Content>"
time_format: null
params:
remove_spaces: True
remove_punctuation: True
lowercase: True
path_templates: local/miranda_templates.txt

JsonParser:
method_type: json_parser
time_format: null
auto_config: False
params:
timestamp_name: "time"
content_name: "message"
content_parser: JsonMatcherParser

detectors:
RandomDetector:
Expand Down
4 changes: 3 additions & 1 deletion src/detectmatelibrary/parsers/json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class JsonParserConfig(CoreParserConfig):
method_type: str = "json_parser"
timestamp_name: str = "time"
content_name: str = "message"
content_parser: str = "JsonMatcherParser"


class JsonParser(CoreParser):
Expand All @@ -57,7 +58,8 @@ def __init__(
) -> None:

if isinstance(config, dict):
content_parser_config = MatcherParserConfig.from_dict(config, "MatcherParser")
content_parser_name = config.get("content_parser", "JsonMatcherParser")
content_parser_config = MatcherParserConfig.from_dict(config, content_parser_name)
self.content_parser = MatcherParser(config=content_parser_config)
config = JsonParserConfig.from_dict(config, name)
super().__init__(name=name, config=config)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parsers/test_json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_parse_with_content_parser(self):
"timestamp_name": "time",
"content_name": "message",
},
"MatcherParser": {
"JsonMatcherParser": {
"auto_config": True,
"method_type": "matcher_parser",
"path_templates": "tests/test_folder/test_templates.txt"
Expand Down