From 39133bde08e9432eda64d7b0f3c7b256384c31b3 Mon Sep 17 00:00:00 2001 From: David Wertenteil Date: Wed, 26 Jul 2023 19:25:01 +0300 Subject: [PATCH] fixed pkg changes Signed-off-by: David Wertenteil --- mainhandler/handlerequests.go | 6 +++--- mainhandler/vulnscan.go | 15 ++++++++------- mainhandler/vulnscanhandlerhelper_test.go | 10 +++++----- utils/typesutils.go | 4 ++-- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/mainhandler/handlerequests.go b/mainhandler/handlerequests.go index ee503dc7..d475ff1f 100644 --- a/mainhandler/handlerequests.go +++ b/mainhandler/handlerequests.go @@ -11,7 +11,7 @@ import ( "github.com/kubescape/operator/watcher" "go.opentelemetry.io/otel" - apitypes "github.com/armosec/armoapi-go/armotypes" + "github.com/armosec/armoapi-go/identifiers" "github.com/armosec/utils-go/boolutils" "github.com/armosec/utils-go/httputils" @@ -248,7 +248,7 @@ func (mainHandler *MainHandler) HandleScopedRequest(ctx context.Context, session if len(sessionObj.Command.Designators) > 0 { namespaces = make([]string, 0, 3) for desiIdx := range sessionObj.Command.Designators { - if ns, ok := sessionObj.Command.Designators[desiIdx].Attributes[apitypes.AttributeNamespace]; ok { + if ns, ok := sessionObj.Command.Designators[desiIdx].Attributes[identifiers.AttributeNamespace]; ok { namespaces = append(namespaces, ns) } } @@ -282,7 +282,7 @@ func (mainHandler *MainHandler) HandleScopedRequest(ctx context.Context, session // clean all scope request parameters cmd.WildWlid = "" - cmd.Designators = make([]apitypes.PortalDesignator, 0) + cmd.Designators = make([]identifiers.PortalDesignator, 0) // send specific command to the channel newSessionObj := utils.NewSessionObj(ctx, cmd, "Websocket", sessionObj.Reporter.GetJobID(), "", 1) diff --git a/mainhandler/vulnscan.go b/mainhandler/vulnscan.go index 4fc0cb94..ed935637 100644 --- a/mainhandler/vulnscan.go +++ b/mainhandler/vulnscan.go @@ -23,6 +23,7 @@ import ( "github.com/armosec/armoapi-go/apis" apitypes "github.com/armosec/armoapi-go/armotypes" + "github.com/armosec/armoapi-go/identifiers" reporterlib "github.com/armosec/logger-go/system-reports/datastructures" "github.com/armosec/utils-go/httputils" "github.com/kubescape/k8s-interface/cloudsupport" @@ -101,12 +102,12 @@ func convertImagesToRegistryScanCommand(registry *registryScan, sessionObj *util ImageTag: repository + ":" + tag, Session: apis.SessionChain{ActionTitle: "vulnerability-scan", JobIDs: make([]string, 0), Timestamp: sessionObj.Reporter.GetTimestamp()}, Args: map[string]interface{}{ - apitypes.AttributeRegistryName: registry.registry.hostname + "/" + registry.registry.projectID, - apitypes.AttributeRepository: repositoryName, - apitypes.AttributeTag: tag, - apitypes.AttributeUseHTTP: !*registry.registryInfo.IsHTTPS, - apitypes.AttributeSkipTLSVerify: registry.registryInfo.SkipTLSVerify, - apitypes.AttributeSensor: utils.ClusterConfig.ClusterName, + identifiers.AttributeRegistryName: registry.registry.hostname + "/" + registry.registry.projectID, + identifiers.AttributeRepository: repositoryName, + identifiers.AttributeTag: tag, + identifiers.AttributeUseHTTP: !*registry.registryInfo.IsHTTPS, + identifiers.AttributeSkipTLSVerify: registry.registryInfo.SkipTLSVerify, + identifiers.AttributeSensor: utils.ClusterConfig.ClusterName, }, } // Check if auth is empty (used for public registries) @@ -210,7 +211,7 @@ func (actionHandler *ActionHandler) parseRegistryName(sessionObj *utils.SessionO return "" } - sessionObj.Reporter.SetTarget(fmt.Sprintf("%s: %s", apitypes.AttributeRegistryName, + sessionObj.Reporter.SetTarget(fmt.Sprintf("%s: %s", identifiers.AttributeRegistryName, registryName)) sessionObj.Reporter.SendDetails(fmt.Sprintf("registryInfo parsed: %v", registryInfo), true, sessionObj.ErrChan) return registryName diff --git a/mainhandler/vulnscanhandlerhelper_test.go b/mainhandler/vulnscanhandlerhelper_test.go index fdb87445..40b5e9be 100644 --- a/mainhandler/vulnscanhandlerhelper_test.go +++ b/mainhandler/vulnscanhandlerhelper_test.go @@ -3,7 +3,7 @@ package mainhandler import ( "testing" - apitypes "github.com/armosec/armoapi-go/armotypes" + "github.com/armosec/armoapi-go/identifiers" "github.com/armosec/armoapi-go/apis" "github.com/stretchr/testify/assert" @@ -70,12 +70,12 @@ func TestGetNamespaceFromVulnScanCommand(t *testing.T) { name: "namespace from designators", command: &apis.Command{ CommandName: apis.TypeSetVulnScanCronJob, - Designators: []apitypes.PortalDesignator{ + Designators: []identifiers.PortalDesignator{ { - DesignatorType: apitypes.DesignatorAttributes, + DesignatorType: identifiers.DesignatorAttributes, Attributes: map[string]string{ - apitypes.AttributeCluster: "minikube", - apitypes.AttributeNamespace: "test-333", + identifiers.AttributeCluster: "minikube", + identifiers.AttributeNamespace: "test-333", }, }, }, diff --git a/utils/typesutils.go b/utils/typesutils.go index 322c57e8..42c1b98c 100644 --- a/utils/typesutils.go +++ b/utils/typesutils.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - apitypes "github.com/armosec/armoapi-go/armotypes" reporterlib "github.com/armosec/logger-go/system-reports/datastructures" "github.com/armosec/utils-go/httputils" "github.com/google/uuid" @@ -12,6 +11,7 @@ import ( "github.com/kubescape/go-logger/helpers" "github.com/armosec/armoapi-go/apis" + "github.com/armosec/armoapi-go/identifiers" ) var ReporterHttpClient httputils.IHttpClient @@ -19,7 +19,7 @@ var ReporterHttpClient httputils.IHttpClient func NewSessionObj(ctx context.Context, command *apis.Command, message, parentID, jobID string, actionNumber int) *SessionObj { reporter := reporterlib.NewBaseReport(ClusterConfig.AccountID, message, ClusterConfig.EventReceiverRestURL, ReporterHttpClient) target := command.GetID() - if target == apitypes.DesignatorsToken { + if target == identifiers.DesignatorsToken { target = fmt.Sprintf("wlid://cluster-%s/", ClusterConfig.ClusterName) } if target == "" {