Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Fix two panics #10

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions protobuf/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions protobuf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file removed protobuf/bin/protoc
Binary file not shown.
9 changes: 6 additions & 3 deletions sentryflow/core/k8sHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ 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"
"k8s.io/apimachinery/pkg/fields"
"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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down
1 change: 1 addition & 0 deletions sentryflow/core/sentryflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
7 changes: 6 additions & 1 deletion sentryflow/exporter/aiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading