How yandex/gixy works
Main Components
• Command-Line Interface (CLI) – Found under gixy/cli, this component handles user input and argument parsing.
• Core Engine – The gixy/core package contains the central logic for configuration management, exception handling, context processing, and issue reporting.
• Parser – Under gixy/parser, this module is responsible for processing raw Nginx config files and transforming them into a format that the core can use.
• Plugin System – The gixy/plugins package houses individual plugins (e.g., ssrf.py, alias_traversal.py) that implement specific vulnerability checks.
• Directives Handling – Found under gixy/directives, it processes and interprets Nginx directives.
• Formatters – The gixy/formatters module is responsible for output representation, including JSON and console formatting; it is also responsible for rendering template-based reports.
• Utilities and Support – Additional helper functions located in gixy/utils and other submodules.
• Testing and Validation – Though not part of the production design, the tests directory shows how each component (parser, plugins, directives) is validated, reinforcing the design’s modularity.
Relationships and Interactions
• The CLI component (gixy/cli/main.py) acts as the entry point, capturing user commands and passing configuration file paths to the core.
• The Core Engine reads the Nginx configuration using modules in the parser, then manages the analysis workflow.
• The Parser processes the config into a structured representation that the Core Engine and plugins can work with.
• The Plugin Manager (in gixy/core/plugins_manager.py) dynamically loads and iterates over available plugins.
• Each Plugin applies its specific rule checks against the structured configuration data and reports any issues.
• The Formatters take the analysis output and render it into human-readable formats (console output, JSON, etc.) before it is displayed to the user.
• Directives processing ensures that Nginx-specific configuration commands are correctly interpreted for security validations.
• Dependencies and external libraries (notably Python 2.7/3.x compatibility, possibly Jinja2 for templates in formatters) form part of the stack.
Architectural Patterns and Design Principles
• Plugin Architecture: Gixy is built in a modular way where independent plugins each check for a specific vulnerability. The Plugin Manager orchestrates these.
• Separation of Concerns: The CLI, core engine, parser, plugins, and formatters are clearly separated into different packages, allowing easier maintenance and extension.
• Testability: The existence of a comprehensive tests directory indicates unit testing is an integral part of the project, ensuring each layer can be validated independently.
Including Relevant Technologies and Frameworks
• Python is the primary language.
• The tool uses standard modules as well as third-party libraries (e.g., Jinja2 for templating in the formatters).
• Docker support is provided (see Dockerfile and instructions in the README) to run Gixy as a container for environments where installation might be more controlled.