# protectai/vulnhuntr architecture

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

- Interactive diagram: https://gitdiagram.com/protectai/vulnhuntr
- Repository: https://github.com/protectai/vulnhuntr

## Overview

##### Main Components

a) Core Components:
- Input Handler (handles repository/file paths and CLI arguments)
- Symbol Finder (static code analysis component)
- LLM Integration Layer (manages different LLM providers)
- Vulnerability Analysis Engine
- Output Generator

b) External Services:
- LLM Providers (Claude, GPT, Ollama)
- Target Repository/Files

**┌─ Input Layer ─────────────────────────────┐**

- CLI Interface         Repository/Files    │

- Processing Layer ──────────────────────┐ │

- ┌─ Symbol Finder ─┐   ┌─ LLM Layer ─┐ │ │

- Static Analysis │◄──►│ API Client │ │ │
- Engine       │   │  Manager    │ │ │
- ┬─┘   └─────┬───────┘ │ │

- ┌────────▼───────────▼──────┐  │ │
- Vulnerability Analyzer    │  │ │
- ┬──┘  │ │

- ┼─────┘ │

- ┌─ Output Layer ───────────────▼─────┐  │

- Reports    Logs    PoC Generator  │  │

- ┘  │
- ┘

##### Key Relationships to Highlight

a) Data Flow:
- Repository/File → Symbol Finder
- Symbol Finder ↔ LLM Layer
- LLM Layer → External LLM Services
- Vulnerability Analyzer → Output Generator

b) Control Flow:
- CLI Interface → Input Handler
- Input Handler → Symbol Finder
- Symbol Finder → Vulnerability Analyzer
- Vulnerability Analyzer → Report Generator

##### Important Details

a) Supported Vulnerability Types:
- LFI
- AFO
- RCE
- XSS
- SQLI
- SSRF
- IDOR

b) LLM Provider Options:
- Claude (Anthropic)
- GPT (OpenAI)
- Ollama (Experimental)

##### Special Notes

- Iterative nature of the analysis process
- How the tool chains together multiple analyses
- Where the README summary is incorporated
- Progression from initial to secondary analysis

Remember to maintain a balance between detail and clarity, focusing on the tool's unique approach to vulnerability discovery through the combination of static analysis and LLM-powered reasoning.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef core fill:#2374ab,color:white
    classDef input fill:#57a773,color:white
    classDef output fill:#57a773,color:white
    classDef external fill:#ff8c42,color:white
    classDef security fill:#845ec2,color:white
    classDef config fill:#b0a8b9,color:white

    %% Input Layer
    subgraph Input
        CLI["CLI Interface"]:::input
        Repo["Repository/Files"]:::input
        Config["Configuration"]:::config
    end

    %% Processing Layer
    subgraph Processing
        SymbolFinder["Symbol Finder\n(Static Analysis)"]:::core
        LLMLayer["LLM Integration Layer"]:::core
        VulnAnalyzer["Vulnerability Analyzer"]:::security
        PromptTemplates["LLM Prompt Templates"]:::core
    end

    %% External Services
    subgraph LLMProviders
        Claude["Claude (Anthropic)"]:::external
        GPT["GPT (OpenAI)"]:::external
        Ollama["Ollama (Experimental)"]:::external
    end

    %% Output Layer
    subgraph Output
        Reports["Reports"]:::output
        PoC["PoC Generator"]:::output
        Logs["Logs"]:::output
    end

    %% Relationships
    CLI --> Config
    Config --> SymbolFinder
    Repo --> SymbolFinder
    SymbolFinder <--> LLMLayer
    LLMLayer --> VulnAnalyzer
    PromptTemplates --> LLMLayer
    LLMLayer --> LLMProviders
    VulnAnalyzer --> Reports
    VulnAnalyzer --> PoC
    VulnAnalyzer --> Logs

    %% Click events
    click SymbolFinder "https://github.com/protectai/vulnhuntr/blob/main/vulnhuntr/symbol_finder.py"
    click LLMLayer "https://github.com/protectai/vulnhuntr/blob/main/vulnhuntr/LLMs.py"
    click CLI "https://github.com/protectai/vulnhuntr/blob/main/vulnhuntr/__main__.py"
    click PromptTemplates "https://github.com/protectai/vulnhuntr/blob/main/vulnhuntr/prompts.py"
    click Config "https://github.com/protectai/vulnhuntr/blob/main/pyproject.toml"
    
    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Input/Output"]:::input
        L3["External Services"]:::external
        L4["Security Components"]:::security
        L5["Configuration"]:::config
    end
```
