Skip to content

Commit 1428b72

Browse files
feat(*): Add usage metrics support (#135)
* feat(*): Use bouncing_level and capRemediation from remediation engine * feat(*): Add pushUsageMetrics method and catch Throwable wherever possible * feat(*): Increment clean origin count when should not bounce is detected * feat(*): Restrict bouncer to LAPI remediation only * docs(changelog): Mention unpublished release * feat(cache): Decrement clean origin count if appsec is used * feat(captcha): Handle captcha origin count when solved * feat(metrics): Update origins count after remediation * feat(origin): Handle clean origin for appsec * docs(changelog): Prepare next release * ci(doc links): Add trigger for pull request [skip ci]
1 parent 0df5a4c commit 1428b72

13 files changed

+441
-285
lines changed

.github/workflows/doc-links.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ on:
33
push:
44
branches:
55
- main
6+
pull_request:
7+
branches:
8+
- main
69

710
permissions:
811
contents: read
912

10-
name: Documentation links
13+
name: Documentation links check
1114
jobs:
1215
markdown-test:
1316
name: Markdown files test

CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,32 @@ The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this librar
99

1010
As far as possible, we try to adhere to [Symfony guidelines](https://symfony.com/doc/current/contributing/code/bc.html#working-on-symfony-code) when deciding whether a change is a breaking change or not.
1111

12+
---
13+
14+
## [4.0.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v4.0.0) - 202?-??-??
15+
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v3.2.0...HEAD)
16+
17+
**This release is not yet published**
18+
19+
### Added
20+
21+
- Add `pushUsageMetrics` method to `AbstractBouncer` class
22+
- Save origins count item in cache after a remediation has been applied
23+
24+
### Changed
25+
26+
- **Breaking change**: `AbstractBouncer::getRemediationForIp` method returns now an array with `remediation` and
27+
`origin` keys.
28+
- **Breaking change**: `$remediationEngine` params of `AbstractBouncer` constructor is now a `LapiRemediationEngine` instance
29+
- **Breaking change**: `AbstractBouncer::getAppSecRemediationForIp` don't need `$remediationEngine` param anymore
30+
- **Breaking change**: `AbstractBouncer::handleRemediation` requires a new `origin` param
31+
- Update `crowdsec/remediation-engine` dependency to `v4.0.0`
32+
33+
### Removed
34+
35+
- **Breaking change**: Remove `bouncing_level` constants and configuration as it is now in `crowdsec/remediation-engine` package
36+
37+
1238
---
1339

1440
## [3.2.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v3.2.0) - 2024-10-23

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
],
4242
"require": {
4343
"php": ">=7.2.5",
44-
"crowdsec/remediation-engine": "^3.5.0",
44+
"crowdsec/remediation-engine": "^4.0.0",
4545
"crowdsec/common": "^2.3.2",
4646
"symfony/config": "^4.4.27 || ^5.2 || ^6.0",
4747
"twig/twig": "^3.4.2",
@@ -52,6 +52,7 @@
5252
},
5353
"require-dev": {
5454
"phpunit/phpunit": "^8.5.30 || ^9.3",
55-
"mikey179/vfsstream": "^1.6.11"
55+
"mikey179/vfsstream": "^1.6.11",
56+
"nikic/php-parser": "^4.18"
5657
}
5758
}

docs/DEVELOPER.md

+18
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ Run:
146146
ddev composer update --working-dir ./my-code/crowdsec-bouncer-lib
147147
```
148148

149+
For advanced usage, you can create a `composer-dev.json` file in the `my-code/crowdsec-bouncer-lib` folder and run:
150+
151+
```bash
152+
ddev exec COMPOSER=composer-dev.json composer update --working-dir ./my-code/crowdsec-bouncer-lib
153+
```
154+
155+
149156
#### Find IP of your docker services
150157

151158
In most cases, you will test to bounce your current IP. As we are running on a docker stack, this is the local host IP.
@@ -222,6 +229,17 @@ We set up some coding standards tools that you will find in the `tools/coding-st
222229
ddev composer update --working-dir=./my-code/crowdsec-bouncer-lib/tools/coding-standards
223230
```
224231

232+
For advanced usage, you can create a `composer-dev.json` file in the
233+
`my-code/crowdsec-bouncer-lib/tools/coding-standards` folder and
234+
run:
235+
236+
```bash
237+
ddev exec COMPOSER=composer-dev.json composer update --working-dir ./my-code/crowdsec-bouncer-lib/tools/coding-standards
238+
```
239+
240+
Then, you can use the following commands:
241+
242+
225243
##### PHPCS Fixer
226244

227245
We are using the [PHP Coding Standards Fixer](https://cs.symfony.com/). With ddev, you can do the following:

docs/USER_GUIDE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
## Description
3232

33-
This library allows you to create CrowdSec bouncers for PHP applications or frameworks like e-commerce, blog or other
33+
This library allows you to create CrowdSec LAPI bouncers for PHP applications or frameworks like e-commerce, blog or other
3434
exposed applications.
3535

3636
## Prerequisites
@@ -45,11 +45,11 @@ Please note that first and foremost a CrowdSec agent must be installed on a serv
4545
- Handle `ip`, `range` and `country` scoped decisions
4646
- `Live mode` or `Stream mode`
4747
- AppSec support
48+
- Usage metrics support
4849
- Support IpV4 and Ipv6 (Ipv6 range decisions are yet only supported in `Live mode`)
4950
- Large PHP matrix compatibility: from 7.2 to 8.4
5051
- Built-in support for the most known cache systems Redis, Memcached and PhpFiles
5152
- Clear, prune and refresh the bouncer cache
52-
- Cap remediation level (ex: for sensitives websites: ban will be capped to captcha)
5353

5454

5555
## Usage

0 commit comments

Comments
 (0)