MLE-31809 Remediate Security Issues in Code for Operator 1.3.1 Release - #191
Open
pengzhouml wants to merge 1 commit into
Open
MLE-31809 Remediate Security Issues in Code for Operator 1.3.1 Release#191pengzhouml wants to merge 1 commit into
pengzhouml wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates HTTP response-body handling to explicitly close response bodies and propagate Close() errors alongside read errors, removing the previous defer + named-return error-join pattern.
Changes:
- Removed named return from
JoinDynamicHostand replaced deferred close/join with explicitReadAll+Closeerror handling. - Applied the same explicit read/close handling to
doJSON,doXML, anddoPlainText.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+431
to
+437
| respBody, readErr := io.ReadAll(resp.Body) | ||
| closeErr := resp.Body.Close() | ||
| if readErr != nil { | ||
| return errors.Join(readErr, closeErr) | ||
| } | ||
| if closeErr != nil { | ||
| return closeErr |
Comment on lines
+680
to
+686
| data, readErr := io.ReadAll(resp.Body) | ||
| closeErr := resp.Body.Close() | ||
| if readErr != nil { | ||
| return nil, resp.StatusCode, errors.Join(readErr, closeErr) | ||
| } | ||
| if closeErr != nil { | ||
| return data, resp.StatusCode, closeErr |
Comment on lines
+719
to
+725
| data, readErr := io.ReadAll(resp.Body) | ||
| closeErr := resp.Body.Close() | ||
| if readErr != nil { | ||
| return nil, resp.StatusCode, errors.Join(readErr, closeErr) | ||
| } | ||
| if closeErr != nil { | ||
| return data, resp.StatusCode, closeErr |
Comment on lines
+749
to
+755
| data, readErr := io.ReadAll(resp.Body) | ||
| closeErr := resp.Body.Close() | ||
| if readErr != nil { | ||
| return nil, resp.StatusCode, errors.Join(readErr, closeErr) | ||
| } | ||
| if closeErr != nil { | ||
| return data, resp.StatusCode, closeErr |
Comment on lines
+680
to
+686
| data, readErr := io.ReadAll(resp.Body) | ||
| closeErr := resp.Body.Close() | ||
| if readErr != nil { | ||
| return nil, resp.StatusCode, errors.Join(readErr, closeErr) | ||
| } | ||
| if closeErr != nil { | ||
| return data, resp.StatusCode, closeErr |
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.
Fixes Polaris
CWE-563: Assignment to Variable without Usefindings inpkg/mlmanage/client.go.Response-body handling no longer assigns close errors to a deferred named return variable. Each affected request path now explicitly reads and closes the response body, returning read or close errors as appropriate.
Changes
JoinDynamicHostresponse-body handling.doJSON,doXML, anddoPlainTexthelpers.