(t *testing.T)
| 739 | } |
| 740 | |
| 741 | func 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 | |
| 785 | func TestSequenceExpire(t *testing.T) { |
| 786 | log.SetLevel(log.DebugLevel) |
nothing calls this directly
no test coverage detected