Skip to content

Commit

Permalink
feature: add signature name to event definition
Browse files Browse the repository at this point in the history
  • Loading branch information
josedonizetti committed Dec 6, 2023
1 parent 75908ae commit 3313d6f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions go.mod
Expand Up @@ -178,3 +178,5 @@ require (
)

replace github.com/kubernetes/cri-api => k8s.io/cri-api v0.23.5-rc.0

replace github.com/josedonizetti/tracee/api => github.com/josedonizetti/tracee/api v0.0.0-20231206154405-5e2999eaa468
3 changes: 3 additions & 0 deletions pkg/cmd/initialize/sigs.go
Expand Up @@ -70,6 +70,9 @@ func CreateEventsFromSignatures(startId events.ID, sigs []detect.Signature) {
events.Capabilities{},
),
[]trace.ArgMeta{},
map[string]string{
"signatureName": m.Name,
},
)

err = events.Core.Add(newEventDefID, newEventDef)
Expand Down
7 changes: 7 additions & 0 deletions pkg/events/definition.go
Expand Up @@ -16,6 +16,7 @@ type Definition struct {
dependencies Dependencies
sets []string
params []trace.ArgMeta
labels map[string]string
}

func NewDefinition(
Expand All @@ -30,6 +31,7 @@ func NewDefinition(
sets []string,
deps Dependencies,
params []trace.ArgMeta,
labels map[string]string,
) Definition {
return Definition{
id: id,
Expand All @@ -43,6 +45,7 @@ func NewDefinition(
dependencies: deps,
sets: sets,
params: params,
labels: labels,
}
}

Expand Down Expand Up @@ -107,3 +110,7 @@ func (d Definition) IsNetwork() bool {

return false
}

func (d Definition) GetLabels() map[string]string {
return d.labels
}
11 changes: 11 additions & 0 deletions pkg/server/grpc/tracee.go
Expand Up @@ -120,12 +120,23 @@ func convertDefinitionToProto(d events.Definition) *pb.EventDefinition {
Patch: d.GetVersion().Patch(),
}

var labels map[string]string
if lbls := d.GetLabels(); lbls != nil {
name, ok := lbls["signatureName"]
if !ok {
labels = map[string]string{
"signatureName": name,
}
}
}

return &pb.EventDefinition{
Id: int32(d.GetID()),
Name: d.GetName(),
Version: v,
Description: d.GetDescription(),
Tags: d.GetSets(),
Labels: labels,
}
}

Expand Down

0 comments on commit 3313d6f

Please sign in to comment.