Skip to content

Commit adea8d6

Browse files
Merge pull request #190 from AikidoSec/inject-middleware-into-ast
Auto inject middleware into AST (abstract syntax tree) before the PHP files are compiled
2 parents 125bdeb + 7bd561b commit adea8d6

File tree

50 files changed

+386
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+386
-180
lines changed

.vscode/c_cpp_properties.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"/usr/include/php",
8+
"/usr/include/php/main",
9+
"/usr/include/php/Zend",
10+
"/usr/include/php/TSRM",
11+
"/usr/include/php/ext"
12+
],
13+
"defines": [],
14+
"compilerPath": "/usr/bin/gcc",
15+
"cStandard": "c11",
16+
"cppStandard": "c++17",
17+
"intelliSenseMode": "linux-gcc-x64"
18+
}
19+
],
20+
"version": 4
21+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Prerequisites:
3838

3939
##### x86_64
4040
```
41-
rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.0.118/aikido-php-firewall.x86_64.rpm
41+
rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.0.119/aikido-php-firewall.x86_64.rpm
4242
```
4343

4444
##### arm64 / aarch64
@@ -50,7 +50,7 @@ rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/downloa
5050

5151
##### x86_64
5252
```
53-
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.118/aikido-php-firewall.x86_64.deb
53+
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.119/aikido-php-firewall.x86_64.deb
5454
dpkg -i -E ./aikido-php-firewall.x86_64.deb
5555
```
5656

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.118/aikido-php-firewall.x86_64.rpm"
7+
command: "rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.0.119/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
@@ -32,7 +32,7 @@ Create a script to install the Aikido PHP Firewall during deployment:
3232
#!/usr/bin/env bash
3333
cd /tmp
3434

35-
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.118/aikido-php-firewall.x86_64.deb
35+
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.0.119/aikido-php-firewall.x86_64.deb
3636
dpkg -i -E ./aikido-php-firewall.x86_64.deb
3737
```
3838

docs/laravel-forge.md

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

docs/should_block_request.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ class AikidoMiddleware implements MiddlewareInterface
5555
if ($decision->trigger == "user") {
5656
$message = "Your user is blocked!";
5757
}
58-
else if ($decision->trigger == "ip") {
59-
$message = "Your IP ({$decision->ip}) is blocked due to: {$decision->description}!";
60-
}
61-
else if ($decision->trigger == "user-agent") {
62-
$message = "Your user agent ({$decision->user_agent}) is blocked due to: {$decision->description}!";
63-
}
6458

6559
return new Response([
6660
'message' => $message,
@@ -118,14 +112,14 @@ class ZenBlockDecision
118112
return $next($request);
119113
}
120114

121-
// Get the authenticated user's ID from Laravel's Auth system
122-
$userId = Auth::id();
115+
// Get the authenticated user's ID from Laravel's Auth system
116+
$userId = Auth::id();
123117

124-
// If a user is authenticated, set the user in Aikido's firewall context
125-
if ($userId) {
126-
// If username is available, you can set it as the second parameter in the \aikido\set_user function call
127-
\aikido\set_user($userId);
128-
}
118+
// If a user is authenticated, set the user in Aikido's firewall context
119+
if ($userId) {
120+
// If username is available, you can set it as the second parameter in the \aikido\set_user function call
121+
\aikido\set_user($userId);
122+
}
129123

130124
// Check blocking decision from Aikido
131125
$decision = \aikido\should_block_request();
@@ -135,9 +129,6 @@ class ZenBlockDecision
135129
if ($decision->trigger == "user") {
136130
return response('Your user is blocked!', 403);
137131
}
138-
else if ($decision->trigger == "ip") {
139-
return response("Your IP ({$decision->ip}) is blocked due to: {$decision->description}!", 403);
140-
}
141132
}
142133
else if ($decision->type == "ratelimited") {
143134
if ($decision->trigger == "user") {

lib/API.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ enum EVENT_ID {
66
EVENT_PRE_REQUEST,
77
EVENT_POST_REQUEST,
88
EVENT_SET_USER,
9+
EVENT_GET_AUTO_BLOCKING_STATUS,
910
EVENT_GET_BLOCKING_STATUS,
1011
EVENT_PRE_OUTGOING_REQUEST,
1112
EVENT_POST_OUTGOING_REQUEST,

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.118"
4+
Version = "1.0.119"
55
ConfigUpdatedAtMethod = "GET"
66
ConfigUpdatedAtAPI = "/config"
77
ConfigAPIMethod = "GET"

lib/agent/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.23.3
66

77
require (
88
github.com/stretchr/testify v1.9.0
9-
google.golang.org/grpc v1.72.1
9+
google.golang.org/grpc v1.72.2
1010
google.golang.org/protobuf v1.36.5
1111
)
1212

lib/agent/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
3434
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
3535
google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI=
3636
google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
37+
google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
38+
google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
3739
google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA=
3840
google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
41+
google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8=
42+
google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
3943
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
4044
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
4145
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=

0 commit comments

Comments
 (0)