How infobyte/faraday works
Project Type and Purpose
• The project is a full-stack application with a backend API, command line interface (CLI), web interface (served from static assets), and integrations with external tools (agents and plugins).
File Structure for Key Components
• There is a clear separation between several top-level sections:
• The “faraday” directory contains most of the core application logic.
• Migration scripts in “faraday/migrations” use Alembic for database versioning.
• There are additional support directories for configuration (“faraday/settings”), utilities (“faraday/utils”), and websockets.
• Other parts include Docker-related files and deployment configurations (docker-compose.yaml, Dockerfile, docker folder and GitLab CI/CD scripts).
• The “pynixify” folder indicates support for package builds using Nix, which is important for reproducible builds and packaging of dependencies.
Main Components of the System
• Frontend / Web UI Component: Represented by the static assets in faraday/server/www. This is the user interface (e.g., dashboard, reports).
• Backend Application Server: Built with Flask (as indicated by the use of flask-related packages in the “pynixify/packages” and the server module structure). This includes:
• API modules (REST API endpoints implemented in faraday/server/api)
• Business logic and controllers (in faraday/server/app.py and various utility modules).
• Templating and command modules.
• Asynchronous Task Handling: Celery workers (celaday_worker.py, celery_worker_gevent.py) that process background tasks – for example, importing data or performing heavy operations.
• Database Layer: Although not explicitly implemented here, the project uses migrations (via Alembic) and assumes a Postgres database (as mentioned in README installation instructions).
• External Integrations and Plugins:
• Faraday Agents: These act as remote executors/scanners that feed data into the system.
• Plugins: There is clear support for both “console” and “report” plugins which extend the functionality. This connection shows how Faraday integrates data from over 80+ tools.
• Faraday CLI: The CLI (faraday-cli) component provides command line access to the core functionality and might interface directly with both the API and the database.
• Configuration & Deployment:
• Docker and docker-compose configurations indicate containerized deployments.
• CI/CD pipelines defined in .gitlab-ci, GitHub workflows, etc.
• Nix packaging (pynixify) reinforces reproducible builds.
Relationships and Data Flow to Illustrate
• How the Web UI (frontend static assets served maybe via a Flask-Gunicorn server) communicates with the backend API.
• Requests flow from end-user browsers to the backend.
• The backend interacts with the Postgres database for persistent storage and works with asynchronous task queues (Celery) for background processing.
• External plugins and agents push vulnerability data into the system via API endpoints or specialized integrations.
• The CLI tool interacts with the API and/or directly invokes server commands.
• Dependencies such as common libraries (Flask, Celery, SQLAlchemy for ORM, etc.) and configuration strategies (using settings defined in faraday/settings and default.ini).
Architectural Patterns and Design Principles
• The application follows Model-View-Controller (MVC)-like principles where:
• Models are defined (faraday/server/models.py and related migrations),
• Views/templates are in faraday/server/templates and faraday/server/www,
• Controllers and API endpoints are in faraday/server/api.
• The separation of concerns is clear with distinct directories for configuration, utility functions, command line tools, and deployment pipelines.
• Emphasis on modularity is seen by having plugins for extending functionalities.