Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [2.13.0](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.13.0) - 2025-12-12
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.12.0...v2.13.0)

### Changed

- Allow sending remediation metrics even with BLaaS LAPI

### Removed

- Remove "Reset remediation metrics" feature previously added for BLaaS LAPI


---


## [2.12.0](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.12.0) - 2025-12-05
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.11.1...v2.12.0)

Expand Down
4 changes: 2 additions & 2 deletions crowdsec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://github.com/crowdsecurity/cs-wordpress-bouncer
* Description: Safer Together. Protect your WordPress application with CrowdSec.
* Tags: security, captcha, ip-blocker, crowdsec, hacker-protection, appsec
* Version: 2.12.0
* Version: 2.13.0
* Author: CrowdSec
* Author URI: https://www.crowdsec.net/
* Github: https://github.com/crowdsecurity/cs-wordpress-bouncer
Expand All @@ -13,7 +13,7 @@
* Requires PHP: 7.2
* Requires at least: 4.9
* Tested up to: 6.9
* Stable tag: 2.12.0
* Stable tag: 2.13.0
* Text Domain: crowdsec-wp
* First release: 2021.
*/
Expand Down
10 changes: 1 addition & 9 deletions docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,8 @@ Before publishing a new release, there are some manual steps to take:

Then, you have to [run the action manually from the GitHub repository](https://github.com/crowdsecurity/cs-wordpress-bouncer/actions/workflows/release.yml)


Alternatively, you could use the [GitHub CLI](https://github.com/cli/cli):
- create a draft release:
```
gh workflow run release.yml -f tag_name=vx.y.z -f draft=true
```
- publish a prerelease:
```
gh workflow run release.yml -f tag_name=vx.y.z -f prerelease=true
```

- publish a release:
```
gh workflow run release.yml -f tag_name=vx.y.z
Expand Down
1 change: 0 additions & 1 deletion docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ note the following:

- The Authentication type must be "Bouncer API key"
- Stream mode must be enabled (see Communication mode with the Local API in [Advanced settings](#advanced-settings)).
- Remediation Metrics cannot be sent (see Remediation Metrics in [Advanced settings](#advanced-settings)).
- AppSec component cannot be used (see Appsec Component in [Advanced settings](#advanced-settings))

***
Expand Down
8 changes: 1 addition & 7 deletions inc/Admin/advanced-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@ function crowdsec_multi_save_advanced_settings()
// Field "crowdsec_usage_metrics"
addFieldCheckbox('crowdsec_usage_metrics', 'Enable Remediation Metrics', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_usage_metrics', function () {
// Usage metrics push just activated.
$lapiUrl = is_multisite() ? get_site_option('crowdsec_api_url') : get_option('crowdsec_api_url');
if (0 === strpos($lapiUrl, Constants::BAAS_URL)) {
AdminNotice::displayError('Pushing remediation metrics with a Block as a Service LAPI ('.esc_html
($lapiUrl).') is not supported. ');
return false;
}
scheduleUsageMetricsPush();
return true;
}, function () {
Expand All @@ -182,7 +176,7 @@ function crowdsec_multi_save_advanced_settings()
<div id="usage-metrics-report">
<p>'.displayBouncerMetricsInAdminPage().'</p>
</div>
' .displayPushMetricsInAdminPage($isUsageMetricsEnabled).displayResetMetricsInAdminPage()
' .displayPushMetricsInAdminPage($isUsageMetricsEnabled)
);


Expand Down
62 changes: 0 additions & 62 deletions inc/Admin/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,6 @@ function pushBouncerMetricsInAdminPage()
}
}

function resetBouncerMetricsInAdminPage()
{
try {
$configs = getDatabaseConfigs();
$bouncer = new Bouncer($configs);
$bouncer->resetUsageMetrics();
AdminNotice::displaySuccess(__('CrowdSec remediation metrics have been reset successfully.'));
} catch (Exception $e) {
if(isset($bouncer) && $bouncer->getLogger()) {
$bouncer->getLogger()->error('', [
'type' => 'WP_EXCEPTION_WHILE_RESETTING_USAGE_METRICS',
'message' => $e->getMessage(),
'code' => $e->getCode(),
'file' => $e->getFile(),
'line' => $e->getLine(),
]);
}
AdminNotice::displayError('Technical error while resetting remediation metrics: '.$e->getMessage());
}
}

function displayBouncerMetricsInAdminPage()
{
try {
Expand Down Expand Up @@ -263,43 +242,11 @@ function displayBouncerMetricsInAdminPage()
}
}


function displayResetMetricsInAdminPage()
{
try {
$configs = getDatabaseConfigs();
$bouncer = new Bouncer($configs);
if ($bouncer->hasBaasUri()) {
return '<p><input id="crowdsec_reset_usage_metrics" style="margin-right:10px" type="button" value="Reset remediation metrics now" class="button button-secondary button-small" onclick="document.getElementById(\'crowdsec_action_reset_usage_metrics\').submit();"></p>';
}

return '';
}
catch (Exception $e) {
if (isset($bouncer) && $bouncer->getLogger()) {
$bouncer->getLogger()->error('', [
'type' => 'WP_EXCEPTION_WHILE_DISPLAYING_RESET_METRICS',
'message' => $e->getMessage(),
'code' => $e->getCode(),
'file' => $e->getFile(),
'line' => $e->getLine(),
]);
}

AdminNotice::displayError('Technical error while displaying reset metrics button: ' . esc_html($e->getMessage()));
return '';
}

}

function displayPushMetricsInAdminPage($isPushEnabled = false)
{
try {
$configs = getDatabaseConfigs();
$bouncer = new Bouncer($configs);
if($bouncer->hasBaasUri()) {
return '';
}
if( $isPushEnabled) {
return '<p><input id="crowdsec_push_usage_metrics" style="margin-right:10px" type="button" value="Push remediation metrics now" class="button button-secondary button-small" onclick="document.getElementById(\'crowdsec_action_push_usage_metrics\').submit();"></p>';
}
Expand Down Expand Up @@ -440,15 +387,6 @@ function testGeolocationInAdminPage($ip)
header("Location: {$_SERVER['HTTP_REFERER']}");
exit(0);
});
add_action('admin_post_crowdsec_reset_usage_metrics', function () {
if (
!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'crowdsec_reset_usage_metrics')) {
die('This link expired.');
}
resetBouncerMetricsInAdminPage();
header("Location: {$_SERVER['HTTP_REFERER']}");
exit(0);
});
add_action('admin_post_crowdsec_prune_cache', function () {
if (
!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'crowdsec_prune_cache')) {
Expand Down
1 change: 0 additions & 1 deletion inc/Admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ function crowdsec_multi_save_settings()
$message .= '<br><b>Please note the following: </b><ul>';
$message .= '<li>- The Authentication type must be "Bouncer API key".</li>';
$message .= '<li>- Stream mode must be enabled (see Communication mode with the Local API in Advanced Settings).</li>';
$message .= '<li>- Usage Metrics cannot be sent (see Usage Metrics in Advanced Settings).</li>';
$message .= '<li>- AppSec component cannot be used (see Appsec Component in Advanced Settings).</li>';
$message .= '</ul>';
AdminNotice::displayWarning($message);
Expand Down
2 changes: 1 addition & 1 deletion inc/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ class Constants extends LibConstants
public const BOUNCER_NAME = 'wordpress-bouncer';
public const DEFAULT_BASE_FILE_PATH = __DIR__ . '/../../../../wp-content/uploads/crowdsec/';
public const STANDALONE_CONFIG_PATH = __DIR__ . '/standalone-settings.php';
public const VERSION = 'v2.12.0';
public const VERSION = 'v2.13.0';
}
5 changes: 0 additions & 5 deletions inc/templates/advanced-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ function updateDsnDisplay () {
<form action="<?php echo admin_url('admin-post.php'); ?>" method="post" id="crowdsec_action_push_usage_metrics">
<input type="hidden" name="action" value="crowdsec_push_usage_metrics">
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce('crowdsec_push_usage_metrics'); ?>">
</form>
<form action="<?php echo admin_url('admin-post.php'); ?>" method="post"
id="crowdsec_action_reset_usage_metrics">
<input type="hidden" name="action" value="crowdsec_reset_usage_metrics">
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce('crowdsec_reset_usage_metrics'); ?>">
</form>
</div>
<p style="padding-top:15px">
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://crowdsec.net/
Tags: security, captcha, ip-blocker, crowdsec, hacker-protection
Requires at least: 4.9
Tested up to: 6.9
Stable tag: 2.12.0
Stable tag: 2.13.0
Requires PHP: 7.2
License: MIT
License URI: https://opensource.org/licenses/MIT
Expand Down Expand Up @@ -63,6 +63,10 @@ Multiple ways you can use the plugin

== Changelog ==

= 2.13 (2025-12-12) =

- Allow sending remediation metrics even with a Blocklist as a Service (BLaaS) LAPI

= 2.12 (2025-12-05) =

- Remove Blocklist as a Service (BLaaS) subscription button
Expand Down
24 changes: 2 additions & 22 deletions tests/e2e-ddev/__tests__/14-blaas.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@ describe("Check BLaaS URL behavior", () => {
}
});

it("Should block remediation metrics", async () => {
await goToAdmin();
await onAdminGoToAdvancedPage();
await setToggle("crowdsec_usage_metrics", true);

await onAdminSaveSettings(false);
await expect(page).toHaveText(
".notice-error",
`Pushing remediation metrics with a Block as a Service LAPI (${FAKE_BLAAS_URL}) is not supported.`,
);
});

it('Should block AppSec"', async () => {
await goToAdmin();
await onAdminGoToAdvancedPage();
Expand All @@ -153,22 +141,14 @@ describe("Check BLaaS URL behavior", () => {
);
});

it("Should interact with remediation metrics", async () => {
it("Should have remediation metrics", async () => {
await goToAdmin();
await onAdminGoToAdvancedPage();
await expect(page).toHaveText("#metrics-cscli-ban", "ban: 1");
await expect(page).toHaveText("#metrics-total-ban", "ban: 1");
const count = await page
.locator("#crowdsec_push_usage_metrics")
.count();
await expect(count).toBe(0);

await page.click("#crowdsec_reset_usage_metrics");

await expect(page).toHaveText(
"#wpbody-content > div.wrap > div.notice.notice-success",
"CrowdSec remediation metrics have been reset successfully.",
);
await expect(page).toHaveText("#metrics-no-new", "No new metrics");
await expect(count).toBe(1);
});
});