Skip to content

Gis 8503 #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 12, 2024
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
2 changes: 1 addition & 1 deletion uncoder-core/app/translator/platforms/splunk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from app.translator.platforms.splunk.parsers.splunk import SplunkQueryParser # noqa: F401
from app.translator.platforms.splunk.parsers.splunk_alert import SplunkAlertParser # noqa: F401
from app.translator.platforms.splunk.parsers.splunk_alert import SplunkAlertParser, SplunkAlertYMLParser # noqa: F401
from app.translator.platforms.splunk.renders.splunk import SplunkQueryRender # noqa: F401
from app.translator.platforms.splunk.renders.splunk_alert import SplunkAlertRender # noqa: F401
from app.translator.platforms.splunk.renders.splunk_cti import SplunkCTI # noqa: F401
9 changes: 9 additions & 0 deletions uncoder-core/app/translator/platforms/splunk/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,14 @@
**PLATFORM_DETAILS,
}

SPLUNK_ALERT_YML_DETAILS = {
"platform_id": "splunk-spl-rule-yml",
"name": "Splunk Alert YML",
"platform_name": "Alert (SPL) YML",
"first_choice": 0,
**PLATFORM_DETAILS,
}

splunk_query_details = PlatformDetails(**SPLUNK_QUERY_DETAILS)
splunk_alert_details = PlatformDetails(**SPLUNK_ALERT_DETAILS)
splunk_alert_yml_details = PlatformDetails(**SPLUNK_ALERT_YML_DETAILS)
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

from app.translator.core.custom_types.meta_info import SeverityType
from app.translator.core.mitre import MitreConfig
from app.translator.core.mixins.rule import YamlRuleMixin
from app.translator.core.models.platform_details import PlatformDetails
from app.translator.core.models.query_container import MetaInfoContainer, MitreInfoContainer, RawQueryContainer
from app.translator.managers import parser_manager
from app.translator.platforms.splunk.const import splunk_alert_details
from app.translator.platforms.splunk.const import splunk_alert_details, splunk_alert_yml_details
from app.translator.platforms.splunk.mapping import SplunkMappings, splunk_alert_mappings
from app.translator.platforms.splunk.parsers.splunk import SplunkQueryParser

Expand Down Expand Up @@ -73,3 +74,45 @@ def parse_raw_query(self, text: str, language: str) -> RawQueryContainer:
mitre_attack=mitre_attack_container,
),
)


@parser_manager.register
class SplunkAlertYMLParser(SplunkQueryParser, YamlRuleMixin):
details: PlatformDetails = splunk_alert_yml_details
mappings: SplunkMappings = splunk_alert_mappings
mitre_config: MitreConfig = MitreConfig()

def parse_raw_query(self, text: str, language: str) -> RawQueryContainer:
rule = self.load_rule(text)
mitre_attack_container = self.mitre_config.get_mitre_info(
techniques=rule.get("tags", {}).get("mitre_attack_id", [])
)
description = rule.get("description", "")
if rule.get("how_to_implement", ""):
description = f'{description} {rule.get("how_to_implement", "")}'
tags = rule.get("tags", {}).get("analytic_story", [])
if rule.get("type"):
tags.append(rule.get("type"))
false_positives = None
if rule.get("known_false_positives"):
false_positives = (
rule["known_false_positives"]
if isinstance(rule["known_false_positives"], list)
else [rule["known_false_positives"]]
)
return RawQueryContainer(
query=rule.get("search"),
language=language,
meta_info=MetaInfoContainer(
id_=rule.get("id"),
title=rule.get("name"),
date=rule.get("date"),
author=rule.get("author").split(", "),
status=rule.get("status"),
description=description,
false_positives=false_positives,
references=rule.get("references"),
mitre_attack=mitre_attack_container,
tags=tags,
),
)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy