feat(Issue 121): Adding LZ4 Support.#142
Merged
S4tvara merged 4 commits intoS4tvara:mainfrom Oct 27, 2025
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
3e46acb to
72aa1f5
Compare
Adding lz4 dependency and adding to the options for compression. Adding lz4 logic in for decompression and compression. Unit tests still need to be written.
72aa1f5 to
c77d82d
Compare
Owner
|
Hi @cjtaylor1990 , |
Contributor
Author
Thanks! Apologies for my slow speed. I'll get this in soon though. |
Adding compression and decompression tests for Compressor.go. Tweaking logic so that decompression can't go over the limit. Before, it would go to limit +2.
Compressor_test.go was failing linting due to typos. Fixed.
Adding zstd case for decom bomb unit test. Uncommenting gzip decom bomb unit test, as that was left commented out by accident.
Owner
|
@cjtaylor1990 , |
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.
Summary
Adding in lz4 dependency and adding it to the options in the prompts.
For the lz4 case, I have added the compression and decompression logic.
Unit tests are to be added for compression and decompression,
as well as decompression bombs.
Updating gzip and lz4 to fail at the max decompression + 1
byte, rather than at max + 2. This was a small bug found while testing.
AI Assistance
Scope & Risk
Security/privacy reviewed where applicableHacktoberfest Notes
LZ4 is a fast compression algorithm that was not previously supported by Sietch. I used the suggested LZ4 library to compress and decompress chunks of data as they are being added to and fetched from Sietch vaults.
To check for decompression bombs, I originally decided to use the Size() method of the lz4 reader. However, it was not working as expected (returning 0 consistently), and as such, I decided to use the same pattern as gzip.
I have added unit tests, one set to check the compression/decompression in general, and then another for the decompression bomb case.
While testing, I did notice that the current implementation of using the extraByte len-1 array to detect decompression bombs in gzip and lz4 would actually result in detection at max size + 2 instead of the expected max size +1. As such, I've fixed that small bug while I was at it in both gzip and lz4.
Given many of the mocking methods in go are based upon dependency injection, I wasn't quite sure how I could cover our "unhappy path" cases in unit tests without further refactoring.
Checklist