Skip to content

Commit

Permalink
fix(api): fix alert rules source field (#1370)
Browse files Browse the repository at this point in the history
  • Loading branch information
PengyuanZhao authored Sep 6, 2023
1 parent 5f499c3 commit c54d98d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/_examples/alert-rules/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions api/alert_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}
Expand Down Expand Up @@ -256,8 +256,8 @@ type AlertRuleConfig struct {
Severities AlertRuleSeverities
ResourceGroups []string
EventCategories []string
Sources []string
AlertCategories []string
AlertSources []string
}

type AlertRule struct {
Expand All @@ -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"`
}
Expand Down
6 changes: 3 additions & 3 deletions api/alert_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
)
Expand All @@ -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")
}
Expand Down Expand Up @@ -315,7 +315,7 @@ func singleMockAlertRule(id string) string {
"Policy",
"Anomaly"
],
"sources": [
"source": [
"Aws",
"Agent",
"K8s"
Expand Down

0 comments on commit c54d98d

Please sign in to comment.