gchq / gchq/CyberChef-server

Bug report: ArrayBuffer return data always empty

Open
#60 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
179
Forks
66
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
No data is ever returned when executing recipes where operations return ArrayBuffer type. The affected examples are recipes containing the following modules (non-exhaustive list - this is what I've checked):

* Encode text
* Generate QR Code
* Generate Image

**To Reproduce**
To reproduce this issue, execute any of the following:

* ```curl -X POST -H "Content-Type:application/json" -d '{"input":"Test", "recipe":[{"op":"Encode text","args":["UTF-32BE (12001)"]}]}' localhost:3000/bake```
* ```curl -X POST -H "Content-Type:application/json" -d '{"input":"Test", "recipe":[{"op":"Generate Image","args":["Greyscale",8,64]}]}' localhost:3000/bake```
* ```curl -X POST -H "Content-Type:application/json" -d '{"input":"Test", "recipe":[{"op":"Generate QR Code","args":["PNG",5,4,"Medium"]}]}' localhost:3000/bake```

From these tests, it could be concluded that any op that, by default, returns ArrayBuffer type could be affected.

**Expected behavior**
The expected behavior is receiving a result JSON, which returns the correct result.

The observed behavior is, in all these cases, receiving an empty result. The result looks like this:
```
{"value":{},"type":"ArrayBuffer"}
```
**Notes**

This happens **even if the output type is explicitly stated**, like so:
```curl -X POST -H "Content-Type:application/json" -d '{"input":"Test", "recipe":[{"op":"Encode text","args":["UTF-32BE (12001)"]}],"outputType":"ArrayBuffer"}' localhost:3000/bake```

However, the correct result is returned if another output type is selected, like so:
```curl -X POST -H "Content-Type:application/json" -d '{"input":"Test", "recipe":[{"op":"Encode text","args":["UTF-32BE (12001)"]}],"outputType":"string"}' localhost:3000/bake```

In this case, this is the returned result: ```{"value":"\u0000\u0000\u0000T\u0000\u0000\u0000e\u0000\u0000\u0000s\u0000\u0000\u0000t","type":"string"}```

**Node version:**
v18.12.1

Contributor guide

Open the contributing guide

Research direction

Start at the /bake endpoint and trace how ArrayBuffer results are converted into the response JSON. Run the provided curl reproductions, including the explicit outputType case, and compare them with the string-output case. Done means ArrayBuffer responses contain the correct result instead of {"value":{},"type":"ArrayBuffer"}.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Bug
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.