diff --git a/.golangci.yml b/.golangci.yml index ca69a11f..9647c459 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,6 +28,7 @@ linters: - goimports - gosimple - govet + - gosec - ineffassign - lll - misspell diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index b036e035..650b894b 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -38,6 +38,7 @@ var _ = Describe("controller", Ordered, func() { Expect(utils.InstallCertManager()).To(Succeed()) By("creating manager namespace") + //nolint:gosec cmd := exec.Command("kubectl", "create", "ns", namespace) _, _ = utils.Run(cmd) }) @@ -50,6 +51,7 @@ var _ = Describe("controller", Ordered, func() { utils.UninstallCertManager() By("removing manager namespace") + //nolint:gosec cmd := exec.Command("kubectl", "delete", "ns", namespace) _, _ = utils.Run(cmd) }) @@ -63,6 +65,7 @@ var _ = Describe("controller", Ordered, func() { var projectimage = "example.com/ceph-csi-operator:v0.0.1" By("building the manager(Operator) image") + //nolint:gosec cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", projectimage)) _, err = utils.Run(cmd) ExpectWithOffset(1, err).NotTo(HaveOccurred()) @@ -72,11 +75,13 @@ var _ = Describe("controller", Ordered, func() { ExpectWithOffset(1, err).NotTo(HaveOccurred()) By("installing CRDs") + //nolint:gosec cmd = exec.Command("make", "install") _, err = utils.Run(cmd) ExpectWithOffset(1, err).NotTo(HaveOccurred()) By("deploying the controller-manager") + //nolint:gosec cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectimage)) _, err = utils.Run(cmd) ExpectWithOffset(1, err).NotTo(HaveOccurred()) @@ -84,7 +89,7 @@ var _ = Describe("controller", Ordered, func() { By("validating that the controller-manager pod is running as expected") verifyControllerUp := func() error { // Get pod name - + //nolint:gosec cmd = exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager", "-o", "go-template={{ range .items }}"+ @@ -104,10 +109,8 @@ var _ = Describe("controller", Ordered, func() { ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager")) // Validate pod status - cmd = exec.Command("kubectl", "get", - "pods", controllerPodName, "-o", "jsonpath={.status.phase}", - "-n", namespace, - ) + //nolint:gosec + cmd = exec.Command("kubectl", "get", "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace) status, err := utils.Run(cmd) ExpectWithOffset(2, err).NotTo(HaveOccurred()) if string(status) != "Running" { diff --git a/test/utils/utils.go b/test/utils/utils.go index e3eb79b0..5e04e047 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -41,6 +41,7 @@ func warnError(err error) { // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. func InstallPrometheusOperator() error { url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion) + //nolint:gosec cmd := exec.Command("kubectl", "create", "-f", url) _, err := Run(cmd) return err @@ -69,6 +70,7 @@ func Run(cmd *exec.Cmd) ([]byte, error) { // UninstallPrometheusOperator uninstalls the prometheus func UninstallPrometheusOperator() { url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion) + //nolint:gosec cmd := exec.Command("kubectl", "delete", "-f", url) if _, err := Run(cmd); err != nil { warnError(err) @@ -78,6 +80,7 @@ func UninstallPrometheusOperator() { // UninstallCertManager uninstalls the cert manager func UninstallCertManager() { url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion) + //nolint:gosec cmd := exec.Command("kubectl", "delete", "-f", url) if _, err := Run(cmd); err != nil { warnError(err) @@ -87,12 +90,14 @@ func UninstallCertManager() { // InstallCertManager installs the cert manager bundle. func InstallCertManager() error { url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion) + //nolint:gosec cmd := exec.Command("kubectl", "apply", "-f", url) if _, err := Run(cmd); err != nil { return err } // Wait for cert-manager-webhook to be ready, which can take time if cert-manager // was re-installed after uninstalling on a cluster. + //nolint:gosec cmd = exec.Command("kubectl", "wait", "deployment.apps/cert-manager-webhook", "--for", "condition=Available", "--namespace", "cert-manager", @@ -110,6 +115,7 @@ func LoadImageToKindClusterWithName(name string) error { cluster = v } kindOptions := []string{"load", "docker-image", name, "--name", cluster} + //nolint:gosec cmd := exec.Command("kind", kindOptions...) _, err := Run(cmd) return err