# fabriziosalmi/patterns architecture

> Architecture diagram of the GitHub repository fabriziosalmi/patterns, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fabriziosalmi/patterns
- Repository: https://github.com/fabriziosalmi/patterns

## Overview

##### Main System Components

A. Input Sources Layer
- OWASP CRS Rules Repository
- Bad Bot Lists Sources
- Manual Triggers (GitHub Actions)

B. Processing Layer (Core Components)
- OWASP Rules Scraper
- Pattern Converters
- Bot Detection System

C. Output Layer
- Web Server Configurations
- Deployment Mechanisms

##### Data Flow Representation

- Daily automated flow from OWASP CRS → Scraper → Converters → Configs
- Bot list processing flow
- Configuration deployment paths

##### Component Relationships

Key interactions:
**OWASP CRS → owasp.py → JSON → owasp2{server}.py → Server Configs**
**Bad Bot Lists → badbots.py → Server-specific bot rules**

##### Technical Details

Annotations for:
- Python script dependencies
- Configuration file formats
- Update frequency
- Supported attack patterns (SQLi, XSS, RCE, LFI)

##### Deployment Flow

Highlight:
- GitHub Actions workflow
- Configuration file generation
- Server integration process

##### Additional Elements

Include:
- Version control integration
- Error handling mechanisms
- Fallback paths
- Monitoring points

Remember to emphasize the daily update mechanism and the separation between pattern generation and server integration components. This will help viewers understand both the automated and manual aspects of the system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Input Layer
    subgraph InputLayer["Input Sources Layer"]
        OWASP[("OWASP CRS Rules")]:::source
        BotLists[("Bad Bot Lists")]:::source
        GHActions["GitHub Actions"]:::automation
    end

    %% Processing Layer
    subgraph ProcessingLayer["Processing Layer"]
        Scraper["OWASP Rules Scraper"]:::processor
        RulesJSON[("Rules JSON")]:::storage
        BotProcessor["Bot Detection System"]:::processor

        subgraph Converters["Pattern Converters"]
            ApacheConv["Apache Converter"]:::converter
            NginxConv["Nginx Converter"]:::converter
            CaddyConv["Caddy Converter"]:::converter
            TraefikConv["Traefik Converter"]:::converter
            HAProxyConv["HAProxy Converter"]:::converter
        end
    end

    %% Output Layer
    subgraph OutputLayer["Output Layer"]
        subgraph Configs["Web Server Configurations"]
            ApacheConf["Apache ModSecurity"]:::config
            NginxConf["Nginx"]:::config
            CaddyConf["Caddy"]:::config
            TraefikConf["Traefik"]:::config
            HAProxyConf["HAProxy"]:::config
        end

        subgraph Patterns["Attack Patterns"]
            SQLi["SQL Injection"]:::pattern
            XSS["Cross-site Scripting"]:::pattern
            RCE["Remote Code Execution"]:::pattern
            LFI["Local File Inclusion"]:::pattern
            RFI["Remote File Inclusion"]:::pattern
        end
    end

    %% Relationships
    OWASP --> Scraper
    BotLists --> BotProcessor
    GHActions --> Scraper
    GHActions --> BotProcessor
    
    Scraper --> RulesJSON
    RulesJSON --> ApacheConv & NginxConv & CaddyConv & TraefikConv & HAProxyConv
    
    ApacheConv --> ApacheConf
    NginxConv --> NginxConf
    CaddyConv --> CaddyConf
    TraefikConv --> TraefikConf
    HAProxyConv --> HAProxyConf
    
    BotProcessor --> ApacheConf & NginxConf & CaddyConf & TraefikConf & HAProxyConf

    %% Click Events
    click RulesJSON "https://github.com/fabriziosalmi/patterns/blob/main/owasp_rules.json"
    click Scraper "https://github.com/fabriziosalmi/patterns/blob/main/owasp.py"
    click BotProcessor "https://github.com/fabriziosalmi/patterns/blob/main/badbots.py"
    click ApacheConv "https://github.com/fabriziosalmi/patterns/blob/main/owasp2apache.py"
    click NginxConv "https://github.com/fabriziosalmi/patterns/blob/main/owasp2nginx.py"
    click CaddyConv "https://github.com/fabriziosalmi/patterns/blob/main/owasp2caddy.py"
    click TraefikConv "https://github.com/fabriziosalmi/patterns/blob/main/owasp2traefik.py"
    click HAProxyConv "https://github.com/fabriziosalmi/patterns/blob/main/owasp2haproxy.py"
    click ApacheConf "https://github.com/fabriziosalmi/patterns/tree/main/waf_patterns/apache/"
    click NginxConf "https://github.com/fabriziosalmi/patterns/tree/main/waf_patterns/nginx/"
    click CaddyConf "https://github.com/fabriziosalmi/patterns/tree/main/waf_patterns/caddy/"
    click TraefikConf "https://github.com/fabriziosalmi/patterns/tree/main/waf_patterns/traefik/"
    click HAProxyConf "https://github.com/fabriziosalmi/patterns/tree/main/waf_patterns/haproxy/"
    click GHActions "https://github.com/fabriziosalmi/patterns/blob/main/.github/workflows/update_patterns.yml"
    click SQLi "https://github.com/fabriziosalmi/patterns/blob/main/waf_patterns/*/sqli.conf"
    click XSS "https://github.com/fabriziosalmi/patterns/blob/main/waf_patterns/*/xss.conf"
    click RCE "https://github.com/fabriziosalmi/patterns/blob/main/waf_patterns/*/rce.conf"
    click LFI "https://github.com/fabriziosalmi/patterns/blob/main/waf_patterns/*/lfi.conf"
    click RFI "https://github.com/fabriziosalmi/patterns/blob/main/waf_patterns/*/rfi.conf"

    %% Styles
    classDef source fill:#2374e1,stroke:#fff,stroke-width:2px,color:#fff
    classDef automation fill:#666,stroke:#fff,stroke-width:2px,color:#fff
    classDef processor fill:#2ecc71,stroke:#fff,stroke-width:2px,color:#fff
    classDef storage fill:#f1c40f,stroke:#fff,stroke-width:2px,color:#fff
    classDef converter fill:#e67e22,stroke:#fff,stroke-width:2px,color:#fff
    classDef config fill:#9b59b6,stroke:#fff,stroke-width:2px,color:#fff
    classDef pattern fill:#e74c3c,stroke:#fff,stroke-width:2px,color:#fff
```
