From 189d9a50995a5d64a309d10f02c99b34953c91ef Mon Sep 17 00:00:00 2001 From: Gabriel Freites Date: Tue, 28 Feb 2023 15:01:40 -0500 Subject: [PATCH] Release 1.8 CVEs updates (#516) * fixed doc lint for vsphere * removing ioutil in favor of os and io standar libs * imported os --- pkg/horizon/horizon.go | 4 ++-- pkg/vsphere/client.go | 4 ++-- pkg/vsphere/doc.go | 6 ++++-- plugins/vsphere/pkg/command/auth/auth_test.go | 6 +++--- plugins/vsphere/pkg/command/auth/create.go | 4 ++-- plugins/vsphere/pkg/command/binding/binding_test.go | 6 +++--- plugins/vsphere/pkg/command/source/source_test.go | 6 +++--- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pkg/horizon/horizon.go b/pkg/horizon/horizon.go index f76f88532..e8a6b6faa 100644 --- a/pkg/horizon/horizon.go +++ b/pkg/horizon/horizon.go @@ -10,8 +10,8 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io/ioutil" "net/http" + "os" "path/filepath" "time" @@ -74,7 +74,7 @@ func readSecretKey(key string) (string, error) { mountPath = env.SecretPath } - data, err := ioutil.ReadFile(filepath.Join(mountPath, key)) + data, err := os.ReadFile(filepath.Join(mountPath, key)) if err != nil { return "", err } diff --git a/pkg/vsphere/client.go b/pkg/vsphere/client.go index 116d5c2e1..e60675b73 100644 --- a/pkg/vsphere/client.go +++ b/pkg/vsphere/client.go @@ -8,9 +8,9 @@ package vsphere import ( "context" "errors" - "io/ioutil" "net/http" "net/url" + "os" "path/filepath" "time" @@ -51,7 +51,7 @@ func ReadKey(key string) (string, error) { mountPath = env.SecretPath } - data, err := ioutil.ReadFile(filepath.Join(mountPath, key)) + data, err := os.ReadFile(filepath.Join(mountPath, key)) if err != nil { return "", err } diff --git a/pkg/vsphere/doc.go b/pkg/vsphere/doc.go index 2ef89e895..ac200ce75 100644 --- a/pkg/vsphere/doc.go +++ b/pkg/vsphere/doc.go @@ -6,10 +6,12 @@ SPDX-License-Identifier: Apache-2.0 // Package vsphere holds utilities for bootstrapping a vSphere API client // from the metadata injected by the VSphereSource. Within a receive adapter, // users can create a new vSphere SOAP API client with automatic keep-alive: -// client, err := vsphere.NewSOAPClient(ctx) +// +// client, err := vsphere.NewSOAPClient(ctx) // // To properly release vSphere API resources, it is recommended to log out when the client is not needed anymore: -// defer client.Logout(context.Background()) +// +// defer client.Logout(context.Background()) // // This is modeled after the Bindings pattern. package vsphere diff --git a/plugins/vsphere/pkg/command/auth/auth_test.go b/plugins/vsphere/pkg/command/auth/auth_test.go index 04f459678..b8e8c8c65 100644 --- a/plugins/vsphere/pkg/command/auth/auth_test.go +++ b/plugins/vsphere/pkg/command/auth/auth_test.go @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 package auth_test import ( - "io/ioutil" + "io" "testing" "github.com/spf13/cobra" @@ -45,7 +45,7 @@ func authTestCommand(clientConfig clientcmd.ClientConfig, objects ...runtime.Obj ClientSet: client, ClientConfig: clientConfig, }) - cmd.SetErr(ioutil.Discard) - cmd.SetOut(ioutil.Discard) + cmd.SetErr(io.Discard) + cmd.SetOut(io.Discard) return cmd, client } diff --git a/plugins/vsphere/pkg/command/auth/create.go b/plugins/vsphere/pkg/command/auth/create.go index 498d345ff..acd9c42f3 100644 --- a/plugins/vsphere/pkg/command/auth/create.go +++ b/plugins/vsphere/pkg/command/auth/create.go @@ -8,7 +8,7 @@ package auth import ( "context" "fmt" - "io/ioutil" + "io" "net/url" "syscall" @@ -136,6 +136,6 @@ func readPassword(cmd *cobra.Command, options *Options) (string, error) { cmd.Println() return string(password), err } - password, err := ioutil.ReadAll(cmd.InOrStdin()) + password, err := io.ReadAll(cmd.InOrStdin()) return string(password), err } diff --git a/plugins/vsphere/pkg/command/binding/binding_test.go b/plugins/vsphere/pkg/command/binding/binding_test.go index 3b6d679b1..f71fdee00 100644 --- a/plugins/vsphere/pkg/command/binding/binding_test.go +++ b/plugins/vsphere/pkg/command/binding/binding_test.go @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 package binding_test import ( - "io/ioutil" + "io" "testing" "github.com/spf13/cobra" @@ -47,7 +47,7 @@ func bindingTestCommand(clientConfig clientcmd.ClientConfig, objects ...runtime. ClientConfig: clientConfig, VSphereClientSet: vSphereSourcesClient, }) - cmd.SetErr(ioutil.Discard) - cmd.SetOut(ioutil.Discard) + cmd.SetErr(io.Discard) + cmd.SetOut(io.Discard) return cmd, vSphereSourcesClient } diff --git a/plugins/vsphere/pkg/command/source/source_test.go b/plugins/vsphere/pkg/command/source/source_test.go index 8af1be897..52f4587c8 100644 --- a/plugins/vsphere/pkg/command/source/source_test.go +++ b/plugins/vsphere/pkg/command/source/source_test.go @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 package source_test import ( - "io/ioutil" + "io" "testing" "github.com/spf13/cobra" @@ -47,7 +47,7 @@ func sourceTestCommand(clientConfig clientcmd.ClientConfig, objects ...runtime.O ClientConfig: clientConfig, VSphereClientSet: vSphereSourcesClient, }) - cmd.SetErr(ioutil.Discard) - cmd.SetOut(ioutil.Discard) + cmd.SetErr(io.Discard) + cmd.SetOut(io.Discard) return cmd, vSphereSourcesClient }