MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / processActions

Method processActions

pkg/rules/engine.go:273–308  ·  view source on GitHub ↗

processActions executes rule actions on behalf of rule matches. Actions are categorized into implicit and explicit actions. Sending an alert is an implicit action carried out each time there is a rule match. Other actions are executed if declared in the rule definition.

()

Source from the content-addressed store, hash-verified

271// match. Other actions are executed if
272// declared in the rule definition.
273func (e *Engine) processActions() error {
274 defer e.clearMatches()
275 e.mmu.Lock()
276 defer e.mmu.Unlock()
277 for _, m := range e.matches {
278 f, evts := m.ctx.Filter, m.ctx.Events
279 filterMatches.Add(f.Name, 1)
280 log.Debugf("[%s] rule matched", f.Name)
281 err := action.Alert(m.ctx, f.Name, filter.InterpolateFields(f.Output, evts), f.Severity, f.Tags)
282 if err != nil {
283 return ErrRuleAction(f.Name, err)
284 }
285
286 actions, err := f.DecodeActions()
287 if err != nil {
288 return err
289 }
290
291 for _, act := range actions {
292 switch t := act.(type) {
293 case config.KillAction:
294 log.Infof("executing kill action: pids=%v rule=%s", m.ctx.UniquePids(), f.Name)
295 if err := action.Kill(m.ctx.UniquePids()); err != nil {
296 return ErrRuleAction(f.Name, err)
297 }
298 case config.IsolateAction:
299 log.Infof("executing isolate action: rule=%s", f.Name)
300 if err := action.Isolate(t.Whitelist); err != nil {
301 return ErrRuleAction(f.Name, err)
302 }
303 }
304 }
305 }
306
307 return nil
308}
309
310func (e *Engine) appendMatch(f *config.FilterConfig, evts ...*event.Event) {
311 for _, evt := range evts {

Callers 1

ProcessEventMethod · 0.95

Calls 10

clearMatchesMethod · 0.95
AlertFunction · 0.92
InterpolateFieldsFunction · 0.92
KillFunction · 0.92
IsolateFunction · 0.92
LockMethod · 0.80
UnlockMethod · 0.80
DecodeActionsMethod · 0.80
UniquePidsMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected