You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 Security concerns
Input validation weakening: The change from BS16.decode to BS16.decodeLenient removes strict validation of hex input. While BS16.decode would fail on invalid hex characters, decodeLenient silently ignores them. This could potentially allow malformed input to pass through undetected, which might be exploitable depending on how the decoded data is used downstream.
The migration from fst . BS16.decode to BS16.decodeLenient changes error handling behavior. The old version would fail on invalid hex input, while decodeLenient silently ignores invalid characters. This could mask input validation issues and lead to unexpected behavior with malformed hex strings.
toBinary (HexString bs) =B.decode .BSL.fromStrict .BS16.decodeLenient $ bs
--| Reads a 'BS.ByteString' as raw bytes and converts to hex representation. We-- cannot use the instance Binary of 'BS.ByteString' because it provides-- a leading length, which is not what we want when dealing with raw bytes.fromBytes::BS.ByteString->HexString
fromBytes = hexString .BS16.encode
--| Access to the raw bytes in a 'BS.ByteString' format.toBytes::HexString->BS.ByteString
toBytes (HexString bs) =BS16.decodeLenient bs
The decodeLenient function may silently ignore invalid hex characters, potentially leading to data corruption. Consider validating the hex string before decoding to ensure data integrity.
Why: The suggestion correctly points out that decodeLenient can silently ignore invalid characters, which could lead to data corruption. The proposed change to use the strict BS16.decode with explicit error handling is a significant improvement in robustness and safety over the PR's implementation.
Medium
Replace lenient with strict decoding
Using decodeLenient here may silently accept malformed hex data, which could cause unexpected behavior. Consider using strict decoding with proper error handling.
-toBytes (HexString bs) = BS16.decodeLenient bs+toBytes (HexString bs) = case BS16.decode bs of+ Right decoded -> decoded+ Left err -> error $ "Invalid hex string: " ++ err
Apply / Chat
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies that using decodeLenient can hide malformed data issues. Switching to the strict BS16.decode and explicitly handling potential errors is a much safer approach, preventing unexpected behavior from invalid hex strings. This is a valuable improvement for data integrity.
I am a bit puzzled as to why there is a LLM bot that edits my own messages...
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
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.
User description
Opening this PR for the sole purpose of hosting the patch (that has already been submitted by @infinisil in an issue).
Fixes #3