(t *testing.T)
| 322 | } |
| 323 | |
| 324 | func TestRunSimpleAndSequenceRules(t *testing.T) { |
| 325 | log.SetLevel(log.DebugLevel) |
| 326 | |
| 327 | expectedMatches := make(map[string][]uint64) |
| 328 | c := newConfig("_fixtures/simple_and_sequence_rules/*.yml") |
| 329 | c.Filters.MatchAll = true |
| 330 | e := NewEngine(new(ps.SnapshotterMock), c) |
| 331 | e.RegisterMatchFunc(func(f *config.FilterConfig, evts ...*event.Event) { |
| 332 | ids := make([]uint64, 0) |
| 333 | for _, evt := range evts { |
| 334 | ids = append(ids, evt.Seq) |
| 335 | } |
| 336 | expectedMatches[f.Name] = ids |
| 337 | }) |
| 338 | |
| 339 | compileRules(t, e) |
| 340 | |
| 341 | evts := []*event.Event{ |
| 342 | { |
| 343 | Seq: 1, |
| 344 | Type: event.CreateProcess, |
| 345 | Timestamp: time.Now(), |
| 346 | Category: event.Process, |
| 347 | Name: "CreateProcess", |
| 348 | Tid: 2484, |
| 349 | PID: 2243, |
| 350 | PS: &types.PS{ |
| 351 | Name: "powershell.exe", |
| 352 | Exe: "C:\\Windows\\system32\\powershell.exe", |
| 353 | }, |
| 354 | Params: event.Params{ |
| 355 | params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(2243)}, |
| 356 | params.ProcessName: {Name: params.ProcessName, Type: params.UnicodeString, Value: "powershell.exe"}, |
| 357 | }, |
| 358 | Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"}, |
| 359 | }, |
| 360 | { |
| 361 | Seq: 2, |
| 362 | Type: event.CreateFile, |
| 363 | Timestamp: time.Now().Add(time.Millisecond * 544), |
| 364 | Name: "CreateFile", |
| 365 | Tid: 2484, |
| 366 | PID: 2243, |
| 367 | Category: event.File, |
| 368 | PS: &types.PS{ |
| 369 | Name: "cmd.exe", |
| 370 | Exe: "C:\\Windows\\system32\\cmd.exe", |
| 371 | }, |
| 372 | Params: event.Params{ |
| 373 | params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Temp\\dropper.exe"}, |
| 374 | params.FileOperation: {Name: params.FileOperation, Type: params.Enum, Value: uint32(2)}, |
| 375 | }, |
| 376 | Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"}, |
| 377 | }, |
| 378 | { |
| 379 | Seq: 10, |
| 380 | Type: event.CreateProcess, |
| 381 | Timestamp: time.Now().Add(time.Second * 2), |
nothing calls this directly
no test coverage detected