Skip to content
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

Closed
Oliboy50 opened this issue Oct 18, 2019 · 4 comments
Closed

Bug report: JSON DIFF does not work as expected #692

Oliboy50 opened this issue Oct 18, 2019 · 4 comments
Labels

Comments

@Oliboy50
Copy link

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 a Fork recipe to be able to beautify 2 valid JSON in 1 input), but it looks like the Merge delimiter is also put to the end of the output (which becomes the new input for the next recipe), so it makes the Diff 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 the Fork 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:
Capture d’écran 2019-10-18 à 14 17 57

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):
Capture d’écran 2019-10-18 à 14 18 11

Desktop (if relevant, please complete the following information):

  • OS: Mac OS X Mojave
  • Browser: firefox 69
  • CyberChef version: 9.7.16

Tell me if you need help to fix this issue, I could try to look into CyberChef sources and submit a PR.

@Oliboy50 Oliboy50 added the bug label Oct 18, 2019
@n1474335
Copy link
Member

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

@n1474335
Copy link
Member

I've pushed a fix for this in v9.7.17

@Oliboy50
Copy link
Author

Thanks!

I was looking for something like the Head recipe, but I didn't manage to find it (was typing remove/end in the search bar) 🎉

Thank you for the great tool 👍

@n1474335
Copy link
Member

I will consider modifying the description for the Head and Tail operations so they get returned in more searches.
Thanks for the feedback, always good to hear!

d98762625 pushed a commit to d98762625/CyberChef that referenced this issue Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants