-
Notifications
You must be signed in to change notification settings - Fork 129
/
checks.go
68 lines (63 loc) · 2.06 KB
/
checks.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
65
66
67
68
package posture
import (
"github.com/openziti/sdk-golang/pb/edge_client_pb"
"github.com/openziti/ziti/common/pb/edge_ctrl_pb"
"time"
)
type Cache struct {
Os *edge_client_pb.PostureResponse_Os
Domain *edge_client_pb.PostureResponse_Domain
Macs *edge_client_pb.PostureResponse_Macs
Unlocked *edge_client_pb.PostureResponse_Unlocked
Woken *edge_client_pb.PostureResponse_Woken
ProcessList *edge_client_pb.PostureResponse_ProcessList
PassedMfaAt *time.Time
}
type Check interface {
Evaluate(state *Cache) *CheckError
}
func CtrlCheckToLogic(postureCheck *edge_ctrl_pb.DataState_PostureCheck) Check {
switch subCheck := postureCheck.Subtype.(type) {
case *edge_ctrl_pb.DataState_PostureCheck_Mac_:
return &MacCheck{
DataState_PostureCheck: postureCheck,
DataState_PostureCheck_Mac: subCheck.Mac,
}
case *edge_ctrl_pb.DataState_PostureCheck_OsList_:
return &OsCheck{
DataState_PostureCheck: postureCheck,
DataState_PostureCheck_OsList: subCheck.OsList,
}
case *edge_ctrl_pb.DataState_PostureCheck_Process_:
return &ProcessCheck{
DataState_PostureCheck: postureCheck,
DataState_PostureCheck_ProcessMulti: &edge_ctrl_pb.DataState_PostureCheck_ProcessMulti{
Semantic: "AllOf",
Processes: []*edge_ctrl_pb.DataState_PostureCheck_Process{
{
OsType: subCheck.Process.OsType,
Path: subCheck.Process.Path,
Hashes: subCheck.Process.Hashes,
Fingerprints: subCheck.Process.Fingerprints,
},
},
},
}
case *edge_ctrl_pb.DataState_PostureCheck_ProcessMulti_:
return &ProcessCheck{
DataState_PostureCheck: postureCheck,
DataState_PostureCheck_ProcessMulti: subCheck.ProcessMulti,
}
case *edge_ctrl_pb.DataState_PostureCheck_Domains_:
return &DomainCheck{
DataState_PostureCheck: postureCheck,
DataState_PostureCheck_Domains: subCheck.Domains,
}
case *edge_ctrl_pb.DataState_PostureCheck_Mfa_:
return &MfaCheck{
DataState_PostureCheck: postureCheck,
DataState_PostureCheck_Mfa: subCheck.Mfa,
}
}
return nil
}