Skip to content

Commit 3bc4b55

Browse files
Merge pull request #159 from AikidoSec/fix-apache-wordpress-crashes
Fix Apache + Wordpress crashes happening on turnkeylinux by reloading the _SERVER var
2 parents 0ca97a1 + 50372af commit 3bc4b55

File tree

18 files changed

+55
-39
lines changed

18 files changed

+55
-39
lines changed

.devcontainer/centos/devcontainer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@
88
"platform": "linux/arm64",
99
"dockerfile": "Dockerfile",
1010
"args": {
11-
"PHP_VERSION": "8.1"
11+
"PHP_VERSION": "8.2"
1212
}
1313
},
1414
"customizations": {
1515
"vscode": {
1616
"extensions": [
1717
"golang.go",
18-
"github.vscode-github-actions"
18+
"github.vscode-github-actions",
19+
"ms-vscode.cpptools-extension-pack",
20+
"ms-vscode.cpptools",
21+
"ms-vscode.cpptools-themes",
22+
"austin.code-gnu-global",
23+
"ms-vscode.makefile-tools"
1924
]
2025
}
2126
}

.devcontainer/ubuntu/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"platform": "linux/amd64",
99
"dockerfile": "Dockerfile",
1010
"args": {
11-
"PHP_VERSION": "8.1"
11+
"PHP_VERSION": "8.2"
1212
}
1313
}
1414
}

.github/workflows/build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,13 @@ jobs:
296296
- name: Build deb
297297
run: |
298298
sudo alien --to-deb --scripts --keep-version ${{ env.AIKIDO_RPM }}/${{ env.AIKIDO_RPM }}
299-
ls -R
300-
mv aikido-php-firewall_${{ env.AIKIDO_VERSION }}-1_${{ env.DEB_ARCH }}.deb ${{ env.AIKIDO_ARTIFACT }}
299+
mv aikido-php-firewall_${{ env.AIKIDO_VERSION }}-1_${{ env.DEB_ARCH }}.deb temp-${{ env.AIKIDO_ARTIFACT }}
300+
301+
# Package contents into deb with gzip compression (because default zstd compression is not supported by older versions of dpkg)
302+
mkdir deb-temp
303+
dpkg-deb -R temp-${{ env.AIKIDO_ARTIFACT }} deb-temp/
304+
dpkg-deb -Zgzip -b deb-temp ${{ env.AIKIDO_ARTIFACT }}
305+
rm -rf deb-temp
301306
302307
- name: Archive deb package
303308
uses: actions/upload-artifact@v4

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ Prerequisites:
3737
#### For Red Hat-based Systems (RHEL, CentOS, Fedora)
3838

3939
```
40-
rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.0.110/aikido-php-firewall.x86_64.rpm
40+
rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.0.111/aikido-php-firewall.x86_64.rpm
4141
```
4242

4343
#### For Debian-based Systems (Debian, Ubuntu)
4444

4545
```
46-
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.110/aikido-php-firewall.x86_64.deb
46+
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.111/aikido-php-firewall.x86_64.deb
4747
dpkg -i -E ./aikido-php-firewall.x86_64.deb
4848
```
4949

docs/aws-elastic-beanstalk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
```
55
commands:
66
aikido-php-firewall:
7-
command: "rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.0.110/aikido-php-firewall.x86_64.rpm"
7+
command: "rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.0.111/aikido-php-firewall.x86_64.rpm"
88
ignoreErrors: true
99
1010
files:

docs/fly-io.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can find their values in the Aikido platform.
1515
#!/usr/bin/env bash
1616
cd /tmp
1717
18-
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.110/aikido-php-firewall.x86_64.deb
18+
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.111/aikido-php-firewall.x86_64.deb
1919
dpkg -i -E ./aikido-php-firewall.x86_64.deb
2020
```
2121

docs/laravel-forge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ cd /tmp
1919
2020
# Install commands from the "Manual install" section below, based on your OS
2121
22-
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.110/aikido-php-firewall.x86_64.deb
22+
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.111/aikido-php-firewall.x86_64.deb
2323
dpkg -i -E ./aikido-php-firewall.x86_64.deb
2424
2525
# Restarting the php services in order to load the Aikido PHP Firewall

lib/agent/globals/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package globals
22

33
const (
4-
Version = "1.0.110"
4+
Version = "1.0.111"
55
ConfigUpdatedAtMethod = "GET"
66
ConfigUpdatedAtAPI = "/config"
77
ConfigAPIMethod = "GET"

lib/php-extension/GoWrappers.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ GoSlice GoCreateSlice(const std::vector<int64_t>& v) {
1111
Callback wrapper called by the RequestProcessor (GO) whenever it needs data from PHP (C++ extension).
1212
*/
1313
char* GoContextCallback(int callbackId) {
14-
if (!request.Ok()) {
15-
AIKIDO_LOG_WARN("Request is not ok!\n");
16-
return nullptr;
17-
}
1814
std::string ctx;
1915
std::string ret;
2016

lib/php-extension/Request.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
Request request;
44

5-
bool Request::Init() {
5+
bool Request::LoadServerVar() {
6+
if (this->server != NULL) {
7+
return true;
8+
}
9+
610
zend_string* serverString = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
711
if (!serverString) {
812
AIKIDO_LOG_WARN("Error allocating the '_SERVER' zend string!");
@@ -27,12 +31,12 @@ bool Request::Init() {
2731
return true;
2832
}
2933

30-
bool Request::Ok() {
31-
return this->server != NULL;
34+
void Request::UnloadServerVar() {
35+
this->server = NULL;
3236
}
3337

3438
std::string Request::GetVar(const char* var) {
35-
if (!this->server) {
39+
if (!this->LoadServerVar()) {
3640
return "";
3741
}
3842
zval* data = zend_hash_str_find(Z_ARRVAL_P(this->server), var, strlen(var));
@@ -43,9 +47,6 @@ std::string Request::GetVar(const char* var) {
4347
}
4448

4549
std::string Request::GetRoute() {
46-
if (!this->server) {
47-
return "";
48-
}
4950
std::string route = GetVar("REQUEST_URI");
5051
size_t pos = route.find("?");
5152
if (pos != std::string::npos) {
@@ -122,7 +123,7 @@ std::string Request::GetQuery() {
122123
}
123124

124125
std::string Request::GetHeaders() {
125-
if (!this->server) {
126+
if (!this->LoadServerVar()) {
126127
return "";
127128
}
128129
std::map<std::string, std::string> headers;

0 commit comments

Comments
 (0)