From f64d0fcb10dbc70b1d1e40471e7ae8393c93ddc1 Mon Sep 17 00:00:00 2001 From: Eyal Delarea Date: Sun, 20 Aug 2023 20:47:06 +0300 Subject: [PATCH] Fix gosec issues (#813) --- artifactory/services/gitlfsclean_test.go | 1 + artifactory/services/go/go_test.go | 6 +++--- pipelines/services/run.go | 2 +- pipelines/services/syncstatus.go | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/artifactory/services/gitlfsclean_test.go b/artifactory/services/gitlfsclean_test.go index 452905b46..216b0337d 100644 --- a/artifactory/services/gitlfsclean_test.go +++ b/artifactory/services/gitlfsclean_test.go @@ -34,6 +34,7 @@ func TestExtractRepo(t *testing.T) { func TestGetLfsFilesFromGit(t *testing.T) { log.SetLogger(log.NewLogger(log.DEBUG, nil)) + // #nosec G101 fileId := "4bf4c8c0fef3f5c8cf6f255d1c784377138588c0a9abe57e440bce3ccb350c2e" gitPath := getCliDotGitPath(t) refs := strings.Join([]string{"refs", "heads", "*"}, "/") diff --git a/artifactory/services/go/go_test.go b/artifactory/services/go/go_test.go index aa945859b..cda3acbe7 100644 --- a/artifactory/services/go/go_test.go +++ b/artifactory/services/go/go_test.go @@ -18,11 +18,11 @@ func TestCreateUrlPath(t *testing.T) { {"withoutBuildProperties", "go-repo/github.com/jfrog/test/@v/v1.1.1.zip", "", "http://test.url/api/go/", "http://test.url/api/go/go-repo/github.com/jfrog/test/@v/v1.1.1.zip"}, {"withoutBuildPropertiesModExtension", "go-repo/github.com/jfrog/test/@v/v1.1.1.mod", "", "http://test.url/api/go/", "http://test.url/api/go/go-repo/github.com/jfrog/test/@v/v1.1.1.mod"}, } - for _, test := range tests { + for i, test := range tests { t.Run(test.name, func(t *testing.T) { - assert.NoError(t, CreateUrlPath(test.pathInArtifactory, test.props, &test.goApiUrl)) + assert.NoError(t, CreateUrlPath(tests[i].pathInArtifactory, tests[i].props, &tests[i].goApiUrl)) // The props might have a different order each time, so we split the URLs and check if the lists are equal (ignoring the order) - assert.ElementsMatch(t, strings.Split(test.goApiUrl, ";"), strings.Split(test.expectedUrl, ";")) + assert.ElementsMatch(t, strings.Split(tests[i].goApiUrl, ";"), strings.Split(tests[i].expectedUrl, ";")) }) } } diff --git a/pipelines/services/run.go b/pipelines/services/run.go index 13997988e..15e69242b 100644 --- a/pipelines/services/run.go +++ b/pipelines/services/run.go @@ -36,7 +36,7 @@ func (rs *RunService) GetRunStatus(branch, pipeName string, isMultiBranch bool) httpDetails := rs.getHttpDetails() // Query params - queryParams := make(map[string]string, 0) + queryParams := make(map[string]string) if isMultiBranch { // Add this query param only when pipeline source is multi-branch queryParams["pipelineSourceBranch"] = branch diff --git a/pipelines/services/syncstatus.go b/pipelines/services/syncstatus.go index 7be7c5f94..2de2cbe36 100644 --- a/pipelines/services/syncstatus.go +++ b/pipelines/services/syncstatus.go @@ -32,7 +32,7 @@ func (ss *SyncStatusService) GetSyncPipelineResourceStatus(repoName, branch stri if resourceErr != nil { return []PipelineSyncStatus{}, fmt.Errorf("unable to fetch resourceID for '%s'. Second error: %s", repoName, resourceErr.Error()) } - queryParams := make(map[string]string, 0) + queryParams := make(map[string]string) if *res.IsMultiBranch { queryParams["pipelineSourceBranches"] = branch }