Skip to content

MLE-31809 Remediate Security Issues in Code for Operator 1.3.1 Release - #191

Open
pengzhouml wants to merge 1 commit into
developfrom
feature/MLE-31809-polaris-131
Open

MLE-31809 Remediate Security Issues in Code for Operator 1.3.1 Release#191
pengzhouml wants to merge 1 commit into
developfrom
feature/MLE-31809-polaris-131

Conversation

@pengzhouml

Copy link
Copy Markdown
Collaborator

Fixes Polaris CWE-563: Assignment to Variable without Use findings in pkg/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

  • Updated JoinDynamicHost response-body handling.
  • Updated shared doJSON, doXML, and doPlainText helpers.
  • Preserved error propagation when reading or closing HTTP response bodies.

Copilot AI lite review requested due to automatic review settings August 6, 2026 20:53
@pengzhouml
pengzhouml changed the base branch from main to develop August 6, 2026 20:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 JoinDynamicHost and replaced deferred close/join with explicit ReadAll + Close error handling.
  • Applied the same explicit read/close handling to doJSON, doXML, and doPlainText.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/mlmanage/client.go
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 thread pkg/mlmanage/client.go
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 thread pkg/mlmanage/client.go
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 thread pkg/mlmanage/client.go
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 thread pkg/mlmanage/client.go
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants