Fixing security bug

This commit is contained in:
Fabian Stamm 2022-05-21 17:55:14 +00:00
parent 94131c55a0
commit 71a6e3f2e0
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@hibas123/jrpcgen",
"version": "1.1.1",
"version": "1.1.2",
"main": "lib/index.js",
"license": "MIT",
"packageManager": "yarn@3.1.1",
@ -8,7 +8,7 @@
"start": "ts-node src/index.ts",
"test-start": "npm run start -- compile examples/example.jrpc --definition=examples/definition.json -o=ts-node:examples/Typescript/out -o=c#:examples/CSharp/Generated",
"test-csharp": "cd examples/CSharp/Example/ && dotnet run",
"test-typescript": "ts-node examples/test.ts",
"test-typescript": "cd examples/Typescript && ts-node test.ts",
"test": "npm run test-start && npm run test-csharp && npm run test-typescript",
"build": "esbuild src/index.ts --bundle --platform=node --target=node14 --outfile=lib/jrpc.js",
"prepublishOnly": "npm run build"

View File

@ -372,7 +372,9 @@ export class TypescriptTarget extends CompileTarget {
a(2, `if(Array.isArray(params)){`);
a(3, `p = params;`);
a(3, `while(p.length < ${fnc.inputs.length})`);
a(4, `p.push(undefined)`);
a(4, `p.push(undefined);`);
a(3, `if(p.length > ${fnc.inputs.length})`);
a(4, `throw new Error("Too many parameters!");`);
a(2, `} else {`);
for (const param of fnc.inputs) {
a(3, `p.push(params["${param.name}"])`);