From c54d98d162c1b477d1e373e893e9c6226af45604 Mon Sep 17 00:00:00 2001 From: Pengyuan Zhao Date: Wed, 6 Sep 2023 09:00:06 -0400 Subject: [PATCH] fix(api): fix alert rules source field (#1370) --- api/_examples/alert-rules/main.go | 2 +- api/alert_rules.go | 6 +++--- api/alert_rules_test.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/_examples/alert-rules/main.go b/api/_examples/alert-rules/main.go index b9b4296d6..ca679ef21 100644 --- a/api/_examples/alert-rules/main.go +++ b/api/_examples/alert-rules/main.go @@ -40,7 +40,7 @@ func main() { ResourceGroups: []string{"TECHALLY_000000000000AAAAAAAAAAAAAAAAAAAA"}, EventCategories: []string{"Compliance"}, AlertCategories: []string{"Policy"}, - Sources: []string{"Aws"}, + AlertSources: []string{"Aws"}, } myAlertRule := api.NewAlertRule("MyTestAlertRule", diff --git a/api/alert_rules.go b/api/alert_rules.go index c3601ed08..a048e5a47 100644 --- a/api/alert_rules.go +++ b/api/alert_rules.go @@ -186,7 +186,7 @@ func NewAlertRule(name string, rule AlertRuleConfig) AlertRule { ResourceGroups: rule.ResourceGroups, EventCategories: rule.EventCategories, AlertCategories: rule.AlertCategories, - Sources: rule.Sources, + AlertSources: rule.AlertSources, }, } } @@ -256,8 +256,8 @@ type AlertRuleConfig struct { Severities AlertRuleSeverities ResourceGroups []string EventCategories []string - Sources []string AlertCategories []string + AlertSources []string } type AlertRule struct { @@ -274,8 +274,8 @@ type AlertRuleFilter struct { Severity []int `json:"severity"` ResourceGroups []string `json:"resourceGroups"` EventCategories []string `json:"eventCategory"` - Sources []string `json:"sources,omitempty"` AlertCategories []string `json:"category"` + AlertSources []string `json:"source,omitempty"` CreatedOrUpdatedTime string `json:"createdOrUpdatedTime,omitempty"` CreatedOrUpdatedBy string `json:"createdOrUpdatedBy,omitempty"` } diff --git a/api/alert_rules_test.go b/api/alert_rules_test.go index 4a1b92170..daecfc94f 100644 --- a/api/alert_rules_test.go +++ b/api/alert_rules_test.go @@ -227,7 +227,7 @@ func TestAlertRuleUpdate(t *testing.T) { Severities: api.AlertRuleSeverities{api.AlertRuleSeverityHigh}, ResourceGroups: []string{"TECHALLY_100000000000AAAAAAAAAAAAAAAAAAAB"}, EventCategories: []string{"Compliance", "SystemCall"}, - Sources: []string{"Aws", "Agent", "K8s"}, + AlertSources: []string{"Aws", "Agent", "K8s"}, AlertCategories: []string{"Policy", "Anomaly"}, }, ) @@ -241,8 +241,8 @@ func TestAlertRuleUpdate(t *testing.T) { assert.NotNil(t, response) assert.Equal(t, intgGUID, response.Data.Guid) assert.Contains(t, response.Data.Filter.EventCategories, "Compliance", "SystemCall") - assert.Contains(t, response.Data.Filter.Sources, "Aws", "Agent", "K8s") assert.Contains(t, response.Data.Filter.AlertCategories, "Policy", "Anomaly") + assert.Contains(t, response.Data.Filter.AlertSources, "Aws", "Agent", "K8s") assert.Contains(t, response.Data.Filter.ResourceGroups, "TECHALLY_100000000000AAAAAAAAAAAAAAAAAAAB") assert.Contains(t, response.Data.Channels, "TECHALLY_000000000000AAAAAAAAAAAAAAAAAAAA") } @@ -315,7 +315,7 @@ func singleMockAlertRule(id string) string { "Policy", "Anomaly" ], - "sources": [ + "source": [ "Aws", "Agent", "K8s"