# splunk/security_content architecture

> Architecture diagram of the GitHub repository splunk/security_content, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/splunk/security_content
- Repository: https://github.com/splunk/security_content

## Overview

##### Project Type and Purpose
- This is an open-source, content-as-code repository for Splunk Security Content—analytic stories, detections, macros, lookups, playbooks, baselines, and investigations—designed to be packaged and deployed into Splunk Enterprise Security (ES) as an ESCU app.
- Key indicators: directories like detections/, stories/, macros/, lookups/, playbooks/, baselines/, deploy­ments/, data_sources/, plus contentctl in README for validate/build/test and GitHub/GitLab workflows for CI/CD.

##### High-Level File Structure Analysis
- Top-level folders group logical Splunk app modules:
- detections/: individual search rules (YAML)
- stories/: grouped use cases/analytic stories
- macros/, lookups/: Splunk search macros and static lookup tables
- playbooks/: Phantom (SOAR) workflows (JSON/YAML/Python)
- baselines/, investigations/: pre-queries and timeline investigations
- data_sources/: metadata about required data inputs
- docs/, notebooks/: specification docs and Jupyter notebooks for ML enrichment
- Configuration/build files: .github/workflows/*, contentctl usage, contentctl.yml, contentctl validate/build/test commands.

##### Main Components
a. Developer Environment
- Local machine or Gitpod
- Python 3.11 venv running contentctl CLI
- Git operations (clone, new, validate, build, test)
b. Source Code Repository & CI/CD
- GitHub (and GitLab mirror) repo hosting content
- GitHub Actions (build.yml, unit-testing.yml) & GitLab CI
- contentctl invoked in CI to validate and build ESCU .spl package
c. Package & Release
- Build artifacts: ESCU Splunk app package (.spl)
- GitHub Releases & Splunkbase distribution
d. Testing Environments
- Splunk Attack Range / Attack Data / Atomic Red Team feeding simulated logs
- contentctl test framework executing detection tests
e. Splunk Enterprise Security (ES) Instance
- Indexers ingest logs from Data Sources (AWS CloudTrail, Sysmon, Network, etc.)
- Search Head with ESCU app installed
- Splunk ES uses content modules: macros, lookups, detections, stories
- Phantom Engine (SOAR) triggers playbooks on notable events
f. External Services & Integrations
- AWS S3 (reporting badges, images)
- MITRE ATT&CK mapping service (mitremap.splunkresearch.com)

##### Relationships & Data Flows
1. Developer → GitHub: push changes
2. GitHub Actions → contentctl validate/build/test → produce .spl package
3. CI → GitHub Releases/Splunkbase
4. Splunk Attack Range / Atomic Red Team → simulated log/events → Splunk Indexers
5. Splunk ES Search Head with ESCU app → runs searches (detections, baselines) against indexed data
6. Alerts → trigger Splunk Phantom playbooks (playbooks/*) for automated response
7. Stories module aggregates detection outputs → Security Posture dashboards

##### Architectural Patterns & Design Principles
- Mono-repo with logical content modules—modularity for maintainability.
- “Content as code” pattern: YAML definitions validated & tested via CI/CD.
- CI/CD pipeline ensures spec compliance (yaml-spec), build reproducibility (contentctl), and quality (unit tests, integration tests).
- Extensibility points: macros/ and lookups/ directories—users can override or augment.
- Data pipeline: content driven by data_sources/ definitions—clear contract with required TA/apps.

##### Essential Elements to Capture
- Separation between Developer/CI pipeline and Splunk runtime.
- Grouping of content modules inside the packaged Splunk app.
- Data ingestion and detection execution flow.
- Automation loop: detection → notable → playbook.
- External testing and enrichment sources.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Development & CI Pipeline
    subgraph "Development & CI Pipeline"
        direction TB
        DevMachine["Developer Environment\n(Local/Gitpod)"]:::pipeline
        GitpodConfig[".gitpod.yml"]:::pipeline
        ContentctlConfig["contentctl.yml"]:::pipeline
        GitHub["GitHub Repository"]:::pipeline
        subgraph "CI Workflows"
            direction TB
            BuildYml["build.yml"]:::pipeline
            UnitTestYml["unit-testing.yml"]:::pipeline
            AppInspectYml["appinspect.yml"]:::pipeline
            DependabotYml["datasource-dependabot.yml"]:::pipeline
            MRTemplate["release_branch.md"]:::pipeline
        end
        DevMachine -->|git push| GitHub
        DevMachine --> GitpodConfig
        DevMachine --> ContentctlConfig
        GitHub -->|triggers| BuildYml
        GitHub --> UnitTestYml
        GitHub --> AppInspectYml
        GitHub --> DependabotYml
        GitHub --> MRTemplate
        BuildYml -->|run contentctl validate/build/test| ContentctlConfig
        UnitTestYml -->|run contentctl test| ContentctlConfig
        AppInspectYml -->|run appinspect| GitHub
        DependabotYml -->|manage data_sources dependencies| GitHub
        BuildYml -->|output .spl package| DistDir
    end

    %% Release Artifacts
    DistDir["dist/ (Release Artifacts)"]:::pipeline
    GitHub -->|create release| DistDir

    %% Testing & Enrichment
    subgraph "Testing & Enrichment" 
        direction TB
        AttackRange["Splunk Attack Range"]:::test
        AtomicRed["Atomic Red Team"]:::test
        MITREMap["MITRE ATT&CK Mapping Service"]:::test
        AWSBadge["AWS S3 (Badges/Images)"]:::test
    end
    AttackRange -->|simulate logs| Indexers
    AtomicRed -->|simulate events| Indexers
    MITREMap -->|provide mappings| StoriesModule
    AWSBadge -->|store badges| Docs

    %% Splunk Runtime
    subgraph "Splunk Enterprise Security Runtime"
        direction TB
        Indexers["Splunk Indexers"]:::runtime
        SearchHead["Splunk Search Head\n+ ESCU App Installed"]:::runtime
        PhantomEngine["Splunk Phantom Engine"]:::runtime
        subgraph "ESCU App Content Modules"
            direction TB
            Detections["detections/"]:::module
            StoriesModule["stories/"]:::module
            Macros["macros/"]:::module
            Lookups["lookups/"]:::module
            Playbooks["playbooks/"]:::module
            Baselines["baselines/"]:::module
            Investigations["investigations/"]:::module
            DataSources["data_sources/"]:::module
            Deployments["deployments/"]:::module
            Docs["docs/"]:::module
            YamlSpec["docs/yaml-spec/"]:::module
            Notebooks["notebooks/"]:::module
            AppTemplate["app_template/"]:::module
            AppUI["app_template/default/data/ui/"]:::module
        end
        Indexers -->|HTTP Event Collector| SearchHead
        SearchHead -->|runs detections/baselines/stories| Indexers
        SearchHead -->|executes playbooks| PhantomEngine
        PhantomEngine -->|automated response| SearchHead
    end

    %% Click Events
    click GitpodConfig "https://github.com/splunk/security_content/blob/develop/.gitpod.yml"
    click ContentctlConfig "https://github.com/splunk/security_content/blob/develop/contentctl.yml"
    click BuildYml "https://github.com/splunk/security_content/blob/develop/.github/workflows/build.yml"
    click UnitTestYml "https://github.com/splunk/security_content/blob/develop/.github/workflows/unit-testing.yml"
    click AppInspectYml "https://github.com/splunk/security_content/blob/develop/.github/workflows/appinspect.yml"
    click DependabotYml "https://github.com/splunk/security_content/blob/develop/.github/workflows/datasource-dependabot.yml"
    click MRTemplate "https://github.com/splunk/security_content/blob/develop/.gitlab/merge_request_templates/release_branch.md"
    click DistDir "https://github.com/splunk/security_content/tree/develop/dist/"
    click Detections "https://github.com/splunk/security_content/tree/develop/detections/"
    click StoriesModule "https://github.com/splunk/security_content/tree/develop/stories/"
    click Macros "https://github.com/splunk/security_content/tree/develop/macros/"
    click Lookups "https://github.com/splunk/security_content/tree/develop/lookups/"
    click Playbooks "https://github.com/splunk/security_content/tree/develop/playbooks/"
    click Baselines "https://github.com/splunk/security_content/tree/develop/baselines/"
    click Investigations "https://github.com/splunk/security_content/tree/develop/removed/investigations/"
    click DataSources "https://github.com/splunk/security_content/tree/develop/data_sources/"
    click Deployments "https://github.com/splunk/security_content/tree/develop/deployments/"
    click Docs "https://github.com/splunk/security_content/tree/develop/docs/"
    click YamlSpec "https://github.com/splunk/security_content/tree/develop/docs/yaml-spec/"
    click Notebooks "https://github.com/splunk/security_content/tree/develop/notebooks/"
    click AppTemplate "https://github.com/splunk/security_content/tree/develop/app_template/"
    click AppUI "https://github.com/splunk/security_content/tree/develop/app_template/default/data/ui/"

    %% Styles
    classDef pipeline fill:#D0E8FF,stroke:#0066CC,color:#000
    classDef runtime fill:#DFF2D8,stroke:#339900,color:#000
    classDef test fill:#FFE5CC,stroke:#FF9900,color:#000
    classDef module fill:#FFFFFF,stroke:#666666,color:#000,stroke-dasharray: 5 5
```
