Skip to content

Commit 022f723

Browse files
committed
Merge branch 'main' into windows-support
2 parents 804a461 + 9a17217 commit 022f723

File tree

230 files changed

+40735
-22618
lines changed

Some content is hidden

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

230 files changed

+40735
-22618
lines changed

.devcontainer/devcontainer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
{
3+
"name": "Zen Node.js",
4+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
5+
"image": "mcr.microsoft.com/devcontainers/typescript-node:22",
6+
7+
// Features to add to the dev container. More info: https://containers.dev/features.
8+
"features": {
9+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
10+
"ghcr.io/devcontainers/features/rust:1": {}
11+
},
12+
13+
// Configure tool-specific properties.
14+
"customizations": {
15+
// Configure properties specific to VS Code.
16+
"vscode": {
17+
"settings": {},
18+
"extensions": [
19+
"ms-azuretools.vscode-docker",
20+
"dbaeumer.vscode-eslint",
21+
"esbenp.prettier-vscode",
22+
"YoavBls.pretty-ts-errors",
23+
"rust-lang.rust-analyzer"
24+
]
25+
}
26+
},
27+
28+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
29+
"forwardPorts": [3000, 4000],
30+
31+
// Use 'portsAttributes' to set default properties for specific forwarded ports.
32+
// More info: https://containers.dev/implementors/json_reference/#port-attributes
33+
"portsAttributes": {},
34+
35+
// Use 'postCreateCommand' to run commands after the container is created.
36+
"postCreateCommand": "./.devcontainer/postCreateCommand.sh"
37+
38+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
39+
// "remoteUser": "root"
40+
}

.devcontainer/postCreateCommand.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Update
4+
sudo apt update -y && sudo apt upgrade -y
5+
rustup update
6+
source /usr/local/share/nvm/nvm.sh
7+
nvm install --lts
8+
nvm use --lts
9+
npm update -g
10+
11+
# Install WASM pack
12+
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
13+
14+
# Install k6
15+
## k6 installation -- arm machines
16+
if [ "$(uname -m)" = "aarch64" ]; then
17+
K6_TAR_LINK=https://github.com/grafana/k6/releases/download/v0.58.0/k6-v0.58.0-linux-arm64.tar.gz
18+
curl -OL $K6_TAR_LINK
19+
tar -xzf k6-v0.58.0-linux-arm64.tar.gz
20+
sudo mv k6-v0.58.0-linux-arm64/k6 /usr/local/bin/k6
21+
rm -rf k6-v0.58.0-linux-arm64*
22+
else ## k6 installation -- other architectures
23+
sudo gpg -k
24+
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
25+
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
26+
sudo apt-get update -y
27+
sudo apt-get install k6 -y
28+
fi
29+
30+
# Install wrk, sqlite3
31+
sudo apt install wrk sqlite3 -y
32+
33+
# Install npm packages, build and run containers
34+
npm i
35+
npm run build
36+
npm run containers

.github/workflows/benchmark.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
cache: "npm"
3535
cache-dependency-path: "**/package-lock.json"
3636
- name: Install K6
37-
uses: grafana/setup-k6-action@v1
37+
uses: grafana/setup-k6-action@ffe7d7290dfa715e48c2ccc924d068444c94bde2 # v1
3838
- name: Install wrk
3939
run: |
4040
sudo apt-get update
@@ -53,3 +53,5 @@ jobs:
5353
run: cd benchmarks/api-discovery && node benchmark.js
5454
- name: Run Express Benchmark
5555
run: cd benchmarks/express && node benchmark.js
56+
- name: Check Rate Limiter memory usage
57+
run: cd benchmarks/rate-limiting && node --expose-gc memory.js

.github/workflows/unit-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ jobs:
8181
- run: npm run build
8282
- run: npm run test:ci
8383
- name: "Upload coverage"
84-
uses: codecov/codecov-action@v4.0.1
84+
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5
8585
with:
86-
file: ./library/.tap/report/lcov.info
86+
files: ./library/.tap/report/lcov.info
8787
env:
8888
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8989
slug: AikidoSec/firewall-node

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Zen for Node.js 16+ is compatible with:
4646
*[Next.js](docs/next.md) 12.x, 13.x and 14.x
4747
*[Fastify](docs/fastify.md) 4.x and 5.x
4848
*[Koa](docs/koa.md) 2.x
49-
*[NestJS](docs/nestjs.md) 10.x
49+
*[NestJS](docs/nestjs.md) 10.x and 11.x
5050

5151
### Database drivers
5252

@@ -87,12 +87,12 @@ See list above for supported database drivers.
8787
### Data serialization tools
8888

8989
*[`xml2js`](https://www.npmjs.com/package/xml2js) 0.6.x, 0.5.x, ^0.4.18
90-
*[`fast-xml-parser`](https://www.npmjs.com/package/fast-xml-parser) 4.x
90+
*[`fast-xml-parser`](https://www.npmjs.com/package/fast-xml-parser) 5.x, 4.x
9191
*[`xml-js`](https://www.npmjs.com/package/xml-js) 1.x
9292

9393
### Shell tools
9494

95-
*[`ShellJS`](https://www.npmjs.com/package/shelljs) 0.8.x, 0.7.x
95+
*[`ShellJS`](https://www.npmjs.com/package/shelljs) 0.9.x, 0.8.x, 0.7.x
9696

9797
### Routers
9898

benchmarks/express/benchmark.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,38 @@ async function run() {
5757
// Stop the server
5858
withoutFirewallProc.kill();
5959

60+
const withOpenTelemetryProc = spawn("node", ["app.js"], {
61+
env: {
62+
...process.env,
63+
PORT: 5003,
64+
NODE_OPTIONS:
65+
"--require @opentelemetry/auto-instrumentations-node/register",
66+
OTEL_TRACES_EXPORTER: "none",
67+
OTEL_METRICS_EXPORTER: "none",
68+
OTEL_LOGS_EXPORTER: "none",
69+
},
70+
stdio: "inherit",
71+
});
72+
73+
// Wait 2 seconds for the server to start and settle
74+
await setTimeout(2000);
75+
76+
const resultWithOpenTelemetry = await exec(
77+
generateWrkCommandForUrl("http://localhost:5003/empty")
78+
);
79+
80+
// Stop the server
81+
withOpenTelemetryProc.unref();
82+
withOpenTelemetryProc.kill();
83+
6084
const withFirewall = parseFloat(resultWithFirewall.stdout.trim());
6185
const withoutFirewall = parseFloat(resultWithoutFirewall.stdout.trim());
86+
const withOpenTelemetry = parseFloat(resultWithOpenTelemetry.stdout.trim());
6287

6388
console.log("--- Results ---");
6489
console.log(`Without Zen: ${withoutFirewall} Requests/sec`);
6590
console.log(`With Zen: ${withFirewall} Requests/sec`);
91+
console.log(`With OpenTelemetry: ${withOpenTelemetry} Requests/sec`);
6692

6793
const increase = ((withoutFirewall - withFirewall) / withoutFirewall) * 100;
6894
console.log(`Decrease with Zen for an empty route: ${increase.toFixed(2)}%`);

0 commit comments

Comments
 (0)