How flipkart-incubator/astra works
Main components
• Web API Server: Represented by the API folder. This component (using Flask) exposes endpoints and hooks into the backend scanning logic. Files like api.py, dbconnection.py, and scanstatus.py are part of this layer.
• Dashboard (Frontend): The Dashboard folder contains static assets (CSS, JavaScript) and HTML templates for the user interface where users can initiate scans and view reports.
• Vulnerability Scanning Modules: Several directories and modules (modules, core, utils, and parts of SSRFmap) implement the actual scanning logic. Each module (for SQL injection, SSRF, XSS, etc.) is encapsulated in its own Python file, making it easier to identify and modularize.
• CLI (Command Line Interface): The astra.py file (and associated command line argument handling) along with celery_app.py reflect the CLI usage for security testing.
• Task Queue and Asynchronous Job Processor: Based on the README, Celery and RabbitMQ are used. A separate "celery_app.py" indicates asynchronous scanning tasks that run off the main process.
• Supporting Utilities: The utils folder (with its configuration, logger, and email sending components) supports various auxiliary functionalities useful across multiple parts of the system.
• Deployment: Dockerfiles in the root and within SSRFmap, along with configuration files (e.g., .dockerignore, .gitignore), indicate containerization support.
Relationships and interactions
• The API server acts as an orchestrator that invokes various vulnerability scanning modules (from core and modules directories) based on the user’s input.
• The CLI provides another entry point to trigger scans: it directly calls into the scanning modules (through astra.py), similar to the API.
• The API and modules interact with the database (MongoDB) to store scan results and logs.
• The SSRFmap module acts in a similar fashion as a specialized component, with its own set of scanning and payload modules. It can either operate independently or integrate its findings back into the main system.
Architectural patterns and design principles
• Modularity: Components are clearly separated (API, Dashboard, modules, utils, SSRFmap) making it easier to isolate functionalities.
• Separation of Concerns: The structure distinguishes between user interface (Dashboard), business logic and scanning (core, modules), and system orchestration (celery_app, API).
• Asynchronous Processing: Incorporation of Celery and RabbitMQ reflects a design that handles potentially long-running scan operations asynchronously.
• Extensibility: The modular design (with individual scanning modules and separate payload definitions) supports future extensions and easier maintenance.