@@ -58,10 +58,11 @@ func TestSequenceState(t *testing.T) {
5858 assert .Equal (t , "evt.name = CreateProcess AND ps.name = cmd.exe" , ss .expr (ss .initialState ))
5959
6060 e1 := & event.Event {
61- Type : event .CreateProcess ,
62- Name : "CreateProcess" ,
63- Tid : 2484 ,
64- PID : 859 ,
61+ Type : event .CreateProcess ,
62+ Name : "CreateProcess" ,
63+ Tid : 2484 ,
64+ PID : 859 ,
65+ Timestamp : time .Now (),
6566 PS : & pstypes.PS {
6667 Name : "cmd.exe" ,
6768 Exe : "C:\\ Windows\\ system32\\ svchost.exe" ,
@@ -71,6 +72,22 @@ func TestSequenceState(t *testing.T) {
7172 params .ProcessName : {Name : params .ProcessName , Type : params .AnsiString , Value : "powershell.exe" },
7273 },
7374 }
75+
76+ e2 := & event.Event {
77+ Type : event .CreateFile ,
78+ Name : "CreateFile" ,
79+ Tid : 2484 ,
80+ PID : 4143 ,
81+ Timestamp : time .Now ().Add (time .Second * 5 ),
82+ PS : & pstypes.PS {
83+ Name : "cmd.exe" ,
84+ Exe : "C:\\ Windows\\ system32\\ svchost.exe" ,
85+ },
86+ Params : event.Params {
87+ params .FilePath : {Name : params .FilePath , Type : params .UnicodeString , Value : "C:\\ Temp\\ dropper" },
88+ },
89+ }
90+
7491 require .True (t , ss .next (0 ))
7592 require .False (t , ss .next (1 ))
7693 require .NoError (t , ss .matchTransition (0 , e1 ))
@@ -82,19 +99,17 @@ func TestSequenceState(t *testing.T) {
8299 assert .False (t , ss .isInitialState ())
83100 assert .Equal (t , "evt.name = CreateFile AND file.path ICONTAINS temp" , ss .expr (ss .currentState ()))
84101
85- e2 := & event.Event {
86- Type : event .CreateFile ,
87- Name : "CreateFile" ,
88- Tid : 2484 ,
89- PID : 4143 ,
90- PS : & pstypes.PS {
91- Name : "cmd.exe" ,
92- Exe : "C:\\ Windows\\ system32\\ svchost.exe" ,
93- },
102+ e3 := & event.Event {
103+ Type : event .CreateProcess ,
104+ Name : "CreateProcess" ,
105+ Timestamp : time .Now ().Add (time .Second * 10 ),
106+ Tid : 2484 ,
107+ PID : 4143 ,
94108 Params : event.Params {
95- params .FilePath : {Name : params .FilePath , Type : params .UnicodeString , Value : "C:\\ Temp\\ dropper" },
109+ params .Exe : {Name : params .Exe , Type : params .UnicodeString , Value : "C:\\ Temp\\ dropper.exe " },
96110 },
97111 }
112+
98113 // can't go to the next transitions as the expr hasn't matched
99114 require .False (t , ss .next (2 ))
100115 require .NoError (t , ss .matchTransition (1 , e2 ))
@@ -108,15 +123,6 @@ func TestSequenceState(t *testing.T) {
108123 assert .Equal (t , 2 , ss .currentState ())
109124 assert .Equal (t , "evt.name = CreateProcess" , ss .expr (ss .currentState ()))
110125
111- e3 := & event.Event {
112- Type : event .CreateProcess ,
113- Name : "CreateProcess" ,
114- Tid : 2484 ,
115- PID : 4143 ,
116- Params : event.Params {
117- params .Exe : {Name : params .Exe , Type : params .UnicodeString , Value : "C:\\ Temp\\ dropper.exe" },
118- },
119- }
120126 require .NoError (t , ss .matchTransition (2 , e3 ))
121127 ss .addPartial (2 , e3 , false )
122128
@@ -214,7 +220,7 @@ func TestSimpleSequence(t *testing.T) {
214220 }, {
215221 Type : event .CreateFile ,
216222 Name : "CreateFile" ,
217- Timestamp : time .Now (),
223+ Timestamp : time .Now (). Add ( time . Second ) ,
218224 Tid : 2484 ,
219225 PID : 859 ,
220226 Category : event .File ,
@@ -242,7 +248,7 @@ func TestSimpleSequence(t *testing.T) {
242248 }, {
243249 Type : event .CreateFile ,
244250 Name : "CreateFile" ,
245- Timestamp : time .Now (),
251+ Timestamp : time .Now (). Add ( time . Second ) ,
246252 Tid : 2484 ,
247253 PID : 859 ,
248254 Category : event .File ,
@@ -410,7 +416,7 @@ func TestUnconstrainedSequenceMatches(t *testing.T) {
410416 e2 := & event.Event {
411417 Seq : 21 ,
412418 Type : event .CreateProcess ,
413- Timestamp : time .Now ().Add (time .Second ),
419+ Timestamp : time .Now ().Add (time .Second * 2 ),
414420 Name : "CreateProcess" ,
415421 Tid : 2484 ,
416422 PID : 1859 ,
@@ -430,7 +436,7 @@ func TestUnconstrainedSequenceMatches(t *testing.T) {
430436 e3 := & event.Event {
431437 Type : event .CreateFile ,
432438 Seq : 25 ,
433- Timestamp : time .Now ().Add (time .Second * time . Duration ( 2 ) ),
439+ Timestamp : time .Now ().Add (time .Second * 3 ),
434440 Name : "CreateFile" ,
435441 Tid : 2484 ,
436442 PID : 3859 ,
@@ -493,7 +499,7 @@ func TestSimpleSequenceDeadline(t *testing.T) {
493499
494500 e2 := & event.Event {
495501 Type : event .CreateFile ,
496- Timestamp : time .Now (),
502+ Timestamp : time .Now (). Add ( time . Millisecond * 200 ) ,
497503 Name : "CreateFile" ,
498504 Tid : 2484 ,
499505 PID : 859 ,
@@ -563,7 +569,7 @@ func TestSequenceMultiLinks(t *testing.T) {
563569
564570 e2 := & event.Event {
565571 Type : event .CreateFile ,
566- Timestamp : time .Now (),
572+ Timestamp : time .Now (). Add ( time . Second ) ,
567573 Name : "CreateFile" ,
568574 Tid : 2484 ,
569575 PID : 859 ,
@@ -856,7 +862,7 @@ func TestSequenceExpire(t *testing.T) {
856862 {
857863 Seq : 2 ,
858864 Type : event .CreateProcess ,
859- Timestamp : time .Now (),
865+ Timestamp : time .Now (). Add ( time . Second ) ,
860866 Category : event .Process ,
861867 Name : "CreateProcess" ,
862868 Tid : 2484 ,
@@ -1029,11 +1035,12 @@ func TestSequenceBoundFieldsWithFunctions(t *testing.T) {
10291035 ss := newSequenceState (f , c , new (ps.SnapshotterMock ))
10301036
10311037 e1 := & event.Event {
1032- Type : event .CreateFile ,
1033- Name : "CreateFile" ,
1034- Category : event .File ,
1035- Tid : 2484 ,
1036- PID : 859 ,
1038+ Type : event .CreateFile ,
1039+ Name : "CreateFile" ,
1040+ Category : event .File ,
1041+ Timestamp : time .Now (),
1042+ Tid : 2484 ,
1043+ PID : 859 ,
10371044 PS : & pstypes.PS {
10381045 Name : "cmd.exe" ,
10391046 Exe : "C:\\ Windows\\ system32\\ cmd.exe" ,
@@ -1045,11 +1052,12 @@ func TestSequenceBoundFieldsWithFunctions(t *testing.T) {
10451052 }
10461053
10471054 e2 := & event.Event {
1048- Type : event .RegSetValue ,
1049- Name : "RegSetValue" ,
1050- Category : event .Registry ,
1051- Tid : 2484 ,
1052- PID : 859 ,
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 ,
10531061 PS : & pstypes.PS {
10541062 Name : "cmd.exe" ,
10551063 Exe : "C:\\ Windows\\ system32\\ cmd.exe" ,
0 commit comments