(t *testing.T)
| 537 | } |
| 538 | |
| 539 | func TestSequenceMultiLinks(t *testing.T) { |
| 540 | log.SetLevel(log.DebugLevel) |
| 541 | |
| 542 | c := &config.FilterConfig{Name: "Command shell created a temp file"} |
| 543 | f := filter.New(` |
| 544 | sequence |
| 545 | maxspan 100ms |
| 546 | |evt.name = 'CreateProcess' and ps.name = 'cmd.exe'| by ps.exe, ps.pid |
| 547 | |evt.name = 'CreateFile' and file.path icontains 'temp'| by file.path, ps.pid |
| 548 | `, &config.Config{EventSource: config.EventSourceConfig{EnableFileIOEvents: true}, Filters: &config.Filters{}}) |
| 549 | require.NoError(t, f.Compile()) |
| 550 | |
| 551 | ss := newSequenceState(f, c, new(ps.SnapshotterMock)) |
| 552 | |
| 553 | e1 := &event.Event{ |
| 554 | Type: event.CreateProcess, |
| 555 | Timestamp: time.Now(), |
| 556 | Name: "CreateProcess", |
| 557 | Tid: 2484, |
| 558 | PID: 859, |
| 559 | PS: &pstypes.PS{ |
| 560 | Name: "cmd.exe", |
| 561 | Exe: "C:\\Windows\\system32\\svchost-temp.exe", |
| 562 | }, |
| 563 | Params: event.Params{ |
| 564 | params.ProcessID: {Name: params.ProcessID, Type: params.Uint32, Value: uint32(4143)}, |
| 565 | }, |
| 566 | Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"}, |
| 567 | } |
| 568 | require.False(t, ss.runSequence(e1)) |
| 569 | |
| 570 | e2 := &event.Event{ |
| 571 | Type: event.CreateFile, |
| 572 | Timestamp: time.Now().Add(time.Second), |
| 573 | Name: "CreateFile", |
| 574 | Tid: 2484, |
| 575 | PID: 859, |
| 576 | Category: event.File, |
| 577 | PS: &pstypes.PS{ |
| 578 | Name: "cmd.exe", |
| 579 | Exe: "C:\\Windows\\system32\\svchost.exe", |
| 580 | }, |
| 581 | Params: event.Params{ |
| 582 | params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Windows\\system32\\svchost-temp.exe"}, |
| 583 | }, |
| 584 | Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"}, |
| 585 | } |
| 586 | require.True(t, ss.runSequence(e2)) |
| 587 | } |
| 588 | |
| 589 | func TestComplexSequence(t *testing.T) { |
| 590 | log.SetLevel(log.DebugLevel) |
nothing calls this directly
no test coverage detected