catalog: fix gosec memory aliasing warning in for loop
gosec correctly flags code that memory aliases the loop variable.
Doing so will result in overwriting previously stored values
based on the value pointed to by loop variable in the last iteration.
@@ -67,8 +67,8 @@ func (mc *MeshCatalog) filterTrafficSplitServices(services []v1.Service) []v1.Se
// These are the services except ones that are a root of a TrafficSplit policy
var filteredServices []v1.Service
- for _, svc := range services {
- nsSvc := utils.K8sSvcToMeshSvc(&svc)
+ for i, svc := range services {
+ nsSvc := utils.K8sSvcToMeshSvc(&services[i])
if _, shouldSkip := excludeTheseServices[nsSvc]; shouldSkip {
continue
}
