diff --git a/.githooks/commit-msg b/.githooks/commit-msg
index 1608390..b3cca0c 100644
--- a/.githooks/commit-msg
+++ b/.githooks/commit-msg
@@ -5,7 +5,7 @@ if [ -z "$1" ]; then
exit 1
fi
-commitTitle="$(cat $1 | head -n1)"
+commitTitle="$(head -n 1 < "$1")"
# ignore merge
if echo "$commitTitle" | grep -qE "^Merge"; then
@@ -15,7 +15,7 @@ fi
# check commit message
REGEX='^(feat|fix|docs|style|refactor|ci|test|chore|comment)\(.*\)\:.*'
-if ! echo "$commitTitle" | grep -qE ${REGEX}; then
+if ! echo "$commitTitle" | grep -qE "${REGEX}"; then
echo "Your commit title '$commitTitle' did not follow conventional commit message rules:"
echo "Please comply with the regex ${REGEX}"
exit 1
diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml
index 95460a4..ba09b77 100644
--- a/.github/workflows/coding-standards.yml
+++ b/.github/workflows/coding-standards.yml
@@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- php-version: ['7.4', '8.0', '8.1', '8.2']
+ php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
name: Coding standards
runs-on: ubuntu-latest
@@ -42,7 +42,7 @@ jobs:
sudo apt-get -q update
sudo apt-get -q -y install libnss3-tools ddev
mkcert -install
- ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
+ ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
- name: Create empty PHP DDEV project
run: ddev config --project-type=php --project-name=crowdsec-bouncer-lib --php-version=${{ matrix.php-version }}
@@ -53,7 +53,12 @@ jobs:
ddev get ddev/ddev-memcached
# override redis.conf
ddev get julienloizelet/ddev-tools
- ddev get julienloizelet/ddev-crowdsec-php
+ ddev get julienloizelet/ddev-crowdsec-php
+
+ - name: Add Redis, Memcached and X-Debug
+ if: ${{ matrix.php-version == '8.3' }}
+ run: |
+ cp .ddev/okaeli-add-on/common/custom_files/config.php83missing.yaml .ddev/config.php83missing.yaml
- name: Start DDEV
run: |
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 37aac58..a4dcfa8 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,8 +2,6 @@ name: Create Release
# example: gh workflow run release.yml -f tag_name=v1.1.4 -f draft=true
on:
workflow_dispatch:
- branches:
- - main
inputs:
tag_name:
type: string
diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml
index e7b9c69..cded0e4 100644
--- a/.github/workflows/test-suite.yml
+++ b/.github/workflows/test-suite.yml
@@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
+ php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
name: Test suite
runs-on: ubuntu-latest
@@ -40,7 +40,7 @@ jobs:
sudo apt-get -q update
sudo apt-get -q -y install libnss3-tools ddev
mkcert -install
- ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
+ ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
- name: Create empty PHP DDEV project
run: ddev config --project-type=php --project-name=${{env.DDEV_PROJECT}} --php-version=${{ matrix.php-version }}
@@ -53,6 +53,11 @@ jobs:
ddev get julienloizelet/ddev-tools
ddev get julienloizelet/ddev-crowdsec-php
+ - name: Add Redis, Memcached and X-Debug
+ if: ${{ matrix.php-version == '8.3' }}
+ run: |
+ cp .ddev/okaeli-add-on/common/custom_files/config.php83missing.yaml .ddev/config.php83missing.yaml
+
- name: Start DDEV
run: ddev start
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ccbd7a..8cd53db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/) and th
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.
+---
+
+
+## [2.1.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v2.1.0) - 202?-??-??
+[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v2.0.0...v2.1.0)
+
+
+### Changed
+
+- Update `gregwar/captcha` from `1.2.0` to `1.2.1` and remove override fixes
+- Update `crowdsec/common` dependency to `v2.2.0` (`api_connect_timeout` setting)
+- Update `crowdsec/remediation-engine` dependency to `v3.2.0` (`api_connect_timeout` setting)
+
+
---
## [2.0.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v2.0.0) - 2023-04-13
diff --git a/composer.json b/composer.json
index 52c70d5..3ac0516 100644
--- a/composer.json
+++ b/composer.json
@@ -41,10 +41,10 @@
"require": {
"php": ">=7.2.5",
"crowdsec/remediation-engine": "^3.1.1",
- "crowdsec/common": "^2.1.0",
+ "crowdsec/common": "^2.2.0",
"symfony/config": "^4.4.27 || ^5.2 || ^6.0",
"twig/twig": "^3.4.2",
- "gregwar/captcha": "^1.2.0",
+ "gregwar/captcha": "^1.2.1",
"mlocati/ip-lib": "^1.18",
"ext-json": "*",
"ext-gd": "*"
diff --git a/docs/USER_GUIDE.md b/docs/USER_GUIDE.md
index 1e95003..620da9f 100644
--- a/docs/USER_GUIDE.md
+++ b/docs/USER_GUIDE.md
@@ -45,7 +45,7 @@ Please note that first and foremost a CrowdSec agent must be installed on a serv
- Handle `ip`, `range` and `country` scoped decisions
- `Live mode` or `Stream mode`
- Support IpV4 and Ipv6 (Ipv6 range decisions are yet only supported in `Live mode`)
-- Large PHP matrix compatibility: 7.2, 7.3, 7.4, 8.0, 8.1 and 8.2
+- Large PHP matrix compatibility: 7.2, 7.3, 7.4, 8.0, 8.1, 8.2 and 8.3
- Built-in support for the most known cache systems Redis, Memcached and PhpFiles
- Clear, prune and refresh the bouncer cache
- Cap remediation level (ex: for sensitives websites: ban will be capped to captcha)
@@ -240,8 +240,12 @@ Below is the list of available settings:
- `api_url`: Define the URL to your Local API server, default to `http://localhost:8080`.
-- `api_timeout`: In seconds. The timeout when calling Local API. Default to 120 sec. If set to a negative value,
- timeout will be unlimited.
+- `api_timeout`: In seconds. The global timeout when calling Local API. Default to 120 sec. If set to a negative value
+ or 0, timeout will be unlimited.
+
+
+- `api_connect_timeout`: In seconds. **Only for curl**. The timeout for the connection phase when calling Local API.
+ Default to 300 sec. If set to a 0, timeout will be unlimited.
### Cache
diff --git a/src/AbstractBouncer.php b/src/AbstractBouncer.php
index f21581f..5036bbd 100644
--- a/src/AbstractBouncer.php
+++ b/src/AbstractBouncer.php
@@ -13,7 +13,7 @@
use CrowdSec\RemediationEngine\CacheStorage\Memcached;
use CrowdSec\RemediationEngine\CacheStorage\PhpFiles;
use CrowdSec\RemediationEngine\CacheStorage\Redis;
-use CrowdSecBouncer\Fixes\Gregwar\Captcha\CaptchaBuilder;
+use Gregwar\Captcha\CaptchaBuilder;
use Gregwar\Captcha\PhraseBuilder;
use IPLib\Factory;
use Monolog\Handler\NullHandler;
@@ -108,8 +108,6 @@ public function clearCache(): bool
/**
* Retrieve Bouncer configuration by name.
- *
- * @return mixed
*/
public function getConfig(string $name)
{
diff --git a/src/Configuration.php b/src/Configuration.php
index 27c9c93..668e2c7 100644
--- a/src/Configuration.php
+++ b/src/Configuration.php
@@ -44,8 +44,6 @@ class Configuration extends AbstractConfiguration
];
/**
- * {@inheritdoc}
- *
* @throws \InvalidArgumentException
*/
public function getConfigTreeBuilder(): TreeBuilder
@@ -157,7 +155,6 @@ private function addDebugNodes($rootNode)
}
/**
- * @param $rootNode
* @return void
*/
private function addTemplateNodes($rootNode)
diff --git a/src/Fixes/Gregwar/Captcha/CaptchaBuilder.php b/src/Fixes/Gregwar/Captcha/CaptchaBuilder.php
deleted file mode 100644
index 5cd8418..0000000
--- a/src/Fixes/Gregwar/Captcha/CaptchaBuilder.php
+++ /dev/null
@@ -1,58 +0,0 @@
-rand(0, 3) - 1;
- $box = \imagettfbbox($size, 0, $font, $phrase);
- $textWidth = $box[2] - $box[0];
- $textHeight = $box[1] - $box[7];
- $x = (int) round(($width - $textWidth) / 2);
- $y = (int) round(($height - $textHeight) / 2) + $size;
-
- if (!$this->textColor) {
- $textColor = [$this->rand(0, 150), $this->rand(0, 150), $this->rand(0, 150)];
- } else {
- $textColor = $this->textColor;
- }
- $col = \imagecolorallocate($image, $textColor[0], $textColor[1], $textColor[2]);
-
- // Write the letters one by one, with random angle
- for ($i = 0; $i < $length; ++$i) {
- $symbol = mb_substr($phrase, $i, 1);
- $box = \imagettfbbox($size, 0, $font, $symbol);
- $w = $box[2] - $box[0];
- $angle = $this->rand(-$this->maxAngle, $this->maxAngle);
- $offset = $this->rand(-$this->maxOffset, $this->maxOffset);
- \imagettftext($image, $size, $angle, $x, $y + $offset, $col, $font, $symbol);
- $x += $w;
- }
-
- return $col;
- }
-}
diff --git a/tests/Integration/WatcherClient.php b/tests/Integration/WatcherClient.php
index fb41d25..8e6761b 100644
--- a/tests/Integration/WatcherClient.php
+++ b/tests/Integration/WatcherClient.php
@@ -133,6 +133,7 @@ protected function getFinalScope($scope, $value)
{
$scope = (Constants::SCOPE_IP === $scope && 2 === count(explode('/', $value))) ? Constants::SCOPE_RANGE :
$scope;
+
/**
* Must use capital first letter as the crowdsec agent seems to query with first capital letter
* during getStreamDecisions.
diff --git a/tests/Unit/AbstractBouncerTest.php b/tests/Unit/AbstractBouncerTest.php
index 44d7976..72009c8 100644
--- a/tests/Unit/AbstractBouncerTest.php
+++ b/tests/Unit/AbstractBouncerTest.php
@@ -53,7 +53,6 @@
* @covers \CrowdSecBouncer\AbstractBouncer::shouldBounceCurrentIp
* @covers \CrowdSecBouncer\AbstractBouncer::checkCaptcha
* @covers \CrowdSecBouncer\AbstractBouncer::buildCaptchaCouple
- * @covers \CrowdSecBouncer\Fixes\Gregwar\Captcha\CaptchaBuilder::writePhrase
* @covers \CrowdSecBouncer\AbstractBouncer::getCache
* @covers \CrowdSecBouncer\AbstractBouncer::getBanHtml
* @covers \CrowdSecBouncer\Template::__construct
diff --git a/tools/coding-standards/psalm/psalm.xml b/tools/coding-standards/psalm/psalm.xml
index db18b2a..c9b35bf 100644
--- a/tools/coding-standards/psalm/psalm.xml
+++ b/tools/coding-standards/psalm/psalm.xml
@@ -11,7 +11,6 @@
-