# 0x727/chkapi_0x727 architecture

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

- Interactive diagram: https://gitdiagram.com/0x727/chkapi_0x727
- Repository: https://github.com/0x727/chkapi_0x727

## Overview

##### Project Type and Purpose
- ChkApi is a Python-based CLI tool for automated API security scanning.
- It orchestrates a pipeline of plugins to extract URLs, discover API endpoints, run fuzzing and parameterized requests, apply bypass techniques, and aggregate results into text or Excel outputs.

##### File Structure Analysis
- Top-level:
- ChkApi.py – the CLI entry point and orchestration engine.
- build.sh – environment setup (chromedriver install).
- requirements.txt – Python dependencies.
- plugins/ – plugin modules plus rule config files.
- plugins/ directory: each .py implements one stage (URL extraction, JS/static URL find, API path finding, request runners, parameter extractors, result disposal, Excel export) plus two YAML rule sets.

##### Architectural Patterns
- Plugin Pipeline Pattern: ChkApi.py dynamically loads and invokes plugins in a fixed sequence.
- Layered Approach:
- Input Layer (CLI args)
- Orchestration Layer (ChkApi.py)
- Plugin Processing Layer (plugins/*.py)
- Persistence Layer (text/Excel outputs)
- Core design emphasizes extensibility: new plugins or rules can be added under plugins/.

##### Main Components and Interactions
a. CLI Interface (ChKApi.py)
- Parses arguments, kicks off scan.
- Loads rule configs (rule.yaml, sensitive_data_rule.yaml).
- Dynamically discovers and orders plugins.
b. Web Driver Module (plugins/webdriverFind.py)
- Uses Selenium/chromedriver to load target URL.
- Extracts automatic JS and static assets.
c. URL & JS Processor (plugins/jsAndStaticUrlFind.py)
- Fetches pages/JS files over HTTP.
- Normalizes and deduplicates URLs.
d. API Discovery
- Regex-based path finder (plugins/apiPathFind.py).
- Swagger parser (nodeCommon.py + rule.yaml).
- Fuzz tester (plugins/apiUrlReqNoParameter.py + apiUrlReqWithParameter.py).
e. Parameter Extraction (plugins/getParameter.py)
- Inspects blank-request results to infer parameters.
f. Dynamic Testing
- Requests with extracted parameters in GET, POST form-data, POST JSON.
- Bypass techniques module (plugins/disposeResults.py).
g. Result Aggregation & Export
- Sensitive data filter via sensitive_data_rule.yaml.
- Save to Excel (plugins/saveToExcel.py) and text files.
h. External Services & Dependencies
- Selenium/chromedriver
- Internet access to target site(s)
- Python libraries (requests, openpyxl, PyYAML, etc.)

[User/CLI] → [ChkApi Orchestrator] → [Plugin Pipeline] → [Data Store/Outputs]
1. webdriverFind → 2. jsAndStaticUrlFind → 3. apiPathFind & Swagger Parser → 4. apiUrlReqNoParameter & apiUrlReqWithParameter → 5. getParameter → 6. apiUrlReqWithParameter (param-driven) → 7. disposeResults (Bypass) → 8. saveToExcel
- Blue rectangles: core components (CLI, orchestrator)
- Green rectangles: plugins
- Gray clouds: external dependencies (chromedriver, target website)
- Enclose rule files (rule.yaml, sensitive_data_rule.yaml) as config artifacts feeding into discovery and filtering plugins.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    subgraph "External Dependencies"
        chromedriver("Selenium / Chromedriver"):::external
        target("Target Website"):::external
    end

    user("User/CLI"):::external
    user -->|"invoke"| orchestrator

    %% Core Component
    orchestrator("CLI Interface\n(ChkApi.py)"):::core

    %% Config Artifacts
    subgraph "Config Artifacts"
        ruleYaml("rule.yaml"):::plugin
        sensitiveYaml("sensitive_data_rule.yaml"):::plugin
    end

    %% Plugin Pipeline
    subgraph "Plugin Pipeline"
        direction TB
        webdriver("WebDriver Module"):::plugin
        jsand("URL & JS Processor"):::plugin
        apiPath("API Path Finder"):::plugin
        swagger("Swagger Parser"):::plugin
        fuzzNo("Fuzz Tester\n(No-Parameter)"):::plugin
        getParam("Parameter Extraction"):::plugin
        paramReq("Fuzz Tester\n(With-Parameter)"):::plugin
        bypass("Bypass / Result Disposal"):::plugin
        saveExcel("Result Export\n(Save to Excel)"):::plugin
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        outputStore("Text / Excel Outputs"):::output
    end

    %% Data Flow
    orchestrator -->|"load plugins"| webdriver
    webdriver -->|"use chromedriver"| chromedriver
    webdriver -->|"load pages"| target
    webdriver -->|"extract URLs"| jsand
    jsand -->|"normalized URLs"| apiPath
    apiPath -->|"raw paths"| swagger
    ruleYaml -.->|"regex rules"| apiPath
    ruleYaml -.->|"swagger rules"| swagger
    swagger -->|"endpoints"| fuzzNo
    fuzzNo -->|"blank responses"| getParam
    getParam -->|"params inferred"| paramReq
    paramReq -->|"responses"| bypass
    sensitiveYaml -.->|"filter rules"| bypass
    bypass -->|"filtered data"| saveExcel
    saveExcel -->|"export reports"| outputStore

    %% Click Events
    click orchestrator "https://github.com/0x727/chkapi_0x727/blob/master/ChkApi.py"
    click webdriver "https://github.com/0x727/chkapi_0x727/blob/master/plugins/webdriverFind.py"
    click jsand "https://github.com/0x727/chkapi_0x727/blob/master/plugins/jsAndStaticUrlFind.py"
    click apiPath "https://github.com/0x727/chkapi_0x727/blob/master/plugins/apiPathFind.py"
    click swagger "https://github.com/0x727/chkapi_0x727/blob/master/plugins/nodeCommon.py"
    click ruleYaml "https://github.com/0x727/chkapi_0x727/blob/master/plugins/rule.yaml"
    click fuzzNo "https://github.com/0x727/chkapi_0x727/blob/master/plugins/apiUrlReqNoParameter.py"
    click paramReq "https://github.com/0x727/chkapi_0x727/blob/master/plugins/apiUrlReqWithParameter.py"
    click getParam "https://github.com/0x727/chkapi_0x727/blob/master/plugins/getParameter.py"
    click bypass "https://github.com/0x727/chkapi_0x727/blob/master/plugins/disposeResults.py"
    click sensitiveYaml "https://github.com/0x727/chkapi_0x727/blob/master/plugins/sensitive_data_rule.yaml"
    click saveExcel "https://github.com/0x727/chkapi_0x727/blob/master/plugins/saveToExcel.py"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000;
    classDef plugin fill:#90EE90,stroke:#000;
    classDef output fill:#FFA500,stroke:#000;
    classDef external fill:#D3D3D3,stroke:#000;
```
