From 765d46dcc927a6aff27c1203fff4dfaff35ce0d9 Mon Sep 17 00:00:00 2001
From: mtyszczak <mateusz.tyszczak@gmail.com>
Date: Fri, 28 Mar 2025 10:43:50 +0100
Subject: [PATCH] Fix Unvalidated dynamic method call

---
 ts/wasm/__tests__/assets/api-mock.ts | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/ts/wasm/__tests__/assets/api-mock.ts b/ts/wasm/__tests__/assets/api-mock.ts
index f25ad365b..e0979b131 100644
--- a/ts/wasm/__tests__/assets/api-mock.ts
+++ b/ts/wasm/__tests__/assets/api-mock.ts
@@ -50,14 +50,17 @@ export class JsonRpcMock extends AProxyMockResolver {
     // here we assume that the request is valid
     const { method, params } = req.body;
 
-    const mockFn = this.mockData[method];
+    if (this.mockData.hasOwnProperty(method)) {
+      const mockFn = this.mockData[method];
+      if (typeof mockFn === 'function') {
+        const response = mockFn(params);
 
-    if (typeof mockFn !== "function")
-      throw new Error(`Method ${method} is not implemented`);
+        res.json(response);
+        return;
+      }
+    }
 
-    const response = mockFn(params);
-
-    res.json(response);
+    throw new Error(`Method ${method} is not implemented`);
   }
 }
 
-- 
GitLab