From 02e9af5678f5120cb37b076f3f5d723820455748 Mon Sep 17 00:00:00 2001 From: Roman Karwacik Date: Fri, 20 Mar 2026 09:52:05 +0100 Subject: [PATCH] Jq: Fix linting and add tests --- src/core/operations/Jq.mjs | 2 +- tests/operations/tests/Jq.mjs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/operations/tests/Jq.mjs diff --git a/src/core/operations/Jq.mjs b/src/core/operations/Jq.mjs index 63271805..bc502957 100644 --- a/src/core/operations/Jq.mjs +++ b/src/core/operations/Jq.mjs @@ -53,7 +53,7 @@ class Jq extends Operation { } catch (err) { throw new OperationError(`Invalid jq expression: ${err.message}`); } - if (raw && typeof result === 'string') { + if (raw && typeof result === "string") { return result; } else { return JSON.stringify(result); diff --git a/tests/operations/tests/Jq.mjs b/tests/operations/tests/Jq.mjs new file mode 100644 index 00000000..a2435450 --- /dev/null +++ b/tests/operations/tests/Jq.mjs @@ -0,0 +1,32 @@ +/** + * Jq tests. + * + * @author rtpt-romankarwacik [roman.karwacik@redteam-pentesting.de] + * + */ +import TestRegister from "../../lib/TestRegister.mjs"; + +TestRegister.addTests([ + { + name: "Get raw JSON Property", + input: '{"data": "testString\\u0000"}', + expectedOutput: "testString\u0000", + recipeConfig: [ + { + op: "Jq", + args: [".data", true], + }, + ], + }, + { + name: "Get JSON Property", + input: '{"data": "testString\\u0000"}', + expectedOutput: "\"testString\\u0000\"", + recipeConfig: [ + { + op: "Jq", + args: [".data", false], + }, + ], + }, +]);