Conversation
…correct documentation ## Description Remediates an unbounded HTTP response body allocation vulnerability (CWE-770/CWE-400), cleans up invalid package usage documentation, and documents gorilla/websocket close lifecycle behavior in `core-go`. ## Key Changes & Remediations * **Bounded Response Body Allocation (`http.go`)**: - Implemented `maxResponseBytes = 32 << 20` (32 MiB) cap in `makeCall()`. - Wrapped `res.Body` with `io.LimitReader(res.Body, maxResponseBytes+1)` to read with an extra byte budget. - Replaces unbounded `io.ReadAll()` allocations with an explicit over-limit error if the payload exceeds 32 MiB, preventing malicious or runaway upstream endpoints from crashing client processes via memory exhaustion. * **API Documentation Accuracy (`README.md`, `CHANGELOG.md`)**: - Replaced the invalid `core.NewClient()` snippet with accurate documentation detailing exported HTTP helper methods (`HttpGet`, `HttpPost`), `DialWebSocket`, and the `RestClient` interface. - Removed the broken/sunset Go Report Card badge. - Added release notes for v0.4.1 in `CHANGELOG.md`. * **WebSocket Close Handshake Documentation (`ws.go`, `ws_utils.go`)**: - Clarified that `gorilla/websocket` handles close frames internally and surfaces closures as `*CloseError` via `ReadMessage()`, guiding SDK consumers on proper shutdown handling. ## Verification - Verified compilation and static analysis with `go vet ./...`. - Validated all tests passing via `go test ./...`. - Verified that HTTP responses exceeding 32 MiB are rejected with the configured error.
🟡 Heimdall Review Status
|
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
Remediates an unbounded HTTP response body allocation vulnerability (CWE-770/CWE-400), cleans up invalid package usage documentation, and documents gorilla/websocket close lifecycle behavior in
core-go.Key Changes & Remediations
Bounded Response Body Allocation (
http.go):maxResponseBytes = 32 << 20(32 MiB) cap inmakeCall().res.Bodywithio.LimitReader(res.Body, maxResponseBytes+1)to read with an extra byte budget.io.ReadAll()allocations with an explicit over-limit error if the payload exceeds 32 MiB, preventing malicious or runaway upstream endpoints from crashing client processes via memory exhaustion.API Documentation Accuracy (
README.md,CHANGELOG.md):core.NewClient()snippet with accurate documentation detailing exported HTTP helper methods (HttpGet,HttpPost),DialWebSocket, and theRestClientinterface.CHANGELOG.md.WebSocket Close Handshake Documentation (
ws.go,ws_utils.go):gorilla/websockethandles close frames internally and surfaces closures as*CloseErrorviaReadMessage(), guiding SDK consumers on proper shutdown handling.Verification
go vet ./....go test ./....