[release-4.13] use net.JoinHostPort for URL construction#3005
Conversation
Use net.JoinHostPort() in Go code to properly handle IPv6 addresses when constructing the Kubernetes service URL. This function correctly adds brackets only for IPv6 addresses, ensuring compliance with CVE-2025-47912 (Go 1.24.8+ rejects IPv4/hostnames in URL brackets). This approach is cleaner than handling the logic in shell scripts, as it follows the existing pattern used in ovn_kubernetes.go. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@stbenjam: This pull request references Jira Issue OCPBUGS-84184, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: stbenjam The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@stbenjam: No Jira issue is referenced in the title of this pull request. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@stbenjam: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
Cherry-pick of commit a8f745d from release-4.14 (part of PR #2996, originally from PR #2969).
https://[${KUBERNETES_SERVICE_HOST}]:${KUBERNETES_SERVICE_PORT}with a Go-rendered{{.KubernetesServiceURL}}template value usingnet.JoinHostPort()in:bindata/network/multus-admission-controller/admission-controller.yaml)bindata/cloud-network-config-controller/managed/controller.yaml)pkg/network/cloud_network.go,pkg/network/multus_admission_controller.go) now constructs the URL properly usingnet.JoinHostPort(), which only adds brackets for IPv6 addressesKUBERNETES_SERVICE_HOSTandKUBERNETES_SERVICE_PORTinto the init container is removed since the URL is now rendered directly into the templateRoot cause
The previous code unconditionally wrapped
KUBERNETES_SERVICE_HOSTin square brackets when constructing the Kubernetes API server URL. Go 1.24.8+ (CVE-2025-47912) rejects brackets around non-IPv6 addresses, causing URL parsing failures.Why this is needed
The 4.14 nightly
gcp-ovn-rt-upgradejob upgrades from 4.13 to 4.14. The 4.13 source cluster hits this bug before the upgrade delivers the fixed 4.14 code.Test plan
go build ./cmd/...