feat(thrift): add Thrift serialization and deserialization operations#2481
Open
engin0223 wants to merge 19 commits into
Open
feat(thrift): add Thrift serialization and deserialization operations#2481engin0223 wants to merge 19 commits into
engin0223 wants to merge 19 commits into
Conversation
GCHQDeveloper581
requested changes
Jun 5, 2026
GCHQDeveloper581
left a comment
Contributor
There was a problem hiding this comment.
Could you add a single, "sunny day" test for each operation to tests/browser/02_ops.js please.
- Moved binary and compact protocol parsing logic from ThriftDeserialize and ThriftSerialize classes to utility functions in Thrift.mjs. - Updated ThriftDeserialize to use new parseBinaryProtocol and parseCompactProtocol functions. - Simplified ThriftSerialize by utilizing buildBinaryStruct and writeValue functions for serialization. - Added comprehensive tests for Thrift serialization and deserialization, covering various data types and structures. - Ensured proper handling of edge cases in readVarint and fromZigZag functions.
- Moved binary and compact protocol parsing logic from ThriftDeserialize and ThriftSerialize classes to utility functions in Thrift.mjs. - Updated ThriftDeserialize to use new parseBinaryProtocol and parseCompactProtocol functions. - Simplified ThriftSerialize by utilizing buildBinaryStruct and writeValue functions for serialization. - Added comprehensive tests for Thrift serialization and deserialization, covering various data types and structures. - Ensured proper handling of edge cases in readVarint and fromZigZag functions.
…ation to prevent element was not found error
GCHQDeveloper581
requested changes
Jun 5, 2026
GCHQDeveloper581
requested changes
Jun 6, 2026
GCHQDeveloper581
requested changes
Jun 7, 2026
Contributor
There was a problem hiding this comment.
Operations tests were not previously connected. I've connected these and some tests now fail.
In manual testing I found a LIST could not be round-tripped correctly (it looks like the inner object (elementType/elements) is omitted when deserializing and instead the list elements presented as the value). I've added a (currently failing) test for this case.
SET and MAP also fail in a similar fashion (but I haven't provided test cases for these)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces two new operations to CyberChef: Thrift Deserialize and Thrift Serialize.
Similar to the existing Protobuf implementation, these operations work in a schema-less mode, inferring fields and data types directly from the wire encoding.
Key additions:
TBinaryProtocol,TCompactProtocol, andTJSONProtocol.Existing Issue
Closes #2374
AI disclosure
I used Gemini 3.1 Pro to assist with the code. I have thoroughly reviewed, tested, and verified all the code submitted and fully understand its implementation.
Test Coverage
Added structured automated unit tests under CyberChef's test framework using
TestRegister.addTests(). The test suite handles 4-space indented JSON formatting verification and explicitly covers:I32,BINARY,BOOL).List of I32) validating element type sizes (0x08) and lengths inside the wire stream.0x00).-1337) are properly transformed via ZigZag calculations to match wire-level expectations (f1 14).