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

Function TestSequenceBoundFieldsWithFunctions

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

Source from the content-addressed store, hash-verified

1017}
1018
1019func TestSequenceBoundFieldsWithFunctions(t *testing.T) {
1020 log.SetLevel(log.DebugLevel)
1021
1022 maxSequencePartialLifetime = time.Millisecond * 500
1023
1024 c := &config.FilterConfig{Name: "Command shell created a temp file with network outbound"}
1025 f := filter.New(`
1026 sequence
1027 maxspan 5m
1028 |evt.name = 'CreateFile' and file.path imatches '?:\\Windows\\System32\\*.dll'| as e1
1029 |evt.name = 'RegSetValue' and registry.path ~= 'HKEY_CURRENT_USER\\Volatile Environment\\Notification Packages'
1030 and
1031 get_reg_value(registry.path) iin (base($e1.file.path, false))|
1032 `, &config.Config{EventSource: config.EventSourceConfig{EnableFileIOEvents: true, EnableRegistryEvents: true}, Filters: &config.Filters{}})
1033 require.NoError(t, f.Compile())
1034
1035 ss := newSequenceState(f, c, new(ps.SnapshotterMock))
1036
1037 e1 := &event.Event{
1038 Type: event.CreateFile,
1039 Name: "CreateFile",
1040 Category: event.File,
1041 Timestamp: time.Now(),
1042 Tid: 2484,
1043 PID: 859,
1044 PS: &pstypes.PS{
1045 Name: "cmd.exe",
1046 Exe: "C:\\Windows\\system32\\cmd.exe",
1047 },
1048 Params: event.Params{
1049 params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Windows\\System32\\passwdflt.dll"},
1050 },
1051 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
1052 }
1053
1054 e2 := &event.Event{
1055 Type: event.RegSetValue,
1056 Name: "RegSetValue",
1057 Category: event.Registry,
1058 Timestamp: time.Now().Add(time.Millisecond * 5),
1059 Tid: 2484,
1060 PID: 859,
1061 PS: &pstypes.PS{
1062 Name: "cmd.exe",
1063 Exe: "C:\\Windows\\system32\\cmd.exe",
1064 },
1065 Params: event.Params{
1066 params.RegPath: {Name: params.RegPath, Type: params.UnicodeString, Value: "HKEY_CURRENT_USER\\Volatile Environment\\Notification Packages"},
1067 },
1068 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
1069 }
1070
1071 key, err := registry.OpenKey(registry.CURRENT_USER, "Volatile Environment", registry.SET_VALUE)
1072 require.NoError(t, err)
1073 defer key.Close()
1074
1075 defer func() {
1076 _ = key.DeleteValue("Notification Packages")

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
newSequenceStateFunction · 0.85
runSequenceMethod · 0.80
CompileMethod · 0.65
AddMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected