From 114f9a844e167c518a82af045fc0b8028f20b8da Mon Sep 17 00:00:00 2001 From: Nadav Strahilevitz Date: Wed, 16 Oct 2024 11:41:03 +0000 Subject: [PATCH] decode strategies --- pkg/bufferdecoder/eventsreader.go | 6 ++++-- types/trace/trace.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/bufferdecoder/eventsreader.go b/pkg/bufferdecoder/eventsreader.go index ca8d42593656..7af153d3cbcb 100644 --- a/pkg/bufferdecoder/eventsreader.go +++ b/pkg/bufferdecoder/eventsreader.go @@ -13,6 +13,8 @@ import ( "github.com/aquasecurity/tracee/types/trace" ) +var decodeStrategies map[trace.DecodeAs]func() + // readArgFromBuff read the next argument from the buffer. // Return the index of the argument and the parsed argument. func readArgFromBuff(id events.ID, ebpfMsgDecoder *EbpfDecoder, params []trace.ArgMeta, @@ -32,7 +34,7 @@ func readArgFromBuff(id events.ID, ebpfMsgDecoder *EbpfDecoder, params []trace.A return 0, arg, errfmt.Errorf("invalid arg index %d", argIdx) } arg.ArgMeta = params[argIdx] - argType := GetParamType(arg.Type) + argType := GetDecodeType(arg.Type) switch argType { case trace.U8_T: @@ -161,7 +163,7 @@ func readArgFromBuff(id events.ID, ebpfMsgDecoder *EbpfDecoder, params []trace.A return uint(argIdx), arg, nil } -func GetParamType(paramType string) trace.DecodeAs { +func GetDecodeType(paramType string) trace.DecodeAs { switch paramType { case "int": return trace.INT_T diff --git a/types/trace/trace.go b/types/trace/trace.go index 708df9e9d6e0..11b37c855e33 100644 --- a/types/trace/trace.go +++ b/types/trace/trace.go @@ -184,7 +184,7 @@ type ArgMeta struct { Type string `json:"type"` // DecodeAs includes designates the decoding strategy. - DecodeAs DecodeAs `json: "-` + DecodeAs DecodeAs `json:"-"` // Zero contains the zero value for Argument.Value. // It is automatically initialized based on ArgMeta.Type when the Core DefinitionGroup is initialized. Zero interface{} `json:"-"`