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

Function TestSequenceGC

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

Source from the content-addressed store, hash-verified

739}
740
741func TestSequenceGC(t *testing.T) {
742 log.SetLevel(log.DebugLevel)
743
744 maxSequencePartialLifetime = time.Millisecond * 500
745
746 c := &config.FilterConfig{Name: "LSASS memory dumping via legitimate or offensive tools"}
747 f := filter.New(`
748 sequence
749 by ps.uuid
750 |evt.name = 'OpenProcess' and evt.arg[exe] imatches '?:\\Windows\\System32\\lsass.exe'|
751 |evt.name = 'CreateFile' and file.operation = 'CREATE' and file.extension = '.dmp'|
752 `, &config.Config{EventSource: config.EventSourceConfig{EnableFileIOEvents: true}, Filters: &config.Filters{}})
753 require.NoError(t, f.Compile())
754
755 ss := newSequenceState(f, c, new(ps.SnapshotterMock))
756
757 e := &event.Event{
758 Type: event.OpenProcess,
759 Timestamp: time.Now(),
760 Name: "OpenProcess",
761 Tid: 2484,
762 PID: 859,
763 PS: &pstypes.PS{
764 Name: "cmd.exe",
765 Exe: "C:\\Windows\\system32\\rundll32.exe",
766 },
767 Params: event.Params{
768 params.Exe: {Name: params.Exe, Type: params.UnicodeString, Value: "C:\\Windows\\System32\\lsass.exe"},
769 params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(2243)},
770 params.DesiredAccess: {Name: params.DesiredAccess, Type: params.Flags, Value: uint32(0x1400), Flags: event.PsAccessRightFlags},
771 },
772 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
773 }
774
775 require.False(t, ss.runSequence(e))
776 assert.Len(t, ss.partials[0], 1)
777
778 time.Sleep(time.Second)
779
780 ss.gc()
781
782 assert.Len(t, ss.partials[0], 0)
783}
784
785func TestSequenceExpire(t *testing.T) {
786 log.SetLevel(log.DebugLevel)

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
newSequenceStateFunction · 0.85
runSequenceMethod · 0.80
gcMethod · 0.80
CompileMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected