github.com/DataDog/datadog-agent/pkg/security/secl@v0.55.0-devel.0.20240517055856-10c4965fea94/compiler/eval/event.go (about) 1 // Unless explicitly stated otherwise all files in this repository are licensed 2 // under the Apache License Version 2.0. 3 // This product includes software developed at Datadog (https://www.datadoghq.com/). 4 // Copyright 2016-present Datadog, Inc. 5 6 // Package eval holds eval related files 7 package eval 8 9 import ( 10 "reflect" 11 ) 12 13 // EventType is the type of an event 14 type EventType = string 15 16 // Event is an interface that an Event has to implement for the evaluation 17 type Event interface { 18 // Init initialize the event 19 Init() 20 // GetType returns the Type of the Event 21 GetType() EventType 22 // GetFieldEventType returns the Event Type for the given Field 23 GetFieldEventType(field Field) (EventType, error) 24 // SetFieldValue sets the value of the given Field 25 SetFieldValue(field Field, value interface{}) error 26 // GetFieldValue returns the value of the given Field 27 GetFieldValue(field Field) (interface{}, error) 28 // GetFieldType returns the Type of the Field 29 GetFieldType(field Field) (reflect.Kind, error) 30 // GetTags returns a list of tags 31 GetTags() []string 32 } 33 34 func eventTypesFromFields(model Model, state *State) ([]EventType, error) { 35 events := make(map[EventType]bool) 36 for field := range state.fieldValues { 37 eventType, err := model.NewEvent().GetFieldEventType(field) 38 if err != nil { 39 return nil, err 40 } 41 42 if eventType != "*" { 43 events[eventType] = true 44 } 45 } 46 47 var uniq []string 48 for event := range events { 49 uniq = append(uniq, event) 50 } 51 return uniq, nil 52 }