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

Function TestRunSequenceRuleWithPsUUIDLink

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

Source from the content-addressed store, hash-verified

271}
272
273func TestRunSequenceRuleWithPsUUIDLink(t *testing.T) {
274 log.SetLevel(log.DebugLevel)
275
276 e := NewEngine(new(ps.SnapshotterMock), newConfig("_fixtures/sequence_rule_ps_uuid.yml"))
277 compileRules(t, e)
278
279 e1 := &event.Event{
280 Seq: 1,
281 Type: event.CreateProcess,
282 Timestamp: time.Now(),
283 Category: event.Process,
284 Name: "CreateProcess",
285 Tid: 2243,
286 PID: uint32(os.Getpid()),
287 PS: &types.PS{
288 PID: uint32(os.Getpid()),
289 Name: "firefox.exe",
290 Exe: "C:\\Program Files\\Firefox\\firefox.exe",
291 },
292 Params: event.Params{
293 params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(os.Getpid())},
294 params.ProcessName: {Name: params.ProcessName, Type: params.UnicodeString, Value: "firefox.exe"},
295 },
296 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
297 }
298
299 e2 := &event.Event{
300 Seq: 2,
301 Type: event.CreateFile,
302 Timestamp: time.Now().Add(time.Second),
303 Name: "CreateFile",
304 Tid: 2484,
305 PID: uint32(os.Getpid()),
306 Category: event.File,
307 PS: &types.PS{
308 PID: uint32(os.Getpid()),
309 Name: "firefox.exe",
310 Exe: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
311 Cmdline: "C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -contentproc --channel=\"10464.7.539748228\\1366525930\" -childID 6 -isF",
312 },
313 Params: event.Params{
314 params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Temp\\dropper.exe"},
315 params.FileOperation: {Name: params.FileOperation, Type: params.Enum, Value: uint32(2), Enum: fs.FileCreateDispositions},
316 },
317 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
318 }
319
320 require.False(t, wrapProcessEvent(e1, e.ProcessEvent))
321 require.True(t, wrapProcessEvent(e2, e.ProcessEvent))
322}
323
324func TestRunSimpleAndSequenceRules(t *testing.T) {
325 log.SetLevel(log.DebugLevel)

Callers

nothing calls this directly

Calls 5

NewEngineFunction · 0.85
newConfigFunction · 0.85
compileRulesFunction · 0.85
wrapProcessEventFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected