How cleantalk/security-malware-firewall works
Major components
• Plugin Core & Business Logic: Represent the PHP modules located in the “inc” and “lib” directories. These include:
– Security logic components (spbc-firewall.php, spbc-admin.php, spbc-settings.php, spbc-scanner.php, and other spbc-*.php files).
– Core libraries under “lib/CleantalkSP” and “lib/CleantalkSP/SpbctWP” that implement scanning (heuristic and signatures analysers), database interactions, state handling, remote calls, and security functions.
• External Services & Communication: Include CleanTalk’s cloud security service (for logging, access key generation, and daily security reports) that communicates with the plugin when API calls or notifications are needed.
• Build & Deployment Pipeline: Outline configuration components (gulpfile.js, webpack.config.js, .github workflows) that facilitate CI/CD, testing, and releasing. Also, note dependencies managed via composer.json and package.json.
• Testing Framework: Represent the extensive test suites (located in “tests” and “spec”) which support continuous integration, unit testing for security functions, scanning modules, and IP-based logic.
Interactions and relationships
• The WordPress environment (hosting the plugin via index.php, install script, and templates) acts as the container. Data flows from the website’s incoming HTTP requests into the plugin’s security modules.
• The backend modules (inc and lib directories) receive events from WordPress hooks. They process tasks (e.g., checking login attempts, scanning files, interacting with the firewall module, and queueing requests) and then communicate results back to the WordPress dashboard.
• The UI components (built in JavaScript/React) provide an interactive admin interface that retrieves data from the underlying PHP modules (using AJAX or REST calls).
• External API channels link the plugin to CleanTalk’s cloud service where logs and security events are stored for a period (45 days). This channel is used to verify API keys and deliver notifications.
• The asset/build process (via gulp, webpack, etc.) transforms and packages CSS/JS resources that get served by WordPress.
Architectural patterns and design principles
• Modularity: The separation of functionalities into distinct directories (for scanning, firewall, admin, etc.) implies a modular design, facilitating maintenance and scalability.
• MVC-like Separation: Although not a pure MVC framework, the plugin separates presentation logic (JS and CSS), business logic (PHP in inc/ and lib/), and data/persistence (DB abstraction in lib/SpbctWP/DB).
• Integration with third-party services: The design leverages external cloud-based monitoring and reporting, underscoring the SaaS approach.
• Asynchronous and scheduled processes: There are elements such as cron jobs (in lib/CleantalkSP/Common/Cron.php and tests for spbc-cron) which reflect background task scheduling.