Skip to content

Commit

Permalink
feat!: Adding splunk security content to dataset.
Browse files Browse the repository at this point in the history
Closes Add Splunk Detections to Dataset  #6
  • Loading branch information
MSAdministrator committed Jul 8, 2023
1 parent 717033c commit ea7b52f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions data_collector/src/data_collector/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .services.osqueryattack import OsqueryAttack
from .services.stockpile import MitreStockpile
from .services.sysmonhunter import SysmonHunter
from .services.splunkcontent import SplunkSecurityContent


class Collector(Base):
Expand Down Expand Up @@ -53,6 +54,7 @@ def collect(self) -> None:
OsqueryAttack,
MitreStockpile,
SysmonHunter,
SplunkSecurityContent,
]:
self.__logger.info(f"Collecting data from {service.__name__}")
service().parse()
Expand Down
34 changes: 34 additions & 0 deletions data_collector/src/data_collector/services/splunkcontent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from .base import Base


class SplunkSecurityContent(Base):
"""
Data Source: https://raw.githubusercontent.com/splunk/security_content/develop/dist/api/detections.json
Authors:
- Splunk
This class is a wrapper for the above data set
"""
URL = 'https://raw.githubusercontent.com/splunk/security_content/develop/dist/api/detections.json'

def parse(self):
self.count = 0
self.actor_count = 0
data = self.session.get(self.URL).json()
for item in data.get("detections"):
if item.get("tags"):
if item["tags"].get("mitre_attack_enrichments"):
for enrichment in item["tags"]["mitre_attack_enrichments"]:
if enrichment.get("mitre_attack_id"):
tech = self.helper.get_object_by_external_id(enrichment["mitre_attack_id"], "attack-pattern")
tech.possible_detections.append({"name": item["name"], "description": item["description"], "search": item["search"], "tags": item["tags"]})
tech.external_references.extend(item.get("external_references",[]))
self.count += 1
self.helper.replace_object(tech)
if enrichment.get("mitre_attack_groups"):
for group in enrichment["mitre_attack_groups"]:
actor = self.helper.get_object_by_name_or_aliases(group, "intrusion-set")
actor.links.extend(item.get("external_references", []))
self.actor_count += 1
self.helper.replace_object(actor)
self.__logger.info(f"Updated {self.count} techniques and {self.actor_count} actors")
1 change: 1 addition & 0 deletions src/pyattck_data/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Actor(BaseModel):
targets: List = field(factory=list)
external_description: List = field(factory=list)
attck_id: AnyStr = field(factory=str)
attck_ids: List = field(factory=list)
comment: AnyStr = field(factory=str)
comments: List = field(factory=list)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import requests

from pyattck_data.attack import MitreAttck
from pyattck_data.generated import GeneratedData
from pyattck_data.nist import NistControls, GeneratedNistControlMap
from pyattck_data.malware import Malware
from pyattck_data.tool import Tool
Expand All @@ -13,7 +12,8 @@
from pyattck_data.tactic import Tactic
from pyattck_data.technique import Technique
from pyattck_data.campaign import Campaign



ENTERPRISE_ATTCK_JSON = requests.get("https://swimlane-pyattck.s3.us-west-2.amazonaws.com/merged_enterprise_attck_v1.json").json()
PRE_ATTCK_JSON = requests.get("https://swimlane-pyattck.s3.us-west-2.amazonaws.com/merged_pre_attck_v1.json").json()
MOBILE_ATTCK_JSON = requests.get("https://swimlane-pyattck.s3.us-west-2.amazonaws.com/merged_mobile_attck_v1.json").json()
Expand Down

0 comments on commit ea7b52f

Please sign in to comment.