gchq / gchq/CyberChef

Feature request: Embed within a JSON object (reverse JPath)

Open
#1,820 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
JavaScript
Stars
35.8k
Forks
4.1k
Avg merge
2d 26m
Merged PRs (30d)
33

Description

**Is your feature request related to a problem? Please describe.**
I have a pipeline which is
1. Extract a string from a JSON object with the `JPath` operation
2. Decode the string as Base64
3. Inflate the binary data with ZLIB inflate

This recipe can be found [here](https://cyberchef.io/#recipe=JPath_expression('data','%5C%5Cn')Find_/_Replace(%7B'option':'Regex','string':'%22'%7D,'',true,false,true,false)From_Base64('A-Za-z0-9%2B/%3D',true)Zlib_Inflate(0,0,'Adaptive',false,false)&input=eyJkYXRhIjoiZUp3RmdMRUpBQUFJdzQ3TEowTEZ1WnZmQjM1U0xpc1E1Z05zIn0)

But I'd like to do the reverse

1. Deflate a string with ZLIB deflate
2. Encode that binary data as Base64
3. Embed that string within a JSON object

That last step is not possible right now

**Describe the solution you'd like**
I would like a step which can take the previous step's output string, and embed it within a provided JSON object. For example, the step's input could be

`{"data": $1}`

and it would substitute the $1 for the step input

**Describe alternatives you've considered**

A workaround is to manually embed the string within the JSON parts `{"data":"` and `"}` via find and replace:

https://cyberchef.io/#recipe=Zlib_Deflate('Dynamic%20Huffman%20Coding')To_Base64('A-Za-z0-9%2B/%3D')Find_/_Replace(%7B'option':'Regex','string':'%5E'%7D,'%7B%22data%22:%22',true,false,false,false)Find_/_Replace(%7B'option':'Regex','string':'$'%7D,'%22%7D',true,false,true,false)&input=Q3liZXJDaGVm

**Additional context**

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing JPath operation and the Zlib Deflate and Base64 operations referenced in the issue to understand how operation inputs and outputs are represented. Add an operation that substitutes its input into a supplied JSON template such as {"data": $1}, then verify that the resulting JSON contains the encoded value and remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.