diff --git a/.github/workflows/doc-links.yml b/.github/workflows/doc-links.yml index d9b7341..9343be8 100644 --- a/.github/workflows/doc-links.yml +++ b/.github/workflows/doc-links.yml @@ -33,6 +33,6 @@ jobs: run: | gem install awesome_bot cd extension - awesome_bot --files README.md --allow-dupe --allow 401 --skip-save-results --white-list ddev.site --base-url http://localhost:8080/ - awesome_bot docs/*.md --skip-save-results --allow-dupe --allow 401 --white-list ddev.site,https://crowdsec,php.net/supported-versions.php --base-url http://localhost:8080/docs/ + awesome_bot --files README.md --allow-dupe --allow 401,301 --skip-save-results --white-list ddev.site --base-url http://localhost:8080/ + awesome_bot docs/*.md --skip-save-results --allow-dupe --allow 401,301 --white-list ddev.site,https://crowdsec,http://crowdsec,php.net/supported-versions.php --base-url http://localhost:8080/docs/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e8569d..2fdf8f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,25 +1,11 @@ name: Create Release -# example: gh workflow run release.yml -f tag_name=v1.1.4 -f draft=true +# example: gh workflow run release.yml -f tag_name=v1.1.4 on: workflow_dispatch: - branches: - - main inputs: tag_name: type: string required: true - draft: - type: boolean - description: Draft release - default: false - prerelease: - type: boolean - description: Prerelease - default: false - first-release: - type: boolean - description: First release - default: false jobs: prepare-release: @@ -41,7 +27,7 @@ jobs: echo "VERSION_NUMBER=$(echo ${{ github.event.inputs.tag_name }} | sed 's/v//g' )" >> $GITHUB_ENV - name: Clone sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Check version ${{ env.VERSION_NUMBER }} consistency in files # Check src/Constants.php and CHANGELOG.md @@ -70,23 +56,20 @@ jobs: fi # Check top [_Compare with previous release_](GITHUB_URL/compare/vLAST_TAG...vVERSION_NUMBER) in CHANGELOG.md - if [[ ${{ github.event.inputs.first-release }} != "true" ]] + COMPARISON=$(grep -oP "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/\K(.*)$" CHANGELOG.md | head -1) + LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/latest | grep -oP "\/tag\/\K(.*)$") + if [[ $COMPARISON == "$LAST_TAG...v${{ env.VERSION_NUMBER }})" ]] then - COMPARISON=$(grep -oP "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/\K(.*)$" CHANGELOG.md | head -1) - LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/latest | grep -oP "\/tag\/\K(.*)$") - if [[ $COMPARISON == "$LAST_TAG...v${{ env.VERSION_NUMBER }})" ]] - then - echo "VERSION COMPARISON OK" - else - echo "VERSION COMPARISON KO" - echo $COMPARISON - echo "$LAST_TAG...v${{ env.VERSION_NUMBER }})" - exit 1 - fi + echo "VERSION COMPARISON OK" + else + echo "VERSION COMPARISON KO" + echo $COMPARISON + echo "$LAST_TAG...v${{ env.VERSION_NUMBER }})" + exit 1 fi - name: Create Tag ${{ github.event.inputs.tag_name }} - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{ github.token }} script: | diff --git a/src/Bouncer.php b/src/Bouncer.php index e8a7082..294a2dc 100644 --- a/src/Bouncer.php +++ b/src/Bouncer.php @@ -83,6 +83,9 @@ public function getRemoteIp(): string return $_SERVER['REMOTE_ADDR'] ?? ''; } + /** + * @SuppressWarnings(PHPMD.ElseExpression) + */ public function getRequestHeaders(): array { $allHeaders = []; diff --git a/tests/Integration/IpVerificationTest.php b/tests/Integration/IpVerificationTest.php index 2ca6eb9..cf3b88e 100644 --- a/tests/Integration/IpVerificationTest.php +++ b/tests/Integration/IpVerificationTest.php @@ -699,11 +699,16 @@ public function testAppSecFlow() ); $originCountItem = $cache->getItem(AbstractCache::ORIGINS_COUNT)->get(); - $this->assertEquals( - 1, - $originCountItem['appsec'], - 'The origin count for appsec should be 1' - ); + if ($this->useTls) { + $this->assertArrayHasNotKey('appsec', $originCountItem, 'The origin count for appsec should not be set'); + } else { + $this->assertEquals( + 1, + $originCountItem['appsec'], + 'The origin count for appsec should be 1' + ); + } + $this->assertEquals( 1, $originCountItem['clean'], @@ -728,11 +733,15 @@ public function testAppSecFlow() ); $originCountItem = $cache->getItem(AbstractCache::ORIGINS_COUNT)->get(); - $this->assertEquals( - 1, - $originCountItem['clean_appsec'], - 'The origin count for clean_appsec should be 1' - ); + if ($this->useTls) { + $this->assertArrayHasNotKey('clean_appsec', $originCountItem, 'The origin count for clean appsec should not be set'); + } else { + $this->assertEquals( + 1, + $originCountItem['clean_appsec'], + 'The origin count for clean appsec should be 1' + ); + } $this->assertEquals( 1, $originCountItem['clean'],