diff --git a/protobuf/.gitignore b/protobuf/.gitignore deleted file mode 100644 index 5a14467..0000000 --- a/protobuf/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.idea/ -*.tar \ No newline at end of file diff --git a/protobuf/Makefile b/protobuf/Makefile index f3adba0..7f037d1 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -14,8 +14,3 @@ go.sum: go.mod .PHONY: clean clean: rm -f go.sum *.pb.go - -.PHONY: deps -deps: - sudo cp bin/protoc /usr/local/bin/ - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest diff --git a/protobuf/bin/protoc b/protobuf/bin/protoc deleted file mode 100755 index 51376bc..0000000 Binary files a/protobuf/bin/protoc and /dev/null differ diff --git a/sentryflow/core/k8sHandler.go b/sentryflow/core/k8sHandler.go index 07f7931..193af0d 100644 --- a/sentryflow/core/k8sHandler.go +++ b/sentryflow/core/k8sHandler.go @@ -8,8 +8,6 @@ import ( "sync" "time" - "github.com/5GSEC/SentryFlow/config" - "github.com/5GSEC/SentryFlow/types" "gopkg.in/yaml.v2" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,6 +15,9 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" + + "github.com/5GSEC/SentryFlow/config" + "github.com/5GSEC/SentryFlow/types" ) // K8s global reference for Kubernetes Handler @@ -101,6 +102,7 @@ func (kh *K8sHandler) initExistingResources() { podList, err := kh.clientSet.CoreV1().Pods(corev1.NamespaceAll).List(context.TODO(), v1.ListOptions{}) if err != nil { log.Print("Error listing Pods:", err.Error()) + return } // Add existing Pods to the podMap @@ -114,6 +116,7 @@ func (kh *K8sHandler) initExistingResources() { serviceList, err := kh.clientSet.CoreV1().Services(corev1.NamespaceAll).List(context.TODO(), v1.ListOptions{}) if err != nil { log.Print("Error listing Services:", err.Error()) + return } // Add existing Services to the svcMap @@ -414,7 +417,7 @@ func (kh *K8sHandler) PatchIstioConfigMap() error { // Append eps to the existing slice if !duplicate { - meshConfig["extensionProviders"] = append(ep.([]map[interface{}]interface{}), eps) + meshConfig["extensionProviders"] = append(ep.([]interface{}), eps) } } diff --git a/sentryflow/core/sentryflow.go b/sentryflow/core/sentryflow.go index d759c06..969f157 100644 --- a/sentryflow/core/sentryflow.go +++ b/sentryflow/core/sentryflow.go @@ -138,6 +138,7 @@ func SentryFlow() { if !exporter.AH.InitAIHandler() { log.Printf("[Error] Failed to initialize AI Engine") + return } log.Printf("[SentryFlow] Successfuly initialized AI Engine") diff --git a/sentryflow/exporter/aiHandler.go b/sentryflow/exporter/aiHandler.go index 97fb773..14a668e 100644 --- a/sentryflow/exporter/aiHandler.go +++ b/sentryflow/exporter/aiHandler.go @@ -8,10 +8,11 @@ import ( "io" "log" + "google.golang.org/grpc" + cfg "github.com/5GSEC/SentryFlow/config" "github.com/5GSEC/SentryFlow/protobuf" "github.com/5GSEC/SentryFlow/types" - "google.golang.org/grpc" ) // AH Local reference for AI handler server @@ -74,6 +75,10 @@ func (ah *aiHandler) InitAIHandler() bool { client := protobuf.NewSentryFlowMetricsClient(conn) aiStream, err := client.GetAPIClassification(context.Background()) + if err != nil { + log.Printf("[gRPC] Error getting API classification: %v", err) + return false + } AH.aiStream = &streamInform{ aiStream: aiStream,