From 4a925f1cee2a80515abda68f10fe4ba5d9549c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6ssler?= Date: Mon, 30 Sep 2024 17:13:21 +0200 Subject: [PATCH] Fix getOrignalRequire --- benchmarks/api-discovery/package-lock.json | 12 +++++++++++- benchmarks/shell-injection/package-lock.json | 12 +++++++++++- benchmarks/sql-injection/package-lock.json | 12 +++++++++++- library/agent/hooks/wrapRequire.ts | 2 +- sample-apps/http2/package-lock.json | 12 +++++++++++- 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/benchmarks/api-discovery/package-lock.json b/benchmarks/api-discovery/package-lock.json index 812fc9f30..941f8c4f6 100644 --- a/benchmarks/api-discovery/package-lock.json +++ b/benchmarks/api-discovery/package-lock.json @@ -11,7 +11,17 @@ "@aikidosec/firewall": "file:../../build" } }, - "../../build": {}, + "../../build": { + "name": "@aikidosec/firewall", + "version": "0.0.0", + "license": "AGPL-3.0-or-later", + "dependencies": { + "import-in-the-middle": "^1.11.1" + }, + "engines": { + "node": ">=16" + } + }, "../../library": { "name": "@aikidosec/firewall", "version": "0.0.0", diff --git a/benchmarks/shell-injection/package-lock.json b/benchmarks/shell-injection/package-lock.json index 68af5171f..befa1fc23 100644 --- a/benchmarks/shell-injection/package-lock.json +++ b/benchmarks/shell-injection/package-lock.json @@ -11,7 +11,17 @@ "@aikidosec/firewall": "file:../../build" } }, - "../../build": {}, + "../../build": { + "name": "@aikidosec/firewall", + "version": "0.0.0", + "license": "AGPL-3.0-or-later", + "dependencies": { + "import-in-the-middle": "^1.11.1" + }, + "engines": { + "node": ">=16" + } + }, "../../library": { "name": "@aikidosec/firewall", "version": "0.0.0", diff --git a/benchmarks/sql-injection/package-lock.json b/benchmarks/sql-injection/package-lock.json index bed6283cb..94f46c418 100644 --- a/benchmarks/sql-injection/package-lock.json +++ b/benchmarks/sql-injection/package-lock.json @@ -11,7 +11,17 @@ "@aikidosec/firewall": "file:../../build" } }, - "../../build": {}, + "../../build": { + "name": "@aikidosec/firewall", + "version": "0.0.0", + "license": "AGPL-3.0-or-later", + "dependencies": { + "import-in-the-middle": "^1.11.1" + }, + "engines": { + "node": ">=16" + } + }, "../../library": { "name": "@aikidosec/firewall", "version": "0.0.0", diff --git a/library/agent/hooks/wrapRequire.ts b/library/agent/hooks/wrapRequire.ts index e8cdcbf29..f4de251c4 100644 --- a/library/agent/hooks/wrapRequire.ts +++ b/library/agent/hooks/wrapRequire.ts @@ -261,5 +261,5 @@ function patchPackage(this: mod, id: string, originalExports: unknown) { * Returns the unwrapped require function. */ export function getOrignalRequire() { - return originalRequire; + return originalRequire || mod.prototype.require; } diff --git a/sample-apps/http2/package-lock.json b/sample-apps/http2/package-lock.json index bce770215..4dfbfb2f9 100644 --- a/sample-apps/http2/package-lock.json +++ b/sample-apps/http2/package-lock.json @@ -9,7 +9,17 @@ "@aikidosec/firewall": "file:../../build" } }, - "../../build": {}, + "../../build": { + "name": "@aikidosec/firewall", + "version": "0.0.0", + "license": "AGPL-3.0-or-later", + "dependencies": { + "import-in-the-middle": "^1.11.1" + }, + "engines": { + "node": ">=16" + } + }, "../../library": { "name": "@aikidosec/firewall", "version": "0.0.0",