-
Notifications
You must be signed in to change notification settings - Fork 24
/
datastructures.go
134 lines (115 loc) · 6.67 KB
/
datastructures.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package reporthandling
import (
"github.com/armosec/armoapi-go/armotypes"
)
const (
ControlAttributeKeyTypeTag = "controlTypeTags"
ControlAttributeKeyAttackTracks = "attackTracks"
)
type RuleLanguages string
const (
RegoLanguage RuleLanguages = "Rego"
RegoLanguage2 RuleLanguages = "rego"
)
// RuleMatchObjects defines which objects this rule applied on
type RuleMatchObjects struct {
APIGroups []string `json:"apiGroups" bson:"apiGroups"` // apps
APIVersions []string `json:"apiVersions" bson:"apiVersions"` // v1/ v1beta1 / *
Resources []string `json:"resources" bson:"resources"` // dep.., pods,
FieldSelector []string `json:"fieldSelector,omitempty" bson:"fieldSelector,omitempty"` // fields selector for example metadata.name==nginx,metadata.namespace==ns1
}
type RuleDependency struct {
PackageName string `json:"packageName" bson:"packageName"`
}
type ControlConfigInputs struct {
Path string `json:"path" bson:"path"`
Name string `json:"name" bson:"name"`
Description string `json:"description" bson:"description"`
}
type ScanningScopeType string
const (
ScopeCloudAKS ScanningScopeType = "AKS"
ScopeCloudGKE ScanningScopeType = "GKE"
ScopeCloudEKS ScanningScopeType = "EKS"
ScopeCloud ScanningScopeType = "cloud"
ScopeCluster ScanningScopeType = "cluster"
ScopeFile ScanningScopeType = "file"
)
type ScanningScope struct {
Matches []ScanningScopeType `json:"matches"`
}
// PolicyRule represents single rule, the fundamental executable block of policy
type PolicyRule struct {
armotypes.PortalBase `json:",inline" bson:"inline"`
CreationTime string `json:"creationTime" bson:"creationTime"`
Rule string `json:"rule" bson:"rule"` // multiline string of raw.rego
ResourceEnumerator string `json:"resourceEnumerator" bson:"resourceEnumerator"` // multiline string of filter.rego, if exists
RuleLanguage RuleLanguages `json:"ruleLanguage" bson:"ruleLanguage"` // default "rego"
Match []RuleMatchObjects `json:"match" bson:"match"` // k8s resources this rule needs as inputs
DynamicMatch []RuleMatchObjects `json:"dynamicMatch,omitempty" bson:"dynamicMatch,omitempty"` // NON-k8s resources this rule needs as inputs, acquired by host-scanner
RuleDependencies []RuleDependency `json:"ruleDependencies" bson:"ruleDependencies"` // packages this rule uses
ControlConfigInputs []ControlConfigInputs `json:"controlConfigInputs" bson:"controlConfigInputs" ` // list of inputs from postureControlInputs in customerConfig for this rule
Description string `json:"description" bson:"description"`
Remediation string `json:"remediation" bson:"remediation"`
RuleQuery string `json:"ruleQuery" bson:"ruleQuery" ` // default "armo_builtins" - DEPRECATED
RelevantCloudProviders []string `json:"relevantCloudProviders" bson:"relevantCloudProviders"` // rule is relevant only to clusters in these cloud providers
}
// Control represents a collection of rules which are combined together to single purpose
type Control struct {
FixedInput map[string][]string `json:"fixedInput,omitempty"`
RulesIDs *[]string `json:"rulesIDs,omitempty" bson:"rulesIDs,omitempty"`
armotypes.PortalBase `json:",inline" bson:"inline"`
Control_ID string `json:"id,omitempty" bson:"id,omitempty" `
ControlID string `json:"controlID" bson:"controlID"`
CreationTime string `json:"creationTime" bson:"creationTime"`
Description string `json:"description" bson:"description"`
Remediation string `json:"remediation" bson:"remediation"`
Rules []PolicyRule `json:"rules" bson:"rules,omitempty"`
FrameworkNames []string `json:"frameworkNames,omitempty" bson:"frameworkNames,omitempty"`
BaseScore float32 `json:"baseScore,omitempty" bson:"baseScore,omitempty"`
ARMOImprovementFactor float32 `json:"ARMOImprovementFactor,omitempty" bson:"ARMOImprovementFactor,omitempty"`
ScanningScope *ScanningScope `json:"scanningScope,omitempty" bson:"scanningScope,omitempty"`
Category *Category `json:"category,omitempty" bson:"category,omitempty"`
}
type Category struct {
Name string `json:"name" bson:"name"`
ID string `json:"id" bson:"id"`
SubCategory *SubCategory `json:"subCategory,omitempty" bson:"subCategory,omitempty"`
}
type SubCategory struct {
Name string `json:"name" bson:"name"`
ID string `json:"id" bson:"id"`
}
type UpdatedControl struct {
Control `json:",inline"`
Rules []interface{} `json:"rules"`
}
// Framework represents a collection of controls which are combined together to expose comprehensive behavior
type Framework struct {
armotypes.PortalBase `json:",inline" bson:"inline"`
CreationTime string `json:"creationTime" bson:"creationTime"`
Description string `json:"description" bson:"description"`
TypeTags []string `json:"typeTags" bson:"typeTags"`
Controls []Control `json:"controls" bson:"-"`
// for new list of controls in POST/UPADTE requests
ControlsIDs *[]string `json:"controlsIDs,omitempty" bson:"controlsIDs,omitempty"`
SubSections map[string]*FrameworkSubSection `json:"subSections,omitempty" bson:"subSections,omitempty"`
ScanningScope *ScanningScope `json:"scanningScope,omitempty" bson:"scanningScope,omitempty"`
}
type UpdatedFramework struct {
Framework `json:",inline"`
Controls []interface{} `json:"controls"`
}
type FrameworkSubSection struct {
armotypes.PortalBase `json:",inline" bson:"inline"`
ID string `json:"id" bson:"id"` // unique id inside the framework.
SubSections map[string]*FrameworkSubSection `json:"subSections,omitempty" bson:"subSections,omitempty"` // inner subsection
ControlIDs []string `json:"controlsIDs,omitempty" bson:"controlsIDs,omitempty"` // control ids.
Controls []*Control `json:"-" bson:"-"` // controls list for fast access
}
type AttackTrackCategories struct {
AttackTrack string
Categories []string
DisplayRelatedResources bool
ClickableResourceKind string
}