Skip to content

Commit

Permalink
Merge pull request #2381 from chrischdi/pr-fix-linter-ignores
Browse files Browse the repository at this point in the history
🌱 lint: remove linter ignores from .golangci-lint for gosec
  • Loading branch information
k8s-ci-robot authored Sep 25, 2023
2 parents 29f9ef7 + 3e16b30 commit 830aa85
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 20 deletions.
11 changes: 0 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,6 @@ issues:
path: ^apis\/.*\/.*conversion.*\.go$

# FIXME: All below excludes should get removed over time.
- linters:
- staticcheck
text: "SA1019: failureDomain.AutoConfigure is deprecated"
- path: "test/e2e/*"
linters:
- gosec
text: "G106:"

# missing comments
- linters:
Expand Down Expand Up @@ -300,7 +293,3 @@ issues:
- gosec
text: "G104: Errors unhandled."
path: ^(controllers/vspherecluster_reconciler|pkg/manager/options_test|test/helpers/webhook)\.go$
- linters:
- gosec
text: "(G204|G301|G304): "
path: ^test/
2 changes: 1 addition & 1 deletion controllers/vspheredeploymentzone_controller_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (r vsphereDeploymentZoneReconciler) reconcileFailureDomain(ctx context.Cont
}

func (r vsphereDeploymentZoneReconciler) reconcileInfraFailureDomain(ctx context.Context, deploymentZoneCtx *capvcontext.VSphereDeploymentZoneContext, failureDomain infrav1.FailureDomain) error {
if *failureDomain.AutoConfigure {
if *failureDomain.AutoConfigure { //nolint:staticcheck
return r.createAndAttachMetadata(ctx, deploymentZoneCtx, failureDomain)
}
return r.verifyFailureDomain(ctx, deploymentZoneCtx, failureDomain)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
// Before all ParallelNodes.

Expect(configPath).To(BeAnExistingFile(), "Invalid test suite argument. e2e.config should be an existing file.")
Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder) //nolint:gofumpt
Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder) //nolint:gosec // Non-production code

By("Initializing a runtime.Scheme with all the GVK relevant for this test")
scheme := initScheme()
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/log_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func createOutputFile(path string) (*os.File, error) {
if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil {
return nil, err
}
return os.Create(path)
return os.Create(filepath.Clean(path))
}

func executeRemoteCommand(f io.StringWriter, hostIPAddr, command string, args ...string) error {
Expand Down Expand Up @@ -137,7 +137,7 @@ func newSSHConfig() (*ssh.ClientConfig, error) {

config := &ssh.ClientConfig{
User: DefaultUserName,
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
HostKeyCallback: ssh.InsecureIgnoreHostKey(), //nolint:gosec // Non-production code
Auth: []ssh.AuthMethod{
ssh.PublicKeys(signer),
},
Expand All @@ -152,5 +152,5 @@ func readPrivateKey() ([]byte, error) {
return nil, errors.Errorf("private key information missing. Please set %s environment variable", VSpherePrivateKeyFilePath)
}

return os.ReadFile(privateKeyFilePath)
return os.ReadFile(filepath.Clean(privateKeyFilePath))
}
3 changes: 2 additions & 1 deletion test/helpers/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package helpers

import (
"os"
"path/filepath"

"github.com/pkg/errors"
"golang.org/x/mod/modfile"
Expand All @@ -30,7 +31,7 @@ type Mod struct {

func NewMod(path string) (Mod, error) {
var mod Mod
content, err := os.ReadFile(path)
content, err := os.ReadFile(filepath.Clean(path))
if err != nil {
return mod, err
}
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/vcsim/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (b *Builder) Build() (*Simulator, error) {
func govcCommand(govcURL, commandStr string, buffers ...*gbytes.Buffer) *exec.Cmd {
govcBinPath := os.Getenv("GOVC_BIN_PATH")
args := strings.Split(commandStr, " ")
cmd := exec.Command(govcBinPath, args...)
cmd := exec.Command(govcBinPath, args...) //nolint:gosec // Non-production code
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, fmt.Sprintf("GOVC_URL=%s", govcURL), "GOVC_INSECURE=true")

Expand Down
2 changes: 1 addition & 1 deletion test/helpers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func initializeWebhookInEnvironment() {
klog.Fatalf("Failed to get information for current file from runtime")
}
root := path.Join(path.Dir(filename), "..", "..")
configyamlFile, err := os.ReadFile(filepath.Join(root, "config", "webhook", "manifests.yaml"))
configyamlFile, err := os.ReadFile(filepath.Clean(filepath.Join(root, "config", "webhook", "manifests.yaml")))
if err != nil {
klog.Fatalf("Failed to read core webhook configuration file: %v ", err)
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
Expect(err).NotTo(HaveOccurred())

Expect(configPath).To(BeAnExistingFile(), "Invalid test suite argument. e2e.config should be an existing file.")
Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder)
Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder) //nolint:gosec // Non-production code

By("Initializing a runtime.Scheme with all the GVK relevant for this test")
scheme := initScheme()
Expand Down

0 comments on commit 830aa85

Please sign in to comment.