From 03596d1b0ce2f1620cc5a756ecec25ca802b8e6f Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 27 Nov 2024 09:24:28 +0100 Subject: [PATCH] Fix sec issues --- pkg/backends/k8s.go | 2 +- pkg/backends/knative.go | 2 +- pkg/backends/openfaas.go | 2 +- pkg/handlers/logs.go | 6 +++--- pkg/resourcemanager/delegate.go | 4 ++-- pkg/types/expose.go | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/backends/k8s.go b/pkg/backends/k8s.go index 0879991d..98a9cde6 100644 --- a/pkg/backends/k8s.go +++ b/pkg/backends/k8s.go @@ -66,7 +66,7 @@ func (k *KubeBackend) ListServices() ([]*types.Service, error) { services := []*types.Service{} for _, cm := range configmaps.Items { - service, err := getServiceFromConfigMap(&cm) + service, err := getServiceFromConfigMap(&cm) // #nosec G601 if err != nil { return nil, err } diff --git a/pkg/backends/knative.go b/pkg/backends/knative.go index 2893eeb3..6167ab05 100644 --- a/pkg/backends/knative.go +++ b/pkg/backends/knative.go @@ -83,7 +83,7 @@ func (kn *KnativeBackend) ListServices() ([]*types.Service, error) { services := []*types.Service{} for _, cm := range configmaps.Items { - service, err := getServiceFromConfigMap(&cm) + service, err := getServiceFromConfigMap(&cm) // #nosec G601 if err != nil { return nil, err } diff --git a/pkg/backends/openfaas.go b/pkg/backends/openfaas.go index 5743e21a..54ede05d 100644 --- a/pkg/backends/openfaas.go +++ b/pkg/backends/openfaas.go @@ -92,7 +92,7 @@ func (of *OpenfaasBackend) ListServices() ([]*types.Service, error) { services := []*types.Service{} for _, cm := range configmaps.Items { - service, err := getServiceFromConfigMap(&cm) + service, err := getServiceFromConfigMap(&cm) // #nosec G601 if err != nil { return nil, err } diff --git a/pkg/handlers/logs.go b/pkg/handlers/logs.go index cc809827..90d073e8 100644 --- a/pkg/handlers/logs.go +++ b/pkg/handlers/logs.go @@ -87,10 +87,10 @@ func MakeJobsInfoHandler(back types.ServerlessBackend, kubeClientset kubernetes. for _, contStatus := range pod.Status.ContainerStatuses { if contStatus.Name == types.ContainerName { if contStatus.State.Running != nil { - jobsInfo[jobName].StartTime = &contStatus.State.Running.StartedAt + jobsInfo[jobName].StartTime = &(contStatus.State.Running.StartedAt) } else if contStatus.State.Terminated != nil { - jobsInfo[jobName].StartTime = &contStatus.State.Terminated.StartedAt - jobsInfo[jobName].FinishTime = &contStatus.State.Terminated.FinishedAt + jobsInfo[jobName].StartTime = &(contStatus.State.Terminated.StartedAt) + jobsInfo[jobName].FinishTime = &(contStatus.State.Terminated.FinishedAt) } } } diff --git a/pkg/resourcemanager/delegate.go b/pkg/resourcemanager/delegate.go index 014df265..87292360 100644 --- a/pkg/resourcemanager/delegate.go +++ b/pkg/resourcemanager/delegate.go @@ -398,14 +398,14 @@ func getClusterStatus(service *types.Service) { if service.Delegation == "random" { max := big.NewInt(int64(noDelegateCode)) randomNumber, _ := rand.Int(rand.Reader, max) - randPriority := randomNumber.Int64() + randPriority := randomNumber.Uint64() replica.Priority = uint(randPriority) fmt.Println("Priority ", replica.Priority, " with ", service.Delegation, " delegation") } else if service.Delegation == "load-based" { //Map the totalClusterCPU range to a smaller range (input range 0 to 32 cpu to output range 100 to 0 priority) totalClusterCPU := clusterStatus.CPUFreeTotal mappedCPUPriority := mapToRange(totalClusterCPU, 0, 32000, 100, 0) - replica.Priority = uint(mappedCPUPriority) + replica.Priority = uint(mappedCPUPriority) // #nosec G115 fmt.Println("Priority ", replica.Priority, " with ", service.Delegation, " delegation") } else if service.Delegation != "static" { replica.Priority = noDelegateCode diff --git a/pkg/types/expose.go b/pkg/types/expose.go index 09b758b4..16f72cce 100644 --- a/pkg/types/expose.go +++ b/pkg/types/expose.go @@ -250,7 +250,7 @@ func getPodTemplateSpec(service Service, cfg *Config) v1.PodTemplateSpec { podSpec.Containers[i].Ports = []v1.ContainerPort{ { Name: podPortName, - ContainerPort: int32(service.Expose.APIPort), + ContainerPort: int32(service.Expose.APIPort), // #nosec G115 }, } podSpec.Containers[i].VolumeMounts[0].ReadOnly = false @@ -352,7 +352,7 @@ func getServiceSpec(service Service, cfg *Config) *v1.Service { Port: servicePortNumber, TargetPort: intstr.IntOrString{ Type: 0, - IntVal: int32(service.Expose.APIPort), + IntVal: int32(service.Expose.APIPort), // #nosec G115 }, } service_type := v1.ServiceType(typeClusterIP)