How yacwagh/arrows works
Project Type and Purpose
• This project is a full-stack web application focused on automated threat modeling using artificial intelligence. It leverages the STRIDE methodology to analyze both application descriptions and codebases.
• The tool offers interactive visualization (using Vis.js) and integrates with external LLM services (OpenAI or OpenRouter).
File Structure
• Key directories include:
• Root-level Python files (app.py, main.py) that indicate the Flask web server initialization and entry points.
• The "llm" directory containing configuration and prompt definitions for LLM integration.
• The "system_architecture" directory housing scripts for system and whitebox analysis.
• The "threat_model" directory, which defines various threat analyzers based on STRIDE (e.g., Dos, Elevation, Info Disclosure, etc.).
• The "static" and "templates" folders for frontend assets (HTML, CSS, and JavaScript) supporting the interactive visualization.
• An "examples" folder which provides sample inputs for both application descriptions and a React-based codebase.
a. Main Components:
• Frontend/UI: Represented by the web server (Flask in app.py) that serves HTML templates and static assets.
• Core Analysis Engine:
• System Analyzer and Whitebox Analyzer (located in system_architecture)
• Threat Analyzers (in threat_model) that process and model the security threats.
• LLM Integration: Represented by the "llm" directory where LLM configuration and prompt handling are defined. It interfaces with external APIs (OpenAI and OpenRouter).
• Input Sources: Two distinct inputs for description-based and codebase analysis (as depicted in the examples folder).
• Threat Model Composer: The component that organizes results into detailed threat models (identifying components, data flows, assets, trust boundaries, threats).
• Analysis Features: STRIDE-based analysis with additional risk assessment and mitigation strategies.
b. Relationships and Interactions:
• Input Sources feed data into two separate analysis pipelines (Description Input goes to the System Analyzer and Code Input goes to the Whitebox Analyzer).
• Both analyzers pass their results to the Threat Analyzer, which then involves the LLM service for deeper analysis.
• The LLM service communicates with external LLM providers to get enhanced insights before the final threat model output is generated.
• The final output is structured into a visual representation (graph) showing components, data flows, and trust boundaries.
c. Architectural Patterns and Design Principles:
• Layered Architecture: A clear separation between the user interface (frontend), the business logic (analysis engines), integration with data sources (LLM services), and presentation (interactive threat model visualization).
• Modularity: Each analysis component (system analyzer, whitebox analysis, threat analyzers) is isolated in different directories, which makes future extensions or adjustments more manageable.
d. Relevant Technologies/Frameworks:
• Backend: Python (Flask), analysis modules (for STRIDE threat detection), integration with LLM services.
• Frontend: HTML5, CSS3, JavaScript (utilizing Vis.js and Bootstrap 5).
• External services: OpenAI/OpenRouter APIs for LLM services.
Elements
• Use clear and descriptive labels for each component (e.g., “System Analyzer”, “Whitebox Analyzer”, “Threat Analyzer”, “LLM Service”, “OpenAI API”, “Threat Model Component”).
• Input Sources → System/Whitebox Analysis → Threat Analyzer → LLM Integration → Threat Model.
• Frontend/UI components (e.g., rectangles)
• Backend analysis components (e.g., rounded rectangles or clouds)
Putting It All Together
• That the integration with the LLM module (from the "llm" folder) and its connection to external API endpoints is clearly visualized.
• Additional details such as interactive visualization components (static/js/graph.js) that render the threat model output dynamically in the web interface.