Skip to content

Commit 8d1a58b

Browse files
Deliver firewall to php 8.5 (#362)
1 parent 0143eb4 commit 8d1a58b

File tree

13 files changed

+158
-28
lines changed

13 files changed

+158
-28
lines changed

.github/workflows/Dockerfile.centos-php-test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ RUN dnf --assumeyes module reset php
1919
RUN dnf --assumeyes --nogpgcheck module install php:remi-${PHP_VERSION}
2020
RUN dnf --assumeyes install php-pdo
2121
RUN dnf --assumeyes install php-mysqlnd
22+
RUN if [ "$(printf '%s\n' "${PHP_VERSION}" "8.5" | sort -V | head -n1)" != "8.5" ]; then \
23+
dnf --assumeyes install php-opcache || true; \
24+
fi
2225
RUN yum install -y mod_php nginx php-fpm procps-ng mysql-server
2326

2427

.github/workflows/Dockerfile.ubuntu-php-test

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ RUN set -eux; \
3333
mariadb-server \
3434
${PHP_PKG} ${PHP_PKG}-cli ${PHP_PKG}-common ${PHP_PKG}-fpm \
3535
${PHP_PKG}-curl ${PHP_PKG}-sqlite3 ${PHP_PKG}-mysql \
36-
${PHP_PKG}-mbstring ${PHP_PKG}-xml ${PHP_PKG}-zip ${PHP_PKG}-opcache \
36+
${PHP_PKG}-mbstring ${PHP_PKG}-xml ${PHP_PKG}-zip \
3737
libapache2-mod-php${PHP_VERSION} \
3838
; \
3939
# Apache: switch to prefork for mod_php scenario and enable rewrite
4040
a2dismod mpm_event || true; \
4141
a2dismod mpm_worker || true; \
4242
a2enmod mpm_prefork rewrite || true
4343

44+
RUN if [ "$(printf '%s\n' "${PHP_VERSION}" "8.5" | sort -V | head -n1)" != "8.5" ]; then \
45+
apt-get install -y --no-install-recommends php${PHP_VERSION}-opcache; \
46+
fi
47+
4448
# ---- Python toolchain used by tests ----
4549
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
4650
PYTHONDONTWRITEBYTECODE=1 \
@@ -93,7 +97,7 @@ RUN printf '%s\n' '#!/usr/bin/env bash' \
9397
'if ! a2query -m "php${ver}" >/dev/null 2>&1; then' \
9498
' apt-get update && apt-get install -y --no-install-recommends "libapache2-mod-php${ver}"' \
9599
'fi' \
96-
'for m in php5 php7 php7.0 php7.1 php7.2 php7.3 php7.4 php8 php8.0 php8.1 php8.2 php8.3 php8.4; do' \
100+
'for m in php5 php7 php7.0 php7.1 php7.2 php7.3 php7.4 php8 php8.0 php8.1 php8.2 php8.3 php8.4 php8.5; do' \
97101
' a2query -m "$m" >/dev/null 2>&1 && a2dismod "$m" >/dev/null 2>&1 || true' \
98102
'done' \
99103
'a2enmod "php${ver}"' \

.github/workflows/build-centos-php-test-images.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-24.04
1818
strategy:
1919
matrix:
20-
php_version: ['7.4','8.0','8.1','8.2','8.3','8.4']
20+
php_version: ['7.4','8.0','8.1','8.2','8.3','8.4','8.5']
2121
fail-fast: false
2222
permissions: { contents: read, packages: write }
2323
steps:
@@ -38,14 +38,14 @@ jobs:
3838
build-args: |
3939
PHP_VERSION=${{ matrix.php_version }}
4040
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.php_version }}-amd64-${{ env.VERSION }}
41-
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-amd64-${{ env.VERSION }}
42-
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-amd64-${{ env.VERSION }},mode=max
41+
#cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-amd64-${{ env.VERSION }}
42+
#cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-amd64-${{ env.VERSION }},mode=max
4343

4444
build-arm64:
4545
runs-on: ubuntu-24.04-arm
4646
strategy:
4747
matrix:
48-
php_version: ['7.4','8.0','8.1','8.2','8.3','8.4']
48+
php_version: ['7.4','8.0','8.1','8.2','8.3','8.4','8.5']
4949
fail-fast: false
5050
permissions: { contents: read, packages: write }
5151
steps:
@@ -66,15 +66,15 @@ jobs:
6666
build-args: |
6767
PHP_VERSION=${{ matrix.php_version }}
6868
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.php_version }}-arm64-${{ env.VERSION }}
69-
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-arm64-${{ env.VERSION }}
70-
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-arm64-${{ env.VERSION }},mode=max
69+
#cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-arm64-${{ env.VERSION }}
70+
#cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-arm64-${{ env.VERSION }},mode=max
7171

7272
publish-manifests:
7373
runs-on: ubuntu-24.04
7474
needs: [build-amd64, build-arm64]
7575
strategy:
7676
matrix:
77-
php_version: ['7.4','8.0','8.1','8.2','8.3','8.4']
77+
php_version: ['7.4','8.0','8.1','8.2','8.3','8.4','8.5']
7878
fail-fast: false
7979
permissions: { contents: read, packages: write }
8080
steps:

.github/workflows/build-extension-images.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4']
21+
php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4','8.5']
2222
permissions:
2323
contents: read
2424
packages: write
@@ -53,7 +53,7 @@ jobs:
5353
strategy:
5454
fail-fast: false
5555
matrix:
56-
php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4']
56+
php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4','8.5']
5757
permissions:
5858
contents: read
5959
packages: write
@@ -91,7 +91,7 @@ jobs:
9191
strategy:
9292
fail-fast: false
9393
matrix:
94-
php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4']
94+
php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4','8.5']
9595
permissions:
9696
contents: read
9797
packages: write

.github/workflows/build-ubuntu-php-test-images.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
build-amd64:
1717
runs-on: ubuntu-24.04
1818
strategy:
19-
matrix: { php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4'] }
19+
matrix: { php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4','8.5'] }
2020
fail-fast: false
2121
permissions: { contents: read, packages: write }
2222
steps:
@@ -36,13 +36,13 @@ jobs:
3636
build-args: |
3737
PHP_VERSION=${{ matrix.php_version }}
3838
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.php_version }}-amd64-${{ env.VERSION }}
39-
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-amd64-${{ env.VERSION }}
40-
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-amd64-${{ env.VERSION }},mode=max
39+
#cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-amd64-${{ env.VERSION }}
40+
#cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-amd64-${{ env.VERSION }},mode=max
4141

4242
build-arm64:
4343
runs-on: ubuntu-24.04-arm
4444
strategy:
45-
matrix: { php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4'] }
45+
matrix: { php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4','8.5'] }
4646
fail-fast: false
4747
permissions: { contents: read, packages: write }
4848
steps:
@@ -62,14 +62,14 @@ jobs:
6262
build-args: |
6363
PHP_VERSION=${{ matrix.php_version }}
6464
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.php_version }}-arm64-${{ env.VERSION }}
65-
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-arm64-${{ env.VERSION }}
66-
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-arm64-${{ env.VERSION }},mode=max
65+
#cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-arm64-${{ env.VERSION }}
66+
#cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.php_version }}-arm64-${{ env.VERSION }},mode=max
6767

6868
publish-manifests:
6969
runs-on: ubuntu-24.04
7070
needs: [build-amd64, build-arm64]
7171
strategy:
72-
matrix: { php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4'] }
72+
matrix: { php_version: ['7.2','7.3','7.4','8.0','8.1','8.2','8.3','8.4','8.5'] }
7373
fail-fast: false
7474
permissions: { contents: read, packages: write }
7575
steps:

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
container: ghcr.io/aikidosec/firewall-php-build-extension:${{ matrix.php_version }}-v1
8585
strategy:
8686
matrix:
87-
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
87+
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
8888
arch: [ '', '-arm' ]
8989
fail-fast: false
9090

@@ -307,7 +307,7 @@ jobs:
307307
needs: [ build_rpm ]
308308
strategy:
309309
matrix:
310-
php_version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
310+
php_version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
311311
server: ['nginx-php-fpm', 'apache-mod-php', 'php-built-in']
312312
arch: ['', '-arm']
313313
fail-fast: false
@@ -394,7 +394,7 @@ jobs:
394394
strategy:
395395
matrix:
396396
arch: ['', '-arm']
397-
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
397+
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
398398
server: ['nginx-php-fpm', 'apache-mod-php', 'php-built-in']
399399
fail-fast: false
400400
steps:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Zen for PHP comes as a single package that needs to be installed on the system t
3030

3131
Prerequisites:
3232
* Ensure you have sudo privileges on your system.
33-
* Check that you have a supported PHP version installed (PHP version >= 7.2 and tested up to 8.4).
33+
* Check that you have a supported PHP version installed (PHP version >= 7.2 and tested up to 8.5).
3434
* Make sure to use the appropriate commands for your system or cloud provider.
3535

3636
### Manual install
@@ -88,7 +88,7 @@ You can run on Debian 10, by doing this setup before install: [Debian10 setup](.
8888
## Supported libraries and frameworks
8989

9090
### PHP versions
91-
Zen for PHP supports the following PHP versions: 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4.
91+
Zen for PHP supports the following PHP versions: 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5.
9292

9393
### Web frameworks
9494

lib/php-extension/Action.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Action action;
55
ACTION_STATUS Action::executeThrow(json &event) {
66
int _code = event["code"].get<int>();
77
std::string _message = event["message"].get<std::string>();
8-
zend_throw_exception(zend_exception_get_default(), _message.c_str(), _code);
8+
zend_throw_exception(GetFirewallDefaultExceptionCe(), _message.c_str(), _code);
99
CallPhpFunctionWithOneParam("http_response_code", _code);
1010
return BLOCK;
1111
}

lib/php-extension/HandleQueries.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@ AIKIDO_HANDLER_FUNCTION(handle_pre_pdostatement_execute) {
6969
eventCache.moduleName = "PDOStatement";
7070
eventCache.sqlQuery = PHP_GET_CHAR_PTR(stmt->query_string);
7171

72-
zval *pdo_object = &stmt->database_object_handle;
73-
eventCache.sqlDialect = GetSqlDialectFromPdo(pdo_object);
72+
#if PHP_VERSION_ID >= 80500
73+
if (!stmt->database_object_handle) {
74+
eventCache.sqlDialect = "unknown";
75+
return;
76+
}
77+
eventCache.sqlDialect = GetSqlDialectFromPdo(stmt->database_object_handle);
78+
#else
79+
eventCache.sqlDialect = GetSqlDialectFromPdo(&stmt->database_object_handle);
80+
#endif
7481
}
7582

7683
zend_class_entry* helper_load_mysqli_link_class_entry() {

lib/php-extension/Utils.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ std::string GetSqlDialectFromPdo(zval *pdo_object) {
111111
return "unknown";
112112
}
113113

114+
#if PHP_VERSION_ID >= 80500
115+
std::string GetSqlDialectFromPdo(zend_object *pdo_object) {
116+
if (!pdo_object) {
117+
return "unknown";
118+
}
119+
120+
zval pdo_object_zval;
121+
ZVAL_OBJ(&pdo_object_zval, pdo_object);
122+
return GetSqlDialectFromPdo(&pdo_object_zval);
123+
}
124+
#endif
125+
114126
bool StartsWith(const std::string& str, const std::string& prefix, bool caseSensitive) {
115127
std::string strToCompare = str;
116128
std::string prefixToCompare = prefix;
@@ -207,3 +219,13 @@ std::string GetStackTrace() {
207219
return "";
208220
#endif
209221
}
222+
223+
zend_class_entry* GetFirewallDefaultExceptionCe() {
224+
#if PHP_VERSION_ID >= 80500
225+
// PHP 8.5+: zend_exception_get_default() removed
226+
return zend_ce_exception;
227+
#else
228+
// PHP < 8.5
229+
return zend_exception_get_default();
230+
#endif
231+
}

0 commit comments

Comments
 (0)