crowdsecurity / cs-wordpress-bouncer

CrowdSec is an open-source cyber security tool. This plugin blocks detected attackers or display them a captcha to check they are not bots.
https://wordpress.org/plugins/crowdsec/
MIT License
34 stars 6 forks source link

Fatal error: Uncaught TypeError: ltrim() expects parameter 1 to be string, bool given #127

Closed michelep closed 1 year ago

michelep commented 1 year ago

Fatal error: Uncaught TypeError: ltrim() expects parameter 1 to be string, bool given in /website/www/wp-content/plugins/crowdsec/inc/Bouncer.php:67 Stack Trace

  1. ltrim()/website/www/wp-content/plugins/crowdsec/inc/Bouncer.php:67
  2. Bouncer->handleRawConfigs()/website/www/wp-content/plugins/crowdsec/inc/Bouncer.php:35
  3. Bouncer->__construct()/website/www/wp-content/plugins/crowdsec/inc/admin/init.php:126
  4. testBouncerConnexionInAdminPage()/website/www/wp-content/plugins/crowdsec/inc/admin/init.php:219
  5. {closure}()/website/www/wp-includes/class-wp-hook.php:308
  6. do_action()/website/www/wp-admin/admin-post.php:85
  7. {main} thrown in /website/www/wp-content/plugins/crowdsec/inc/Bouncer.php on line 67
julienloizelet commented 1 year ago

Hi @michelep , Thanks for reporting this issue.

Which PHP version is running on your server ?

Looking at the code, it is strange that the retrieved value of crowdsec_tls_cert_path database entry is a boolean:

ltrim($rawConfigs['crowdsec_tls_cert_path'] ?? '', '/')

Could you look in the wp-options table and share the value of your crowdsec_tls_cert_path entry ?

[EDIT]: Ok, I can reproduce the bug : I guess you don't have any entry in your database for the crowdsec_tls_cert_path. Then the WordPress get_option(crowdsec_tls_cert_path) method returns false => BUG

Anyway, I guess I could force a string cast to avoid such error.

Will work on a fix asap.

Thanks again.

michelep commented 1 year ago

Could you look in the wp-options table and share the value of your crowdsec_tls_cert_path entry ?

Column "option_value" is empty and "autoload" is "yes".

Hope this help!

julienloizelet commented 1 year ago

Hi @michelep,

I released a new 2.0.2 version of the plugin with a fix for your issue.

Please let me know if it is ok with this new release.

Thanks