forked from kai-ten/go-csf-schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_test.go
64 lines (58 loc) · 1.36 KB
/
process_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package gcs
import (
"testing"
"time"
)
func TestValidProcessObject(t *testing.T) {
ts := time.Now()
process := &Process{
CommandLine: "ssh [email protected]",
CreatedTimed: &ts,
File: nil,
Integrity: "Windows",
IntegrityLevel: 99,
Lineage: []string{"/usr/sbin/sshd"},
LoadedModules: []string{"Docker"},
Name: "Docker",
ParentProcess: nil,
ProcessID: 3899,
ProcessUID: "Docker",
Sandbox: "default_ps",
TerminatedTime: &ts,
ThreadID: 123,
User: nil,
UserSession: nil,
}
_, err := ValidateProcess(process)
if err != nil {
t.Fatalf("Process object should be valid: %v", err)
}
}
func BenchmarkValidProcessObject(b *testing.B) {
b.ReportAllocs()
ts := time.Now()
process := &Process{
CommandLine: "ssh [email protected]",
CreatedTimed: &ts,
File: nil,
Integrity: "Windows",
IntegrityLevel: 99,
Lineage: []string{"/usr/sbin/sshd"},
LoadedModules: []string{"Docker"},
Name: "Docker",
ParentProcess: nil,
ProcessID: 3899,
ProcessUID: "Docker",
Sandbox: "default_ps",
TerminatedTime: &ts,
ThreadID: 123,
User: nil,
UserSession: nil,
}
for n := 0; n < b.N; n++ {
_, err := ValidateProcess(process)
if err != nil {
b.Fatalf("Policy object is invalid: %v", err)
}
}
}