From 7f767ba6808e1bef21f083b7b0d3e01e6db82a38 Mon Sep 17 00:00:00 2001 From: Prateeknandle Date: Tue, 13 Jun 2023 18:17:52 +0530 Subject: [PATCH] handling empty owner field Signed-off-by: Prateeknandle --- KubeArmor/feeder/feeder.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/KubeArmor/feeder/feeder.go b/KubeArmor/feeder/feeder.go index cab17a8af0..ab99828a6c 100644 --- a/KubeArmor/feeder/feeder.go +++ b/KubeArmor/feeder/feeder.go @@ -602,17 +602,17 @@ func (fd *Feeder) PushLog(log tp.Log) { pbAlert.NamespaceName = log.NamespaceName - var o *pb.Podowner - if log.Owner != nil { - o = &pb.Podowner{ + var owner *pb.Podowner + if log.Owner != nil && (log.Owner.Ref != "" || log.Owner.Name != "" || log.Owner.Namespace != "") { + owner = &pb.Podowner{ Ref: log.Owner.Ref, Name: log.Owner.Name, Namespace: log.Owner.Namespace, } } - if pbAlert.Owner == nil { - pbAlert.Owner = o + if pbAlert.Owner == nil && owner != nil { + pbAlert.Owner = owner } pbAlert.PodName = log.PodName @@ -688,17 +688,17 @@ func (fd *Feeder) PushLog(log tp.Log) { pbLog.NamespaceName = log.NamespaceName - var o *pb.Podowner - if log.Owner != nil { - o = &pb.Podowner{ + var owner *pb.Podowner + if log.Owner != nil && (log.Owner.Ref != "" || log.Owner.Name != "" || log.Owner.Namespace != "") { + owner = &pb.Podowner{ Ref: log.Owner.Ref, Name: log.Owner.Name, Namespace: log.Owner.Namespace, } } - if pbLog.Owner == nil { - pbLog.Owner = o + if pbLog.Owner == nil && owner != nil { + pbLog.Owner = owner } pbLog.PodName = log.PodName