Skip to content

Commit

Permalink
fixed pkg changes
Browse files Browse the repository at this point in the history
Signed-off-by: David Wertenteil <[email protected]>
  • Loading branch information
David Wertenteil committed Jul 26, 2023
1 parent e9ca08d commit 39133bd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions mainhandler/handlerequests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 8 additions & 7 deletions mainhandler/vulnscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions mainhandler/vulnscanhandlerhelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions utils/typesutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ 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"
"github.com/kubescape/go-logger"
"github.com/kubescape/go-logger/helpers"

"github.com/armosec/armoapi-go/apis"
"github.com/armosec/armoapi-go/identifiers"
)

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 == "" {
Expand Down

0 comments on commit 39133bd

Please sign in to comment.