-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug report: JSON DIFF does not work as expected #692
Comments
You're absolutely right, I'll take a look at it now. You will also need to use the Merge operation to end the fork, otherwise you'll be trying to diff each JSON blob separately within a fork. In the meantime, you can use the Head operation with a value of -2 to strip off the final two newlines: https://gchq.github.io/CyberChef/#recipe=Fork('%5C%5Cn%5C%5Cn','%5C%5Cn%5C%5Cn',false)JSON_Beautify('%20%20%20%20',true)Merge()Head('Nothing%20(separate%20chars)',-2)Diff('%5C%5Cn%5C%5Cn','JSON',true,true,false)&input=eyJmb28iOiBbImJhciJdfQoKewogICAgImZvbyI6IFsKICAgICAgICAidmFyIgogICAgXSwKICAgICJiYXoiOiBbdHJ1ZV0KfQ |
I've pushed a fix for this in v9.7.17 |
Thanks! I was looking for something like the Thank you for the great tool 👍 |
I will consider modifying the description for the Head and Tail operations so they get returned in more searches. |
Describe the bug
Just trying to use CyberChef to do a useful JSON DIFF
Since the default JSON option of the
Diff
recipe is only useful when both JSON are beautified (exemple of what I mean by "not useful when not beautified": https://gchq.github.io/CyberChef/#recipe=Fork('%5C%5Cn%5C%5Cn','%5C%5Cn%5C%5Cn',false/disabled)JSON_Beautify('%20%20%20%20',true/disabled)Diff('%5C%5Cn%5C%5Cn','JSON',true,true,false)&input=eyJmb28iOiBbImJhciJdfQoKewogICAgImZvbyI6IFsKICAgICAgICAidmFyIgogICAgXSwKICAgICJiYXoiOiBbdHJ1ZV0KfQ )I tried to beautify both compared JSON using the
JSON Beautify
recipe (through aFork
recipe to be able to beautify 2 valid JSON in 1 input), but it looks like theMerge delimiter
is also put to the end of the output (which becomes the new input for the next recipe), so it makes theDiff
recipe fails (because there are now 2 delimiters instead of 1).To Reproduce
https://gchq.github.io/CyberChef/#recipe=Fork('%5C%5Cn%5C%5Cn','%5C%5Cn%5C%5Cn',false)JSON_Beautify('%20%20%20%20',true)Diff('%5C%5Cn%5C%5Cn','JSON',true,true,false)&input=eyJmb28iOiBbImJhciJdfQoKewogICAgImZvbyI6IFsKICAgICAgICAidmFyIgogICAgXSwKICAgICJiYXoiOiBbdHJ1ZV0KfQ
Expected behaviour
The
Merge delimiter
of theFork
recipe should not be added to the end of the output.It should only be placed at the same place the
Split delimiter
was found in the first place.Screenshots

JSON Beautify is applied to both JSON:
DIFF fails (probably) because it compares the 2nd JSON with nothing (because the ouput of JSON Beautify seems to contain

\n\n
at the end):Desktop (if relevant, please complete the following information):
Tell me if you need help to fix this issue, I could try to look into CyberChef sources and submit a PR.
The text was updated successfully, but these errors were encountered: