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

Function TestUnconstrainedSequenceMatches

pkg/rules/sequence_test.go:382–467  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

380}
381
382func TestUnconstrainedSequenceMatches(t *testing.T) {
383 log.SetLevel(log.DebugLevel)
384
385 c := &config.FilterConfig{Name: "Command shell created a temp file"}
386 f := filter.New(`
387 sequence
388 maxspan 200ms
389 |evt.name = 'CreateProcess' and ps.name = 'cmd.exe'|
390 |evt.name = 'CreateFile' and file.path icontains 'temp'|
391 `, &config.Config{EventSource: config.EventSourceConfig{EnableFileIOEvents: true}, Filters: &config.Filters{}})
392 require.NoError(t, f.Compile())
393
394 ss := newSequenceState(f, c, new(ps.SnapshotterMock))
395
396 e1 := &event.Event{
397 Seq: 20,
398 Type: event.CreateProcess,
399 Timestamp: time.Now().Add(time.Second),
400 Name: "CreateProcess",
401 Tid: 2484,
402 PID: 859,
403 PS: &pstypes.PS{
404 Name: "cmd.exe",
405 Exe: "C:\\Windows\\System32\\cmd.exe",
406 PID: 859,
407 Parent: &pstypes.PS{
408 Name: "WmiPrvSE.exe",
409 },
410 },
411 Params: event.Params{
412 params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(859)},
413 },
414 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
415 }
416 e2 := &event.Event{
417 Seq: 21,
418 Type: event.CreateProcess,
419 Timestamp: time.Now().Add(time.Second * 2),
420 Name: "CreateProcess",
421 Tid: 2484,
422 PID: 1859,
423 PS: &pstypes.PS{
424 Name: "cmd.exe",
425 Exe: "C:\\Windows\\System32\\cmd.exe",
426 PID: 1859,
427 Parent: &pstypes.PS{
428 Name: "svchost.exe",
429 },
430 },
431 Params: event.Params{
432 params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(859)},
433 },
434 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
435 }
436 e3 := &event.Event{
437 Type: event.CreateFile,
438 Seq: 25,
439 Timestamp: time.Now().Add(time.Second * 3),

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
newSequenceStateFunction · 0.85
runSequenceMethod · 0.80
EqualMethod · 0.80
GetParamAsStringMethod · 0.80
CompileMethod · 0.65
AddMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected