Jq: Fix linting and add tests

This commit is contained in:
Roman Karwacik 2026-03-20 09:52:05 +01:00
parent b1369c97f0
commit 02e9af5678
No known key found for this signature in database
2 changed files with 33 additions and 1 deletions

View File

@ -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);

View File

@ -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],
},
],
},
]);