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

Function TestRunSequenceRule

pkg/rules/engine_test.go:183–271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func TestRunSequenceRule(t *testing.T) {
184 log.SetLevel(log.DebugLevel)
185
186 e := NewEngine(new(ps.SnapshotterMock), newConfig("_fixtures/sequence_rule_complex.yml"))
187 compileRules(t, e)
188
189 e1 := &event.Event{
190 Seq: 1,
191 Type: event.CreateProcess,
192 Timestamp: time.Now(),
193 Category: event.Process,
194 Name: "CreateProcess",
195 Tid: 2484,
196 PID: 2243,
197 PS: &types.PS{
198 Name: "firefox.exe",
199 Exe: "C:\\Program Files\\Firefox\\firefox.exe",
200 },
201 Params: event.Params{
202 params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(2243)},
203 params.ProcessName: {Name: params.ProcessName, Type: params.UnicodeString, Value: "firefox.exe"},
204 },
205 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
206 }
207
208 e2 := &event.Event{
209 Seq: 2,
210 Type: event.CreateFile,
211 Timestamp: time.Now().Add(time.Millisecond * 250),
212 Name: "CreateFile",
213 Tid: 2484,
214 PID: 2243,
215 Category: event.File,
216 PS: &types.PS{
217 Name: "firefox.exe",
218 Exe: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
219 Cmdline: "C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -contentproc --channel=\"10464.7.539748228\\1366525930\" -childID 6 -isF",
220 },
221 Params: event.Params{
222 params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Temp\\dropper.exe"},
223 params.FileOperation: {Name: params.FileOperation, Type: params.Enum, Value: uint32(2), Enum: fs.FileCreateDispositions},
224 },
225 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
226 }
227
228 e3 := &event.Event{
229 Seq: 4,
230 Type: event.ConnectTCPv4,
231 Timestamp: time.Now().Add(time.Second),
232 Category: event.Net,
233 Name: "Connect",
234 Tid: 244,
235 PID: 2243,
236 PS: &types.PS{
237 Name: "firefox.exe",
238 Exe: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
239 Cmdline: "C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -contentproc --channel=\"10464.7.539748228\\1366525930\" -childID 6 -isF",
240 },

Callers

nothing calls this directly

Calls 8

LoadAllFunction · 0.92
NewEngineFunction · 0.85
newConfigFunction · 0.85
compileRulesFunction · 0.85
wrapProcessEventFunction · 0.85
EqualMethod · 0.80
AddMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected