Skip to content

Commit 010a9e8

Browse files
authored
Merge pull request #623 from AikidoSec/realtime-e2e
Set AIKIDO_REALTIME_ENDPOINT for end2end tests
2 parents 266dfdd + 9dbb422 commit 010a9e8

8 files changed

+31
-0
lines changed

end2end/server/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const checkToken = require("./src/middleware/checkToken");
88
const updateConfig = require("./src/handlers/updateConfig");
99
const lists = require("./src/handlers/lists");
1010
const updateLists = require("./src/handlers/updateLists");
11+
const realtimeConfig = require("./src/handlers/realtimeConfig");
1112

1213
const app = express();
1314

@@ -18,6 +19,9 @@ app.use(express.json());
1819
app.get("/api/runtime/config", checkToken, config);
1920
app.post("/api/runtime/config", checkToken, updateConfig);
2021

22+
// Realtime polling endpoint
23+
app.get("/config", checkToken, realtimeConfig);
24+
2125
app.get("/api/runtime/events", checkToken, listEvents);
2226
app.post("/api/runtime/events", checkToken, captureEvent);
2327

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { getAppConfig } = require("../zen/config");
2+
3+
module.exports = function realtimeConfig(req, res) {
4+
if (!req.app) {
5+
throw new Error("App is missing");
6+
}
7+
8+
const config = getAppConfig(req.app);
9+
10+
res.json({
11+
serviceId: req.app.serviceId,
12+
configUpdatedAt: config.configUpdatedAt,
13+
});
14+
};

end2end/tests/express-mongodb.ssrf.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ t.test("it blocks in blocking mode", (t) => {
5858
AIKIDO_BLOCKING: "true",
5959
AIKIDO_TOKEN: token,
6060
AIKIDO_ENDPOINT: testServerUrl,
61+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
6162
},
6263
});
6364

@@ -156,6 +157,7 @@ t.test("it does not block in dry mode", (t) => {
156157
AIKIDO_DEBUG: "true",
157158
AIKIDO_TOKEN: token,
158159
AIKIDO_ENDPOINT: testServerUrl,
160+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
159161
},
160162
});
161163

@@ -214,6 +216,7 @@ t.test("it blocks request to base URL if proxy is not trusted", (t) => {
214216
AIKIDO_BLOCKING: "true",
215217
AIKIDO_TOKEN: token,
216218
AIKIDO_ENDPOINT: testServerUrl,
219+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
217220
AIKIDO_TRUST_PROXY: "false",
218221
},
219222
});

end2end/tests/hono-xml-allowlists.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ t.test("it blocks non-allowed IP addresses", (t) => {
7878
AIKIDO_BLOCK: "true",
7979
AIKIDO_TOKEN: token,
8080
AIKIDO_ENDPOINT: testServerUrl,
81+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
8182
},
8283
});
8384

end2end/tests/hono-xml-blocklists.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ t.test("it blocks geo restricted IPs", (t) => {
5959
AIKIDO_BLOCKING: "true",
6060
AIKIDO_TOKEN: token,
6161
AIKIDO_ENDPOINT: testServerUrl,
62+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
6263
},
6364
});
6465

@@ -159,6 +160,7 @@ t.test("it blocks bots", (t) => {
159160
AIKIDO_BLOCKING: "true",
160161
AIKIDO_TOKEN: token,
161162
AIKIDO_ENDPOINT: testServerUrl,
163+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
162164
},
163165
});
164166

@@ -253,6 +255,7 @@ t.test("it does not block bypass IP if in blocklist", (t) => {
253255
AIKIDO_BLOCKING: "true",
254256
AIKIDO_TOKEN: token,
255257
AIKIDO_ENDPOINT: testServerUrl,
258+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
256259
},
257260
});
258261

end2end/tests/hono-xml-monitored-lists.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ t.test("it does not block monitored IPs", (t) => {
4343
AIKIDO_BLOCKING: "true",
4444
AIKIDO_TOKEN: token,
4545
AIKIDO_ENDPOINT: testServerUrl,
46+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
4647
},
4748
});
4849

@@ -109,6 +110,7 @@ t.test("it does not block monitored user agents", (t) => {
109110
AIKIDO_BLOCKING: "true",
110111
AIKIDO_TOKEN: token,
111112
AIKIDO_ENDPOINT: testServerUrl,
113+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
112114
},
113115
});
114116

end2end/tests/hono-xml-rate-limiting.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ t.test("it rate limits requests", (t) => {
5050
AIKIDO_BLOCKING: "true",
5151
AIKIDO_TOKEN: token,
5252
AIKIDO_ENDPOINT: testServerUrl,
53+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
5354
},
5455
});
5556

@@ -110,6 +111,7 @@ t.test("user rate limiting works", (t) => {
110111
AIKIDO_BLOCKING: "true",
111112
AIKIDO_TOKEN: token,
112113
AIKIDO_ENDPOINT: testServerUrl,
114+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
113115
},
114116
});
115117

end2end/tests/nestjs-fastify-rate-limiting.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ t.test("it rate limits requests", (t) => {
6161
AIKIDO_BLOCKING: "true",
6262
AIKIDO_TOKEN: token,
6363
AIKIDO_ENDPOINT: testServerUrl,
64+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
6465
PORT: "4002",
6566
},
6667
});
@@ -123,6 +124,7 @@ t.test("user rate limiting works", (t) => {
123124
AIKIDO_BLOCKING: "true",
124125
AIKIDO_TOKEN: token,
125126
AIKIDO_ENDPOINT: testServerUrl,
127+
AIKIDO_REALTIME_ENDPOINT: testServerUrl,
126128
PORT: "4003",
127129
},
128130
});

0 commit comments

Comments
 (0)