@@ -40,15 +40,22 @@ var AlertRuleCategories = []string{"Anomaly", "Policy", "Composite"}
4040// Valid inputs for AlertRule SubCategories property
4141var AlertRuleSubCategories = []string {
4242 "Compliance" ,
43- "App " ,
44- "Cloud" ,
43+ "Application " ,
44+ "Cloud Activity " ,
4545 "File" ,
4646 "Machine" ,
4747 "User" ,
4848 "Platform" ,
49- "K8sActivity " ,
49+ "Kubernetes Activity " ,
5050 "Registry" ,
5151 "SystemCall" ,
52+ "Host Vulnerability" ,
53+ "Container Vulnerability" ,
54+ "Threat Intel" ,
55+ // Deprecated eventCategory values
56+ "App" ,
57+ "Cloud" ,
58+ "K8sActivity" ,
5259}
5360
5461type alertRuleSeverity int
@@ -142,6 +149,24 @@ func convertSeverityInt(sev int) alertRuleSeverity {
142149 }
143150}
144151
152+ // Convert deprecated eventCatory values to subCategory values
153+ func convertEventCategories (categories []string ) []string {
154+ var res []string
155+ for _ , c := range categories {
156+ switch c {
157+ case "App" :
158+ res = append (res , "Application" )
159+ case "Cloud" :
160+ res = append (res , "Cloud Activity" )
161+ case "K8sActivity" :
162+ res = append (res , "Kubernetes Activity" )
163+ default :
164+ res = append (res , c )
165+ }
166+ }
167+ return res
168+ }
169+
145170const (
146171 AlertRuleSeverityCritical alertRuleSeverity = 1
147172 AlertRuleSeverityHigh alertRuleSeverity = 2
@@ -179,14 +204,14 @@ func NewAlertRule(name string, rule AlertRuleConfig) AlertRule {
179204 Channels : rule .Channels ,
180205 Type : AlertRuleEventType ,
181206 Filter : AlertRuleFilter {
182- Name : name ,
183- Enabled : 1 ,
184- Description : rule .Description ,
185- Severity : rule .Severities .toInt (),
186- ResourceGroups : rule .ResourceGroups ,
187- EventCategories : rule .EventCategories ,
188- AlertCategories : rule .AlertCategories ,
189- AlertSources : rule .AlertSources ,
207+ Name : name ,
208+ Enabled : 1 ,
209+ Description : rule .Description ,
210+ Severity : rule .Severities .toInt (),
211+ ResourceGroups : rule .ResourceGroups ,
212+ AlertSubCategories : convertEventCategories ( rule .AlertSubCategories ) ,
213+ AlertCategories : rule .AlertCategories ,
214+ AlertSources : rule .AlertSources ,
190215 },
191216 }
192217}
@@ -251,13 +276,13 @@ func (svc *AlertRulesService) Get(guid string, response interface{}) error {
251276}
252277
253278type AlertRuleConfig struct {
254- Channels []string
255- Description string
256- Severities AlertRuleSeverities
257- ResourceGroups []string
258- EventCategories []string
259- AlertCategories []string
260- AlertSources []string
279+ Channels []string
280+ Description string
281+ Severities AlertRuleSeverities
282+ ResourceGroups []string
283+ AlertSubCategories []string
284+ AlertCategories []string
285+ AlertSources []string
261286}
262287
263288type AlertRule struct {
@@ -273,7 +298,7 @@ type AlertRuleFilter struct {
273298 Description string `json:"description,omitempty"`
274299 Severity []int `json:"severity"`
275300 ResourceGroups []string `json:"resourceGroups"`
276- EventCategories []string `json:"eventCategory "`
301+ AlertSubCategories []string `json:"subCategory "`
277302 AlertCategories []string `json:"category"`
278303 AlertSources []string `json:"source,omitempty"`
279304 CreatedOrUpdatedTime string `json:"createdOrUpdatedTime,omitempty"`
0 commit comments