# unchartedsecurity/laf architecture

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

- Interactive diagram: https://gitdiagram.com/unchartedsecurity/laf
- Repository: https://github.com/unchartedsecurity/laf

## Overview

##### Main Components

a. Kernel Space Components:
- eBPF Programs (from src/bpf directory)
- Linux Kernel Hooks
- Packet Filter Infrastructure

b. User Space Components:
- Python-based Control Program (src/main.py)
- Configuration Management
- Rule Engine
- User Interface Layer

**┌─────────────────────────────────────────┐**
- User Space                 │

- ┌──────────┐        ┌──────────────┐  │
- Python   │        │ Configuration│  │
- Control  │◄─────► │  Management  │  │
- Program  │        └──────────────┘  │
- ┬─────┘                          │
- ┼────────────────────────────────┘

- ▼
**┌─────────────────────────────────────────┐**
- Kernel Space               │
- ┌──────────┐        ┌──────────────┐  │
- eBPF    │◄─────► │   Kernel     │  │
- Programs │        │   Hooks      │  │
- ┘        └──────────────┘  │
- ┘

##### Key Elements to Highlight

a. Communication Flows:
- Bidirectional communication between user space and kernel space
- Packet inspection points
- Configuration data flow
- Rule application paths

b. Security Boundaries:
- User space/kernel space boundary
- Privileged operations
- Security policy enforcement points

##### Technical Details

- eBPF program loading paths
- Hook points in the kernel
- Configuration file locations
- Policy enforcement mechanisms
- Logging and monitoring paths

##### Implementation Notes

- Maintain consistent spacing and alignment
- Use standard networking and security symbols where applicable
- Brief annotations for complex interactions

##### Security boundaries and enforcement points

Remember to:
- Security-critical paths
- Both normal operation and error handling paths
- Monitoring and logging components

- How the firewall integrates with the Linux kernel
- The flow of packet filtering decisions
- Configuration and policy management
- Security boundaries and trust zones

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef userspace fill:#a8d1f0,stroke:#2c3e50
    classDef kernelspace fill:#ffb366,stroke:#994d00
    classDef config fill:#90EE90,stroke:#006400
    classDef security fill:#ff6666,stroke:#990000

    %% User Space Components
    subgraph UserSpace["User Space"]
        PythonControl["Python Control Program"]
        ConfigMgmt["Configuration Management"]
        RuleEngine["Rule Engine"]
        UI["User Interface Layer"]
        
        PythonControl --> ConfigMgmt
        ConfigMgmt --> RuleEngine
        UI --> PythonControl
    end

    %% Kernel Space Components
    subgraph KernelSpace["Kernel Space"]
        BPF["eBPF Programs"]
        KernelHooks["Kernel Hooks"]
        PacketFilter["Packet Filter Infrastructure"]
        
        BPF --> KernelHooks
        KernelHooks --> PacketFilter
    end

    %% Cross-boundary interactions
    PythonControl --> BPF
    RuleEngine --> BPF

    %% Add classes to components
    class PythonControl,ConfigMgmt,RuleEngine,UI userspace
    class BPF,KernelHooks,PacketFilter kernelspace

    %% Add click events for component mapping
    click PythonControl "https://github.com/UnchartedSecurity/LAF/blob/master/src/main.py"
    click BPF "https://github.com/UnchartedSecurity/LAF/blob/master/src/bpf/getpid.bpf"

    %% Legend
    subgraph Legend
        US["User Space Component"]:::userspace
        KS["Kernel Space Component"]:::kernelspace
    end
```
