From 457c6073030f50a5b1a1f534a0315f2e8403460d Mon Sep 17 00:00:00 2001 From: Corey Daley Date: Mon, 21 Aug 2023 10:19:55 -0400 Subject: [PATCH] correcting golangci-lint and gosec issues Fixing gosec issue G601 (CWE-118): Implicit memory aliasing in for loop. (Confidence: MEDIUM, Severity: MEDIUM) --- controllers/pipelinerun_controller.go | 2 +- pkg/filter/customrun.go | 4 ++-- pkg/filter/pipelinerun.go | 2 +- pkg/inventory/search_result.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/pipelinerun_controller.go b/controllers/pipelinerun_controller.go index ce6b425a..ae63153f 100644 --- a/controllers/pipelinerun_controller.go +++ b/controllers/pipelinerun_controller.go @@ -137,7 +137,7 @@ func (r *PipelineRunReconciler) Reconcile( var triggeredBuilds = []filter.TriggeredBuild{} if filter.PipelineRunAnnotatedNameMatchesObject(&pipelineRun) { // extracting existing triggered-builds from the annotation, information needed to detect if - // the BuildRuns have already beeing issued for the PipelineRun + // the BuildRuns have already been issued for the PipelineRun triggeredBuilds, err = filter.PipelineRunExtractTriggeredBuildsSlice(&pipelineRun) if err != nil { logger.V(0).Error(err, "parsing triggered-builds annotation") diff --git a/pkg/filter/customrun.go b/pkg/filter/customrun.go index e99e9873..2bc5947a 100644 --- a/pkg/filter/customrun.go +++ b/pkg/filter/customrun.go @@ -16,7 +16,7 @@ import ( // ParamValues slice. func TektonCustomRunParamsToShipwrightParamValues(customRun *tknv1beta1.CustomRun) []v1alpha1.ParamValue { paramValues := []v1alpha1.ParamValue{} - for _, p := range customRun.Spec.Params { + for i, p := range customRun.Spec.Params { paramValue := v1alpha1.ParamValue{Name: p.Name} if p.Value.Type == tknv1beta1.ParamTypeArray { paramValue.Values = []v1alpha1.SingleValue{} @@ -28,7 +28,7 @@ func TektonCustomRunParamsToShipwrightParamValues(customRun *tknv1beta1.CustomRu } } else { paramValue.SingleValue = &v1alpha1.SingleValue{ - Value: &p.Value.StringVal, + Value: &customRun.Spec.Params[i].Value.StringVal, } } paramValues = append(paramValues, paramValue) diff --git a/pkg/filter/pipelinerun.go b/pkg/filter/pipelinerun.go index e708a2ec..1b9ba799 100644 --- a/pkg/filter/pipelinerun.go +++ b/pkg/filter/pipelinerun.go @@ -38,7 +38,7 @@ var ( TektonPipelineRunTriggeredBuilds = fmt.Sprintf("%s/pipelinerun-triggered-builds", Prefix) ) -// pipelineRunReferencesShipwright checks if the informed PipelineRun is reffering to a Shipwright +// pipelineRunReferencesShipwright checks if the informed PipelineRun is referring to a Shipwright // resource via TaskRef. func pipelineRunReferencesShipwright(pipelineRun *tknv1beta1.PipelineRun) bool { if pipelineRun.Status.PipelineSpec == nil { diff --git a/pkg/inventory/search_result.go b/pkg/inventory/search_result.go index 1298852b..84189ae0 100644 --- a/pkg/inventory/search_result.go +++ b/pkg/inventory/search_result.go @@ -10,7 +10,7 @@ import ( // SearchResult contains a Inventory result item. type SearchResult struct { - BuildName types.NamespacedName // build name maching criteria + BuildName types.NamespacedName // build name matching criteria SecretName types.NamespacedName // respective secret coordinates (for webhook) }