-
Notifications
You must be signed in to change notification settings - Fork 115
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
FNS - bounds check raw subscription payload int vals #2523
Conversation
WalkthroughThe changes in this pull request focus on enhancing error handling in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
protocol/streaming/ws/websocket_server.go (2)
126-129
: LGTM: Bounds check for subaccount number.The added validation check ensures that the subaccount number is within the valid range (0 to MaxInt32), which aligns with the PR objective. The error message is clear and informative.
Consider using a constant for the maximum value to improve maintainability:
+const MaxSubaccountNumber = math.MaxInt32 -if number < 0 || number > math.MaxInt32 { +if number < 0 || number > MaxSubaccountNumber { return nil, fmt.Errorf("invalid subaccount number: %s", parts[1]) }
152-154
: LGTM: Bounds check for clob pair ID.The added validation check ensures that the clob pair ID is within the valid range (0 to MaxInt32), which aligns with the PR objective. The error message is clear and informative.
For consistency with the
parseSubaccountIds
function, consider using a constant for the maximum value:+const MaxClobPairId = math.MaxInt32 -if id < 0 || id > math.MaxInt32 { +if id < 0 || id > MaxClobPairId { return nil, fmt.Errorf("invalid clob pair id: %s", idStr) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- protocol/streaming/ws/websocket_server.go (3 hunks)
🧰 Additional context used
🔇 Additional comments (2)
protocol/streaming/ws/websocket_server.go (2)
6-6
: LGTM: Import ofmath
package.The addition of the
math
package import is necessary and correctly placed for the new validation checks usingmath.MaxInt32
.
Line range hint
1-193
: Overall assessment: Changes meet PR objectives and improve code robustness.The implemented bounds checks for subaccount numbers and clob pair IDs align with the PR objectives. These changes enhance the error handling and prevent potential issues with invalid input. The implementation is consistent across both parsing functions.
Consider the suggested minor improvements for using constants to define the maximum values, which would enhance maintainability and consistency.
Great job on improving the input validation!
must be
>= 0
and<= math.MaxInt32
Summary by CodeRabbit
New Features
Bug Fixes