78% crowdsec

Code Review | CrowdSec

WordPress plugin CrowdSec scored78%from 54 tests.

About plugin

  • Plugin page: crowdsec
  • Plugin version: 2.5.2
  • PHP compatiblity: 7.2+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.9-6.4
  • WordPress version: 6.3.1
  • First release: Jan 14, 2021
  • Latest release: Nov 23, 2023
  • Number of updates: 59
  • Update frequency: every 17.7 days
  • Top authors: crowdsec (100%)

Code review

54 tests

User reviews

4 reviews

Install metrics

1,000+ active /24,735 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▲1.08MB] [CPU: ▼3.01ms] Passed 4 tests

Analyzing server-side resources used by CrowdSec
This plugin does not affect your website's performance
PageMemory (MB)CPU Time (ms)
Home /4.36 ▲0.8941.28 ▲0.29
Dashboard /wp-admin4.46 ▲1.1149.60 ▼13.65
Posts /wp-admin/edit.php4.58 ▲1.2255.03 ▲6.08
Add New Post /wp-admin/post-new.php7.07 ▲1.1885.51 ▼4.75
Media Library /wp-admin/upload.php4.39 ▲1.1541.54 ▲8.37
Theme customization /wp-admin/admin.php?page=crowdsec_theme_settings4.3537.24
Advanced /wp-admin/admin.php?page=crowdsec_advanced_settings4.3636.67
CrowdSec /wp-admin/admin.php?page=crowdsec_plugin4.3735.78

Server storage [IO: ▲5.83MB] [DB: ▲0.00MB] Passed 3 tests

Analyzing filesystem and database footprints of this plugin
No storage issues were detected
Filesystem: 969 new files
Database: no new tables, 60 new options
New WordPress options
crowdsec_geolocation_cache_duration
crowdsec_theme_text_ban_wall_subtitle
crowdsec_theme_text_captcha_wall_footer
crowdsec_theme_color_background_button
crowdsec_theme_color_background_page
crowdsec_geolocation_maxmind_database_path
crowdsec_theme_text_captcha_wall_error_message
crowdsec_hide_mentions
crowdsec_theme_color_text_primary
crowdsec_fallback_remediation
...

Browser metrics Passed 4 tests

An overview of browser requirements for CrowdSec
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,825 ▲6314.67 ▲0.321.75 ▲0.1043.58 ▼0.88
Dashboard /wp-admin2,233 ▲535.63 ▲0.0490.86 ▼7.6543.00 ▼0.08
Posts /wp-admin/edit.php2,132 ▲322.11 ▲0.1537.51 ▼4.1832.52 ▼7.97
Add New Post /wp-admin/post-new.php1,555 ▲2923.42 ▲0.70655.79 ▲5.4053.96 ▼1.76
Media Library /wp-admin/upload.php1,435 ▲354.20 ▲0.0195.54 ▼0.7142.66 ▲1.88
Theme customization /wp-admin/admin.php?page=crowdsec_theme_settings1,1332.0026.3139.50
Advanced /wp-admin/admin.php?page=crowdsec_advanced_settings1,3901.7030.5156.79
CrowdSec /wp-admin/admin.php?page=crowdsec_plugin1,1292.2025.4435.07

Uninstaller [IO: ▲0.00MB] [DB: ▲0.00MB] 75% from 4 tests

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
These items require your attention
  • This plugin does not fully uninstall, leaving 6 options in the database
    • widget_recent-posts
    • db_upgraded
    • can_compress_scripts
    • widget_theysaidso_widget
    • theysaidso_admin_options
    • widget_recent-comments

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
Everything seems fine, however this is by no means an exhaustive test

SRP 0% from 2 tests

🔹 Tests weight: 20 | A shallow check of the single-responsibility principle; PHP files should perform no action - including output of placeholder text - and trigger no errors when accessed directly
Almost there! Just fix the following items
  • 1× PHP files output non-empty strings when accessed directly via GET requests:
    • > /wp-content/plugins/crowdsec/vendor/gregwar/captcha/demo/index.php
  • 557× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'MaxMind\\Exception\\HttpException' not found in wp-content/plugins/crowdsec/vendor/maxmind/web-service-common/src/Exception/InvalidRequestException.php:10
    • > PHP Fatal error
      Uncaught Error: Class 'Symfony\\Component\\Filesystem\\Exception\\IOException' not found in wp-content/plugins/crowdsec/vendor/symfony/filesystem/Exception/FileNotFoundException.php:20
    • > PHP Fatal error
      Uncaught Error: Class 'Monolog\\Handler\\AbstractProcessingHandler' not found in wp-content/plugins/crowdsec/vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php:34
    • > PHP Fatal error
      require_once(): Failed opening required 'wp-content/plugins/crowdsec/vendor/gregwar/captcha/demo/../vendor/autoload.php' (include_path='.:/usr/share/php') in wp-content/plugins/crowdsec/vendor/gregwar/captcha/demo/ocr.php on line 3
    • > PHP Fatal error
      Uncaught Error: Class 'Twig\ode\ode' not found in wp-content/plugins/crowdsec/vendor/twig/twig/src/Node/SandboxNode.php:21
    • > PHP Fatal error
      Uncaught Error: Class 'Twig\ode\ode' not found in wp-content/plugins/crowdsec/vendor/twig/twig/src/Node/WithNode.php:21
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Cache\\InvalidArgumentException' not found in wp-content/plugins/crowdsec/vendor/symfony/cache/Exception/InvalidArgumentException.php:22
    • > PHP Fatal error
      Uncaught Error: Class 'Twig\ode\\Expression\\Binary\\AbstractBinary' not found in wp-content/plugins/crowdsec/vendor/twig/twig/src/Node/Expression/Binary/ModBinary.php:17
    • > PHP Fatal error
      Uncaught Error: Class 'Monolog\\Formatter\\JsonFormatter' not found in wp-content/plugins/crowdsec/vendor/monolog/monolog/src/Monolog/Formatter/LogmaticFormatter.php:19
    • > PHP Fatal error
      Uncaught Error: Class 'Monolog\\Formatter\ormalizerFormatter' not found in wp-content/plugins/crowdsec/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php:24

User-side errors Passed 1 test

🔹 Test weight: 20 | This is just a short smoke test looking for browser issues
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration 93% from 29 tests

readme.txt 94% from 16 tests

Don't ignore readme.txt as it is the file that instructs WordPress.org on how to present your plugin to the world
These attributes need your attention:
  • Tags: Please delete some tags, you are using 20 tag instead of maximum 10
You can take inspiration from this readme.txt

crowdsec/crowdsec.php 92% from 13 tests

The entry point to "CrowdSec" version 2.5.2 is a PHP file that has certain tags in its header comment area
It is important to fix the following:
  • Text Domain: The text domain must be the same as the plugin slug, although optional since WordPress version 4.6

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are considered dangerous and should not be included with any WordPress plugin
There were no executable files found in this plugin71,573 lines of code in 884 files:
LanguageFilesBlank linesComment linesLines of code
PHP78512,14025,39161,255
Markdown592,60105,554
JSON1002,315
YAML15181421,092
C111825668
XML101311339
Twig6190187
CSS216196
m418032
Bourne Again Shell14216
reStructuredText18510
C/C++ Header14128
JavaScript1011

PHP code Passed 2 tests

This is a very shot review of cyclomatic complexity and code structure
There are no cyclomatic complexity problems detected for this plugin
Cyclomatic complexity
Average complexity per logical line of code0.41
Average class complexity10.30
▷ Minimum class complexity1.00
▷ Maximum class complexity181.00
Average method complexity2.86
▷ Minimum method complexity1.00
▷ Maximum method complexity54.00
Code structure
Namespaces128
Interfaces69
Traits14
Classes636
▷ Abstract classes487.55%
▷ Concrete classes58892.45%
▷ Final classes10317.52%
Methods3,470
▷ Static methods3339.60%
▷ Public methods2,59674.81%
▷ Protected methods43412.51%
▷ Private methods44012.68%
Functions491
▷ Named functions22245.21%
▷ Anonymous functions26954.79%
Constants455
▷ Global constants408.79%
▷ Class constants41591.21%
▷ Public constants33380.24%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Using a strong compression for your PNG files is a great way to speed-up your plugin
8 PNG files occupy 0.26MB with 0.15MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
vendor/crowdsec/common/docs/images/logo_crowdsec.png7.55KB3.44KB▼ 54.43%
.wordpress-org/icon-128x128.png12.32KB4.69KB▼ 61.95%
vendor/crowdsec/capi-client/docs/images/logo_crowdsec.png7.55KB3.44KB▼ 54.43%
vendor/crowdsec/remediation-engine/docs/images/logo_crowdsec.png7.55KB3.44KB▼ 54.43%
.wordpress-org/banner-772x250.png52.51KB19.30KB▼ 63.24%