Skip to content

Commit

Permalink
decode strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
NDStrahilevitz committed Oct 16, 2024
1 parent 22d5ea7 commit 114f9a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/bufferdecoder/eventsreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion types/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
Expand Down

0 comments on commit 114f9a8

Please sign in to comment.