@@ -23,7 +23,7 @@ package config
2323
2424import (
2525 "github.com/rabbitstack/fibratus/pkg/event"
26- "golang.org/x/sys/windows "
26+ "github.com/rabbitstack/fibratus/pkg/util/bitmask "
2727 "runtime"
2828 "time"
2929
@@ -102,7 +102,8 @@ type EventSourceConfig struct {
102102 // ExcludedImages are process image names that will be rejected if they generate a kernel event.
103103 ExcludedImages []string `json:"blacklist.images" yaml:"blacklist.images"`
104104
105- dropMasks event.EventsetMasks
105+ dropMasks * bitmask.Bitmask
106+ allMasks * bitmask.Bitmask
106107
107108 excludedImages map [string ]bool
108109}
@@ -127,13 +128,21 @@ func (c *EventSourceConfig) initFromViper(v *viper.Viper) {
127128 c .ExcludedEvents = v .GetStringSlice (excludedEvents )
128129 c .ExcludedImages = v .GetStringSlice (excludedImages )
129130
131+ c .dropMasks = bitmask .New ()
132+ c .allMasks = bitmask .New ()
133+
130134 c .excludedImages = make (map [string ]bool )
131135
132136 for _ , name := range c .ExcludedEvents {
133137 if typ := event .NameToType (name ); typ != event .UnknownType {
134- c .dropMasks .Set (typ )
138+ c .dropMasks .Set (typ . ID () )
135139 }
136140 }
141+
142+ for _ , typ := range event .AllWithState () {
143+ c .allMasks .Set (typ .ID ())
144+ }
145+
137146 for _ , name := range c .ExcludedImages {
138147 c .excludedImages [name ] = true
139148 }
@@ -142,35 +151,54 @@ func (c *EventSourceConfig) initFromViper(v *viper.Viper) {
142151// Init is an exported method to allow initializing exclusion maps from external modules.
143152func (c * EventSourceConfig ) Init () {
144153 c .excludedImages = make (map [string ]bool )
154+
155+ if c .dropMasks == nil {
156+ c .dropMasks = bitmask .New ()
157+ }
145158 for _ , name := range c .ExcludedEvents {
146159 for _ , typ := range event .NameToTypes (name ) {
147160 if typ != event .UnknownType {
148- c .dropMasks .Set (typ )
161+ c .dropMasks .Set (typ . ID () )
149162 }
150163 }
151164 }
165+
152166 for _ , name := range c .ExcludedImages {
153167 c .excludedImages [name ] = true
154168 }
169+
170+ if c .allMasks == nil {
171+ c .allMasks = bitmask .New ()
172+ }
173+ for _ , typ := range event .AllWithState () {
174+ c .allMasks .Set (typ .ID ())
175+ }
155176}
156177
157178// SetDropMask inserts the event mask in the bitset to
158179// instruct the given event type should be dropped from
159180// the event stream.
160- func (c * EventSourceConfig ) SetDropMask (Type event.Type ) {
161- c .dropMasks .Set (Type )
181+ func (c * EventSourceConfig ) SetDropMask (typ event.Type ) {
182+ c .dropMasks .Set (typ . ID () )
162183}
163184
164185// TestDropMask checks if the specified event type has
165186// the drop mask in the bitset.
166- func (c * EventSourceConfig ) TestDropMask (Type event.Type ) bool {
167- return c .dropMasks .Test (Type .GUID (), Type .HookID ())
187+ func (c * EventSourceConfig ) TestDropMask (typ event.Type ) bool {
188+ return c .dropMasks .IsSet (typ .ID ())
189+ }
190+
191+ // ExcludeEvent determines whether the supplied short
192+ // event ID exists in the bitset of excluded events.
193+ func (c * EventSourceConfig ) ExcludeEvent (id uint ) bool {
194+ return c .dropMasks .IsSet (id )
168195}
169196
170- // ExcludeEvent determines whether the supplied provider GUID
171- // and the hook identifier are in the bitset of excluded events.
172- func (c * EventSourceConfig ) ExcludeEvent (guid windows.GUID , hookID uint16 ) bool {
173- return c .dropMasks .Test (guid , hookID )
197+ // EventExists determines if the provided event ID exists
198+ // in the internal event catalog by checking the event ID
199+ // bitmask.
200+ func (c * EventSourceConfig ) EventExists (id uint ) bool {
201+ return c .allMasks .IsSet (id )
174202}
175203
176204// ExcludeImage determines whether the process generating event is present in the
0 commit comments