diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 77b60565f..f6fd023aa 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -29,7 +29,7 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 with: - version: v2.10.1 + version: v2.11.3 args: --timeout 5m -v #--exclude SA5011 diff --git a/Makefile b/Makefile index 5953c0913..40b4be895 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ GOFLAGS=-mod=vendor REGISTRY ?= localhost UPLOADREGISTRY ?= quay.io/validatedpatterns GOLANGCI_IMG ?= docker.io/golangci/golangci-lint -GOLANGCI_VERSION ?= 2.10.1 +GOLANGCI_VERSION ?= 2.11.3 # CI uses a non-writable home dir, make sure .cache is writable ifeq ("${HOME}", "/") diff --git a/internal/controller/pattern_controller.go b/internal/controller/pattern_controller.go index 9ff9bf766..0bcfeb807 100644 --- a/internal/controller/pattern_controller.go +++ b/internal/controller/pattern_controller.go @@ -25,6 +25,7 @@ import ( "io" "log" "net/http" + "net/url" "os" "path/filepath" "strings" @@ -926,6 +927,16 @@ func (r *PatternReconciler) checkSpokeApplicationsGone(appOfApps bool) (bool, er searchURL = fmt.Sprintf("https://search-search-api.%s.svc.cluster.local:4010/searchapi/graphql", searchNamespace) } + parsedURL, err := url.Parse(searchURL) + if err != nil || (parsedURL.Scheme != "https" && parsedURL.Scheme != "http") { + return false, fmt.Errorf("invalid search API URL: %s", searchURL) + } + cleanURL := url.URL{ + Scheme: parsedURL.Scheme, + Host: parsedURL.Host, + Path: parsedURL.Path, + } + token := os.Getenv("ACM_SEARCH_API_TOKEN") if token == "" { var tokenBytes []byte @@ -983,7 +994,7 @@ func (r *PatternReconciler) checkSpokeApplicationsGone(appOfApps bool) (bool, er } // Create HTTP request - req, err := http.NewRequestWithContext(context.Background(), "POST", searchURL, bytes.NewBuffer(queryJSON)) + req, err := http.NewRequestWithContext(context.Background(), "POST", cleanURL.String(), bytes.NewBuffer(queryJSON)) if err != nil { return false, fmt.Errorf("failed to create HTTP request: %w", err) }