-
Notifications
You must be signed in to change notification settings - Fork 270
MGMT-24693: Normalize unbracketed IPv6 ignition endpoint URLs before … #10570
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||
| __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||
| source ${__dir}/common.sh | ||||||
| source ${__dir}/utils.sh | ||||||
| source ${__dir}/mirror_utils.sh | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Quote 🔧 Proposed fix-source ${__dir}/mirror_utils.sh
+source "${__dir}/mirror_utils.sh"📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.11.0)[info] 6-6: Not following: ./mirror_utils.sh was not specified as input (see shellcheck -x). (SC1091) [info] 6-6: Double quote to prevent globbing and word splitting. (SC2086) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||
|
|
||||||
| set -o xtrace | ||||||
|
|
||||||
|
|
@@ -139,7 +140,7 @@ function from_upstream() { | |||||
|
|
||||||
| if [ "${DISCONNECTED}" = "true" ]; then | ||||||
| export IMG="${LOCAL_REGISTRY}/localimages/hive:latest" | ||||||
| oc image mirror \ | ||||||
| run_mirror_command_with_retry oc image mirror \ | ||||||
| -a ${AUTHFILE} \ | ||||||
| ${HIVE_IMAGE} \ | ||||||
| ${IMG} | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package bminventory | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/openshift/assisted-service/models" | ||
| "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| func TestValidateIgnitionEndpointNormalizesUnbracketedIPv6(t *testing.T) { | ||
| bm := &bareMetalInventory{} | ||
| url := "https://fd2e:6f44:5dd8:c956::14:31187" | ||
| ignitionEndpoint := &models.IgnitionEndpoint{URL: &url} | ||
|
|
||
| if err := bm.validateIgnitionEndpoint(ignitionEndpoint, logrus.New()); err != nil { | ||
| t.Fatalf("validateIgnitionEndpoint returned error: %v", err) | ||
| } | ||
| want := "https://[fd2e:6f44:5dd8:c956::14]:31187" | ||
| if *ignitionEndpoint.URL != want { | ||
| t.Fatalf("got URL %q, want %q", *ignitionEndpoint.URL, want) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package hostutil | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/openshift/assisted-service/internal/common" | ||
| "github.com/openshift/assisted-service/models" | ||
| "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| func TestGetIgnitionEndpointAndCertUnbracketedIPv6CustomEndpoint(t *testing.T) { | ||
| customEndpoint := "https://fd2e:6f44:5dd8:c956::14:31187" | ||
| cluster := common.Cluster{ | ||
| Cluster: models.Cluster{ | ||
| IgnitionEndpoint: &models.IgnitionEndpoint{URL: &customEndpoint}, | ||
| }, | ||
| } | ||
| host := models.Host{Role: models.HostRoleWorker} | ||
|
|
||
| url, cert, err := GetIgnitionEndpointAndCert(&cluster, &host, logrus.New()) | ||
| if err != nil { | ||
| t.Fatalf("GetIgnitionEndpointAndCert returned error: %v", err) | ||
| } | ||
| if cert != nil { | ||
| t.Fatalf("expected no certificate, got %v", cert) | ||
| } | ||
| want := "https://[fd2e:6f44:5dd8:c956::14]:31187/worker" | ||
| if url != want { | ||
| t.Fatalf("got URL %q, want %q", url, want) | ||
| } | ||
| } |
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Fix shellcheck SC2155/SC2086 on
PROVIDER_LOCAL_IMAGEassignment.Command substitution's return value is masked by the
exportassignment, and${PROVIDER_IMAGE}is unquoted inside$(...), risking word-splitting/globbing.🔧 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 83-83: Declare and assign separately to avoid masking return values.
(SC2155)
[info] 83-83: Double quote to prevent globbing and word splitting.
(SC2086)
🤖 Prompt for AI Agents
Source: Linters/SAST tools