Skip to content

Commit 247949f

Browse files
feat(*): Update Gregwar Captcha and add PHP 8.3 tests (#130)
* feat(captcha): Update Gregwar/Captcha to 1.2.1 and remove fixes * docs(user guide): Add api_connect_timeout mention * test(8.3): Add tests for PHP 8.3 * test(fix): Fix ddev install * test(*): Add PHP 8.3 test * docs(user guide): Mention PHP 8.3
1 parent 2920637 commit 247949f

File tree

13 files changed

+42
-80
lines changed

13 files changed

+42
-80
lines changed

.githooks/commit-msg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if [ -z "$1" ]; then
55
exit 1
66
fi
77

8-
commitTitle="$(cat $1 | head -n1)"
8+
commitTitle="$(head -n 1 < "$1")"
99

1010
# ignore merge
1111
if echo "$commitTitle" | grep -qE "^Merge"; then
@@ -15,7 +15,7 @@ fi
1515

1616
# check commit message
1717
REGEX='^(feat|fix|docs|style|refactor|ci|test|chore|comment)\(.*\)\:.*'
18-
if ! echo "$commitTitle" | grep -qE ${REGEX}; then
18+
if ! echo "$commitTitle" | grep -qE "${REGEX}"; then
1919
echo "Your commit title '$commitTitle' did not follow conventional commit message rules:"
2020
echo "Please comply with the regex ${REGEX}"
2121
exit 1

.github/workflows/coding-standards.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
php-version: ['7.4', '8.0', '8.1', '8.2']
27+
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
2828

2929
name: Coding standards
3030
runs-on: ubuntu-latest
@@ -42,7 +42,7 @@ jobs:
4242
sudo apt-get -q update
4343
sudo apt-get -q -y install libnss3-tools ddev
4444
mkcert -install
45-
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
45+
ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
4646
4747
- name: Create empty PHP DDEV project
4848
run: ddev config --project-type=php --project-name=crowdsec-bouncer-lib --php-version=${{ matrix.php-version }}
@@ -53,7 +53,12 @@ jobs:
5353
ddev get ddev/ddev-memcached
5454
# override redis.conf
5555
ddev get julienloizelet/ddev-tools
56-
ddev get julienloizelet/ddev-crowdsec-php
56+
ddev get julienloizelet/ddev-crowdsec-php
57+
58+
- name: Add Redis, Memcached and X-Debug
59+
if: ${{ matrix.php-version == '8.3' }}
60+
run: |
61+
cp .ddev/okaeli-add-on/common/custom_files/config.php83missing.yaml .ddev/config.php83missing.yaml
5762
5863
- name: Start DDEV
5964
run: |

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Create Release
22
# example: gh workflow run release.yml -f tag_name=v1.1.4 -f draft=true
33
on:
44
workflow_dispatch:
5-
branches:
6-
- main
75
inputs:
86
tag_name:
97
type: string

.github/workflows/test-suite.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
22+
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
2323

2424
name: Test suite
2525
runs-on: ubuntu-latest
@@ -40,7 +40,7 @@ jobs:
4040
sudo apt-get -q update
4141
sudo apt-get -q -y install libnss3-tools ddev
4242
mkcert -install
43-
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
43+
ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
4444
4545
- name: Create empty PHP DDEV project
4646
run: ddev config --project-type=php --project-name=${{env.DDEV_PROJECT}} --php-version=${{ matrix.php-version }}
@@ -53,6 +53,11 @@ jobs:
5353
ddev get julienloizelet/ddev-tools
5454
ddev get julienloizelet/ddev-crowdsec-php
5555
56+
- name: Add Redis, Memcached and X-Debug
57+
if: ${{ matrix.php-version == '8.3' }}
58+
run: |
59+
cp .ddev/okaeli-add-on/common/custom_files/config.php83missing.yaml .ddev/config.php83missing.yaml
60+
5661
- name: Start DDEV
5762
run: ddev start
5863

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/) and th
77

88
The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this library consists of all public or protected methods, properties and constants belonging to the `src` folder.
99

10+
---
11+
12+
13+
## [2.1.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v2.1.0) - 202?-??-??
14+
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v2.0.0...v2.1.0)
15+
16+
17+
### Changed
18+
19+
- Update `gregwar/captcha` from `1.2.0` to `1.2.1` and remove override fixes
20+
- Update `crowdsec/common` dependency to `v2.2.0` (`api_connect_timeout` setting)
21+
- Update `crowdsec/remediation-engine` dependency to `v3.2.0` (`api_connect_timeout` setting)
22+
23+
1024
---
1125

1226
## [2.0.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v2.0.0) - 2023-04-13

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
"require": {
4242
"php": ">=7.2.5",
4343
"crowdsec/remediation-engine": "^3.1.1",
44-
"crowdsec/common": "^2.1.0",
44+
"crowdsec/common": "^2.2.0",
4545
"symfony/config": "^4.4.27 || ^5.2 || ^6.0",
4646
"twig/twig": "^3.4.2",
47-
"gregwar/captcha": "^1.2.0",
47+
"gregwar/captcha": "^1.2.1",
4848
"mlocati/ip-lib": "^1.18",
4949
"ext-json": "*",
5050
"ext-gd": "*"

docs/USER_GUIDE.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ 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
- Support IpV4 and Ipv6 (Ipv6 range decisions are yet only supported in `Live mode`)
48-
- Large PHP matrix compatibility: 7.2, 7.3, 7.4, 8.0, 8.1 and 8.2
48+
- Large PHP matrix compatibility: 7.2, 7.3, 7.4, 8.0, 8.1, 8.2 and 8.3
4949
- Built-in support for the most known cache systems Redis, Memcached and PhpFiles
5050
- Clear, prune and refresh the bouncer cache
5151
- Cap remediation level (ex: for sensitives websites: ban will be capped to captcha)
@@ -240,8 +240,12 @@ Below is the list of available settings:
240240
- `api_url`: Define the URL to your Local API server, default to `http://localhost:8080`.
241241

242242

243-
- `api_timeout`: In seconds. The timeout when calling Local API. Default to 120 sec. If set to a negative value,
244-
timeout will be unlimited.
243+
- `api_timeout`: In seconds. The global timeout when calling Local API. Default to 120 sec. If set to a negative value
244+
or 0, timeout will be unlimited.
245+
246+
247+
- `api_connect_timeout`: In seconds. **Only for curl**. The timeout for the connection phase when calling Local API.
248+
Default to 300 sec. If set to a 0, timeout will be unlimited.
245249

246250

247251
### Cache

src/AbstractBouncer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use CrowdSec\RemediationEngine\CacheStorage\Memcached;
1414
use CrowdSec\RemediationEngine\CacheStorage\PhpFiles;
1515
use CrowdSec\RemediationEngine\CacheStorage\Redis;
16-
use CrowdSecBouncer\Fixes\Gregwar\Captcha\CaptchaBuilder;
16+
use Gregwar\Captcha\CaptchaBuilder;
1717
use Gregwar\Captcha\PhraseBuilder;
1818
use IPLib\Factory;
1919
use Monolog\Handler\NullHandler;
@@ -108,8 +108,6 @@ public function clearCache(): bool
108108

109109
/**
110110
* Retrieve Bouncer configuration by name.
111-
*
112-
* @return mixed
113111
*/
114112
public function getConfig(string $name)
115113
{

src/Configuration.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class Configuration extends AbstractConfiguration
4444
];
4545

4646
/**
47-
* {@inheritdoc}
48-
*
4947
* @throws \InvalidArgumentException
5048
*/
5149
public function getConfigTreeBuilder(): TreeBuilder
@@ -157,7 +155,6 @@ private function addDebugNodes($rootNode)
157155
}
158156

159157
/**
160-
* @param $rootNode
161158
* @return void
162159
*/
163160
private function addTemplateNodes($rootNode)

src/Fixes/Gregwar/Captcha/CaptchaBuilder.php

Lines changed: 0 additions & 58 deletions
This file was deleted.

tests/Integration/WatcherClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ protected function getFinalScope($scope, $value)
133133
{
134134
$scope = (Constants::SCOPE_IP === $scope && 2 === count(explode('/', $value))) ? Constants::SCOPE_RANGE :
135135
$scope;
136+
136137
/**
137138
* Must use capital first letter as the crowdsec agent seems to query with first capital letter
138139
* during getStreamDecisions.

tests/Unit/AbstractBouncerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
* @covers \CrowdSecBouncer\AbstractBouncer::shouldBounceCurrentIp
5454
* @covers \CrowdSecBouncer\AbstractBouncer::checkCaptcha
5555
* @covers \CrowdSecBouncer\AbstractBouncer::buildCaptchaCouple
56-
* @covers \CrowdSecBouncer\Fixes\Gregwar\Captcha\CaptchaBuilder::writePhrase
5756
* @covers \CrowdSecBouncer\AbstractBouncer::getCache
5857
* @covers \CrowdSecBouncer\AbstractBouncer::getBanHtml
5958
* @covers \CrowdSecBouncer\Template::__construct

tools/coding-standards/psalm/psalm.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<directory name="../../../src" />
1212
<ignoreFiles>
1313
<directory name="../../../vendor" />
14-
<directory name="../../../src/Fixes" />
1514
</ignoreFiles>
1615
</projectFiles>
1716
<issueHandlers>

0 commit comments

Comments
 (0)