# uditrajput03/docker-security-poc architecture

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

- Interactive diagram: https://gitdiagram.com/uditrajput03/docker-security-poc
- Repository: https://github.com/uditrajput03/docker-security-poc

## Overview

##### Project Type and Purpose
- The project is a security tool specifically designed to scan Docker Hub images for potential sensitive credential leaks. It operates as a proof-of-concept using a microservices pipeline and Redis queues to manage workflow tasks.
- Its core function is to scan, inspect, and alert when sensitive information (like environmental variables or configuration files) is detected inside pulled Docker images.

##### Analyzing the File Structure
- The top-level files (.env.exampl, package.json, tsconfig.json) and the source code files in the “src” folder indicate a Node.js/TypeScript application.
- The source directory hosts multiple scripts like getImages.ts, getIndexData.ts, getTags.ts, getRedis.ts, logger.ts, index.ts, queueHandler.ts, and worker.ts which reflect distinct responsibilities within the system.
- The presence of scripts (e.g., node.sh) suggests command line utilities or process orchestration.
- This structure is aligned with a microservices-based architecture where each script potentially forms a step in the scanning pipeline.

##### Extracting Insights from the README
- The README clearly outlines the scanning pipeline’s steps: Keyword Scanner, Username Scanner, Image Scanner, Tag Scanner, and Alert System.
- It highlights that Redis is used as the central queue system where jobs are passed from one stage to the next.
- The README details environmental configuration (for Redis and Telegram) and outlines how each component (implemented in various source files) contributes to the end-to-end scanning process.

a. Main Components to Include:
- Keyword Scanner: Initiates searching by populating a Redis queue with keywords.
- Username Scanner: Consumes keywords to retrieve usernames from Docker Hub.
- Image Scanner: Uses the retrieved usernames to discover associated Docker images.
- Tag Scanner: Extracts image tags and pulls their corresponding Docker tar files.
- Alert System: Checks for sensitive files and sends notifications (via Telegram, etc.).
- Redis Queues: The central mediator facilitating communication and task flow between scanners.

b. Relationships and Interactions:
- Redis Queues at the center, connecting each scanner component to indicate their reliance on Redis for synchronous/asynchronous messaging.

c. Architectural Patterns and Design Principles:
- Microservices: Indicate that each scanning component is a loosely coupled service.
- Pipeline/Queue-based processing: Emphasize the role of Redis in decoupling the stages.
- Stateless Service Design: Each microservice operates independently without shared state aside from what is passed via Redis.
- Separation of Concerns: Highlight that each script (as per the “src” directory) has a dedicated responsibility (e.g., getImages.ts solely handles image retrieval).

d. Technology Stack Details:
- Node.js with TypeScript as the primary runtime/language.
- Redis as the message queue.
- Docker Hub as the external service being scanned.
- Telegram (via the provided webhook and credentials in the .env configuration) for alert notifications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Scanning Pipeline"
        KS["Keyword Scanner"]:::scanner
        US["Username Scanner"]:::scanner
        IS["Image Scanner"]:::scanner
        TS["Tag Scanner"]:::scanner
        AS["Alert System"]:::alert
    end

    RQ("Redis Queue"):::redis

    %% Pipeline flow through Redis queues
    KS -->|"enqueue"| RQ
    RQ -->|"dequeue"| US
    US -->|"enqueue"| RQ
    RQ -->|"dequeue"| IS
    IS -->|"enqueue"| RQ
    RQ -->|"dequeue"| TS
    TS -->|"enqueue"| RQ
    RQ -->|"dequeue"| AS

    %% Direct Pipeline Flow (optional logical view)
    KS -->|"next"| US
    US -->|"next"| IS
    IS -->|"next"| TS
    TS -->|"next"| AS

    %% Click Events
    click KS "https://github.com/uditrajput03/docker-security-poc/blob/main/src/getIndexData.ts"
    click US "https://github.com/uditrajput03/docker-security-poc/blob/main/src/queueHandler.ts"
    click IS "https://github.com/uditrajput03/docker-security-poc/blob/main/src/getImages.ts"
    click TS "https://github.com/uditrajput03/docker-security-poc/blob/main/src/getTags.ts"
    click AS "https://github.com/uditrajput03/docker-security-poc/blob/main/src/worker.ts"
    click RQ "https://github.com/uditrajput03/docker-security-poc/blob/main/src/getRedis.ts"

    %% Styles
    classDef scanner fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef redis fill:#F9E79F,stroke:#B9770E,stroke-width:2px,stroke-dasharray: 5 5;
    classDef alert fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
