Skip to content

Commit ecbac5c

Browse files
feat(*): Add disable_prod_log config and remove disable_bouncing config, prepare release 1.8.0
1 parent 1f21eac commit ecbac5c

33 files changed

+160
-182
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
8+
## [1.8.0] - 2022-08-04
9+
10+
### Added
11+
- Add `use_curl` configuration: should be used if `allow_url_fopen` is disabled and `curl` is available
12+
- Add `disable_prod_log` configuration
13+
14+
### Changed
15+
- Change log path to `wp-content/plugins/crowdsec/logs`
16+
- By default, the `bouncing_level` setting is `bouncing_disabled` (instead of `normal_bouncing`)
17+
18+
719
## [1.7.0] - 2022-07-21
820

921
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
},
2121
"require": {
22-
"crowdsec/bouncer": "0.27.0",
22+
"crowdsec/bouncer": "0.28.0",
2323
"symfony/polyfill-mbstring": "1.20.0",
2424
"symfony/service-contracts": "2.4.1"
2525
},

composer.lock

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crowdsec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin URI: https://github.com/crowdsecurity/cs-wordpress-bouncer
55
* Description: Safer Together. Protect your WordPress application with CrowdSec.
66
* Tags: crowdsec-bouncer, wordpress, security, firewall, captcha, ip-scanner, ip-blocker, ip-blocking, ip-address, ip-database, ip-range-check, crowdsec, ban-hosts, ban-management, anti-hacking, hacker-protection, captcha-image, captcha-generator, captcha-generation, captcha-service
7-
* Version: 1.7.0
7+
* Version: 1.8.0
88
* Author: CrowdSec
99
* Author URI: https://www.crowdsec.net/
1010
* Github: https://github.com/crowdsecurity/cs-wordpress-blocker
@@ -13,7 +13,7 @@
1313
* Requires PHP: 7.2
1414
* Requires at least: 4.9
1515
* Tested up to: 6.0
16-
* Stable tag: 1.7.0
16+
* Stable tag: 1.8.0
1717
* Text Domain: crowdsec-wp
1818
* First release: 2021.
1919
*/

docs/USER_GUIDE.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ also be able to test your settings.
7272

7373
***
7474

75-
`Bouncing feature → Disable bouncing feature`
76-
77-
Until you have configured all the required parameters, you should disable the bouncing feature.
78-
79-
***
80-
8175

8276
`Connection details → LAPI URL`
8377

@@ -302,9 +296,16 @@ See the `Geolocation cache lifetime` setting above to set the lifetime of this r
302296

303297
Enable if you want to see some debug information in a specific log file.
304298

305-
When this mode is enabled, a `debug.log` file will be written in a `wp-content/plugins/crowdsec/logs`
306-
sub folder.
307-
Note that by default, there is always a `prod.log` file in the same folder.
299+
When this mode is enabled, a `debug.log` file will be written in `wp-content/plugins/crowdsec/logs` folder.
300+
301+
***
302+
303+
`Debug mode → Disable prod log`
304+
305+
By default, a `prod.log` file will be written in `wp-content/plugins/crowdsec/logs` folder.
306+
307+
You can disable this log here.
308+
308309

309310
***
310311

-21.1 KB
Loading
14.8 KB
Loading

inc/Bounce.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function getBouncerInstance(array $settings): Bouncer
5050
'api_timeout' => Constants::API_TIMEOUT,
5151
// Debug
5252
'debug_mode' => $this->getBoolSettings('crowdsec_debug_mode'),
53+
'disable_prod_log' => $this->getBoolSettings('crowdsec_disable_prod_log'),
5354
'log_directory_path' => Constants::CROWDSEC_LOG_BASE_PATH,
5455
'forced_test_ip' => $this->getStringSettings('crowdsec_forced_test_ip'),
5556
'forced_test_forwarded_ip' => $this->getStringSettings('crowdsec_forced_test_forwarded_ip'),
@@ -210,19 +211,17 @@ public function getPostedVariable(string $name): ?string
210211
*/
211212
public function shouldBounceCurrentIp(): bool
212213
{
213-
$shouldNotBounce = $this->getBoolSettings('crowdsec_bouncer_disabled');
214-
if ($shouldNotBounce) {
214+
$bouncingDisabled = (Constants::BOUNCING_LEVEL_DISABLED === $this->escape($this->getStringSettings('crowdsec_bouncing_level')));
215+
if ($bouncingDisabled) {
215216
if($this->logger){
216217
$this->logger->warning('', [
217218
'type' => 'WP_CONFIG_BOUNCER_DISABLED',
218219
'message' => 'Will not bounce because bouncing is disabled.',
219220
]);
220221
}
221-
222222
return false;
223223
}
224224

225-
226225
// We should not bounce when headers already sent
227226
if (headers_sent()) {
228227
return false;
@@ -274,10 +273,6 @@ public function shouldBounceCurrentIp(): bool
274273
return false;
275274
}
276275

277-
$bouncingDisabled = (Constants::BOUNCING_LEVEL_DISABLED === $this->escape($this->getStringSettings('crowdsec_bouncing_level')));
278-
if ($bouncingDisabled) {
279-
return false;
280-
}
281276

282277
return true;
283278
}
@@ -389,7 +384,8 @@ public function isConfigValid(): bool
389384
public function initLogger(array $configs): void
390385
{
391386
$isDebug = !empty($configs['crowdsec_debug_mode']);
392-
$this->logger = getStandaloneCrowdSecLoggerInstance(Constants::CROWDSEC_LOG_PATH, $isDebug, Constants::CROWDSEC_DEBUG_LOG_PATH);
387+
$disableProd = !empty($configs['crowdsec_disable_prod_log']);
388+
$this->logger = getStandaloneCrowdSecLoggerInstance($isDebug, $disableProd);
393389

394390
}
395391
}

inc/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Constants extends LibConstants
2222
public const CROWDSEC_DEBUG_LOG_PATH = __DIR__ . '/../logs/debug.log';
2323
public const CROWDSEC_CACHE_PATH = __DIR__ . '/../.cache';
2424
public const CROWDSEC_CONFIG_PATH = __DIR__ . '/standalone-settings.php';
25-
public const CROWDSEC_BOUNCER_USER_AGENT = 'WordPress CrowdSec Bouncer/v1.7.0';
25+
public const CROWDSEC_BOUNCER_USER_AGENT = 'WordPress CrowdSec Bouncer/v1.8.0';
2626
public const CROWDSEC_BOUNCER_GEOLOCATION_DIR = __DIR__ . '/../geolocation';
2727

2828
}

inc/admin/advanced-settings.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ function convertInlineIpRangesToComparableIpBounds(string $inlineIpRanges): arra
355355

356356
// Field "crowdsec_debug_mode"
357357
addFieldCheckbox('crowdsec_debug_mode', 'Enable debug mode', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_debug', function () {}, function () {}, '
358-
<p>Should not be used in production.<br>When this mode is enabled, a debug.log file will be written in the <i>wp-content/plugins/crowdsec/logs</i> folder.<br> Note that by default, there is always a prod.log file in the same folder.</p>');
358+
<p>Should not be used in production.<br>When this mode is enabled, a debug.log file will be written in the <i>wp-content/plugins/crowdsec/logs</i> folder.</p>');
359+
360+
// Field "crowdsec_disable_prod_log"
361+
addFieldCheckbox('crowdsec_disable_prod_log', 'Disable prod log', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_debug', function () {}, function () {}, '
362+
<p>By default, a prod.log file will be written in the <i>wp-content/plugins/crowdsec/logs</i> folder.<br>You can disable this log here.</p>');
359363

360364
/*******************************
361365
** Section "Display errors" **

0 commit comments

Comments
 (0)