From 745187f7e3895bc74253990c8cae9e307bd2593c Mon Sep 17 00:00:00 2001 From: Panos Koutsovasilis Date: Wed, 3 Apr 2024 23:30:55 +0300 Subject: [PATCH] fix(fim/ebpf): remove x-pack import from OSS package --- libbeat/ebpf/sys/sys.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libbeat/ebpf/sys/sys.go b/libbeat/ebpf/sys/sys.go index 2d1d101e66b9..4156321a3214 100644 --- a/libbeat/ebpf/sys/sys.go +++ b/libbeat/ebpf/sys/sys.go @@ -20,11 +20,12 @@ package sys import ( + "crypto/sha256" + "encoding/base64" "encoding/binary" "sync" "time" - "github.com/elastic/beats/v7/x-pack/auditbeat/module/system" "github.com/elastic/go-sysinfo" "github.com/elastic/go-sysinfo/types" ) @@ -48,7 +49,7 @@ func EntityID(pid uint32, start time.Time) (string, error) { return "", err } - h := system.NewEntityHash() + h := sha256.New() if _, err := h.Write([]byte(info.UniqueID)); err != nil { return "", err } @@ -59,5 +60,9 @@ func EntityID(pid uint32, start time.Time) (string, error) { return "", err } - return h.Sum(), nil + sum := h.Sum(nil) + if len(sum) > 12 { + sum = sum[:12] + } + return base64.RawStdEncoding.EncodeToString(sum), nil }