# redborder/redborder-intrusion architecture

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

- Interactive diagram: https://gitdiagram.com/redborder/redborder-intrusion
- Repository: https://github.com/redborder/redborder-intrusion

## Overview

##### Project Type and Purpose
- The project is a packaged software tool intended for installing and managing the "redborder intrusion" system on Rocky Linux 9.
- It primarily serves as an intrusion detection solution (a variant of redborder-ips) but now using snort3 (and notably without barnyard2). It includes system initialization routines, configuration management (using Chef templates), and various operational scripts for managing sensor tasks.
- Since the product is distributed via an RPM (packaging and spec files are present), it’s designed for system-level deployment in enterprise/security environments.

##### File Structure for Architectural Clues
- There is a clear separation between packaging, deployment, and execution resources.
- Key directories and files:
- .github: Contains CI/CD workflows (e.g., rpm.yml) to automate builds and testing.
- packaging: Contains RPM packaging components including a spec file and Makefile for building the package.
- resources:
▫ bin: Contains shell scripts (e.g., rb_bypass.sh, rb_clean_logs_snort.sh, etc.) that are likely executable commands to control or interact with the intrusion detection system.
▫ lib: Contains various utility scripts and libraries written in Ruby and shell (such as rb_config_utils.rb, rb_functions.sh, wizard_helper.rb) which encapsulate configuration and operational logic.
▫ scripts: Contains Ruby scripts that automate tasks (such as sensor association, configuration initialization, and updates). These come together as supporting components for dynamic actions like initializing and setting up configuration via a wizard.
▫ systemd: Contains a service file (rb-init-conf.service) that integrates the intrusion detection tool with the system’s init system, ensuring that configurations and initialization are automatically applied on boot or triggered when needed.
- The top-level Makefile, VERSION, and LICENSE are also included for build management, version control, and legal clarity.

##### README for Additional Insights
- The README succinctly explains that this is the “Main package to install redborder intrusion” on Rocky Linux 9 and highlights its relationship to snort3.
- The installation instructions mention adding the redborder repository and installing via yum, emphasizing its packaging and deployment nature.

##### Main Components
a. Packaging & Deployment:
- RPM Packaging module (packaging/rpm and .github/workflows support) which builds and automates package deployment.
- Integration of the RPM via the build scripts and Makefile.
b. Core Execution & Management:
- Main executable script (resources/redborder-intrusion.sh) that likely acts as the central entry point.
- A collection of control scripts (in resources/bin) to perform operational duties (bypass, clean logs, update configurations, handle performance stats, etc.).
c. Configuration & Initialization:
- Libraries and helper scripts (resources/lib) that provide utility functions for configuration and management.
- Initialization scripts (resources/scripts) that may execute configuration routines, sensor association, and wizard-driven setups.
- Default configuration files (resources/etc) including Chef configuration files – these ensure that system configuration is dynamically applied.
d. Service Integration:
- The systemd integration (resources/systemd/rb-init-conf.service) indicates that part of the package includes auto-start and initialization on system startup.
e. External Dependencies & Integrations:
- Snort3 as the core intrusion detection mechanism.
- Chef for configuration management.
- Underlying Rocky Linux 9 environment and its service management.

##### Relationships and Interactions
- How the RPM packaging is built and deployed, feeding the system installation which then provides:
- A systemd-managed service (rb-init-conf) that kicks off configuration routines.
- A main executable script that, through a series of shell and Ruby scripts (located in the resources/bin, resources/lib, and resources/scripts directories), facilitates installation, configuration, and ongoing monitoring.
- That configuration files in resources/etc, including Chef JSON files, are consumed by the configuration scripts to dynamically adjust the behavior of the system.
- That the build pipelines from .github are responsible for validating and packaging the code before it is released to the repository for installation on Rocky Linux systems.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build & Deployment
    subgraph "Build & Deployment"
        CI["CI/CD Pipeline"]:::build
        RPM["RPM Packaging Module"]:::build
    end

    %% Runtime Components
    subgraph "Runtime Components"
        SYS["Systemd Service Integration"]:::runtime
        MAIN["Main Execution Script"]:::runtime
        OPS["Operational Control Scripts"]:::runtime
        INIT["Initialization & Setup Scripts"]:::runtime
        UTIL["Utility Libraries"]:::runtime
        CFG["Configuration Files & Chef Templates"]:::config
    end

    %% External Systems
    subgraph "External Systems"
        SNORT["Snort3 Intrusion Detection"]:::external
        CHEF["Chef Configuration Management"]:::external
        OS["Rocky Linux 9 Environment"]:::external
    end

    %% Connections
    CI -->|"builds"| RPM
    RPM -->|"deploys"| SYS
    SYS -->|"triggers"| MAIN
    MAIN -->|"calls"| OPS
    MAIN -->|"invokes"| INIT
    INIT -->|"uses"| UTIL
    CFG -->|"supplies"| INIT
    RPM -->|"installs_on"| OS
    MAIN -->|"monitors"| SNORT
    CFG -->|"configures"| CHEF

    %% Click Events
    click CI "https://github.com/redborder/redborder-intrusion/blob/master/.github/workflows/rpm.yml"
    click RPM "https://github.com/redborder/redborder-intrusion/blob/master/packaging/rpm/redborder-intrusion.spec"
    click MAIN "https://github.com/redborder/redborder-intrusion/blob/master/resources/redborder-intrusion.sh"
    click OPS "https://github.com/redborder/redborder-intrusion/tree/master/resources/bin"
    click INIT "https://github.com/redborder/redborder-intrusion/tree/master/resources/scripts"
    click UTIL "https://github.com/redborder/redborder-intrusion/tree/master/resources/lib"
    click CFG "https://github.com/redborder/redborder-intrusion/tree/master/resources/etc"
    click SYS "https://github.com/redborder/redborder-intrusion/blob/master/resources/systemd/rb-init-conf.service"

    %% Styles
    classDef build fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef runtime fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef config fill:#FFFFE0,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA07A,stroke:#000,stroke-width:2px;
```
