|
20 | 20 |
|
21 | 21 | from app.translator.core.custom_types.meta_info import SeverityType |
22 | 22 | from app.translator.core.mitre import MitreConfig |
| 23 | +from app.translator.core.mixins.rule import YamlRuleMixin |
23 | 24 | from app.translator.core.models.platform_details import PlatformDetails |
24 | 25 | from app.translator.core.models.query_container import MetaInfoContainer, MitreInfoContainer, RawQueryContainer |
25 | 26 | from app.translator.managers import parser_manager |
26 | | -from app.translator.platforms.splunk.const import splunk_alert_details |
| 27 | +from app.translator.platforms.splunk.const import splunk_alert_details, splunk_alert_yml_details |
27 | 28 | from app.translator.platforms.splunk.mapping import SplunkMappings, splunk_alert_mappings |
28 | 29 | from app.translator.platforms.splunk.parsers.splunk import SplunkQueryParser |
29 | 30 |
|
@@ -73,3 +74,31 @@ def parse_raw_query(self, text: str, language: str) -> RawQueryContainer: |
73 | 74 | mitre_attack=mitre_attack_container, |
74 | 75 | ), |
75 | 76 | ) |
| 77 | + |
| 78 | + |
| 79 | +@parser_manager.register |
| 80 | +class SplunkAlertYMLParser(SplunkQueryParser, YamlRuleMixin): |
| 81 | + details: PlatformDetails = splunk_alert_yml_details |
| 82 | + mappings: SplunkMappings = splunk_alert_mappings |
| 83 | + mitre_config: MitreConfig = MitreConfig() |
| 84 | + |
| 85 | + def parse_raw_query(self, text: str, language: str) -> RawQueryContainer: |
| 86 | + rule = self.load_rule(text) |
| 87 | + mitre_attack_container = self.mitre_config.get_mitre_info( |
| 88 | + techniques=rule.get("tags", {}).get("mitre_attack_id", []) |
| 89 | + ) |
| 90 | + return RawQueryContainer( |
| 91 | + query=rule.get("search"), |
| 92 | + language=language, |
| 93 | + meta_info=MetaInfoContainer( |
| 94 | + id_=rule.get("id"), |
| 95 | + title=rule.get("name"), |
| 96 | + date=rule.get("date"), |
| 97 | + author=rule.get("author").split(", "), |
| 98 | + status=rule.get("status"), |
| 99 | + description=rule.get("description"), |
| 100 | + false_positives=rule.get("known_false_positives"), |
| 101 | + references=rule.get("references"), |
| 102 | + mitre_attack=mitre_attack_container, |
| 103 | + ), |
| 104 | + ) |
0 commit comments