Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add actions and groupSignalsBy field in detection rules API #2922

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-10 19:09:26.701430",
"spec_repo_commit": "824f78a1"
"regenerated": "2025-02-11 09:59:41.165078",
"spec_repo_commit": "b980d49f"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-10 19:09:26.716618",
"spec_repo_commit": "824f78a1"
"regenerated": "2025-02-11 09:59:41.182412",
"spec_repo_commit": "b980d49f"
}
}
}
92 changes: 92 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15657,6 +15657,15 @@ components:
example: 1729843470000
format: int64
type: integer
groupSignalsBy:
description: Additional grouping to perform on top of the existing groups
in the query section. Must be a subset of the existing groups.
example:
- service
items:
description: Field to group by.
type: string
type: array
index:
description: Index used to load the data.
example: cloud_siem
Expand Down Expand Up @@ -24242,6 +24251,11 @@ components:
SecurityMonitoringRuleCase:
description: Case when signal is generated.
properties:
actions:
description: Action to perform for each rule case.
items:
$ref: '#/components/schemas/SecurityMonitoringRuleCaseAction'
type: array
condition:
description: 'A rule case contains logical operations (`>`,`>=`, `&&`, `||`)
to determine if a signal should be generated
Expand All @@ -24260,9 +24274,42 @@ components:
status:
$ref: '#/components/schemas/SecurityMonitoringRuleSeverity'
type: object
SecurityMonitoringRuleCaseAction:
description: Action to perform when a signal is triggered. Only available for
Application Security rule type.
properties:
options:
$ref: '#/components/schemas/SecurityMonitoringRuleCaseActionOptions'
type:
$ref: '#/components/schemas/SecurityMonitoringRuleCaseActionType'
type: object
SecurityMonitoringRuleCaseActionOptions:
description: Options for the rule action
properties:
duration:
description: Duration of the action in seconds. 0 indicates no expiration.
example: 0
format: int64
minimum: 0
type: integer
type: object
SecurityMonitoringRuleCaseActionType:
description: The action type.
enum:
- block_ip
- block_user
type: string
x-enum-varnames:
- BLOCK_IP
- BLOCK_USER
SecurityMonitoringRuleCaseCreate:
description: Case when signal is generated.
properties:
actions:
description: Action to perform for each rule case.
items:
$ref: '#/components/schemas/SecurityMonitoringRuleCaseAction'
type: array
condition:
description: 'A case contains logical operations (`>`,`>=`, `&&`, `||`)
to determine if a signal should be generated
Expand Down Expand Up @@ -24724,6 +24771,15 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringFilter'
type: array
groupSignalsBy:
description: Additional grouping to perform on top of the existing groups
in the query section. Must be a subset of the existing groups.
example:
- service
items:
description: Field to group by.
type: string
type: array
hasExtendedTitle:
description: Whether the notifications include the triggering group-by values
in their title.
Expand Down Expand Up @@ -25429,6 +25485,15 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringFilter'
type: array
groupSignalsBy:
description: Additional grouping to perform on top of the existing groups
in the query section. Must be a subset of the existing groups.
example:
- service
items:
description: Field to group by.
type: string
type: array
hasExtendedTitle:
description: Whether the notifications include the triggering group-by values
in their title.
Expand Down Expand Up @@ -25501,6 +25566,15 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringFilter'
type: array
groupSignalsBy:
description: Additional grouping to perform on top of the existing groups
in the query section. Must be a subset of the existing groups.
example:
- service
items:
description: Field to group by.
type: string
type: array
hasExtendedTitle:
description: Whether the notifications include the triggering group-by values
in their title.
Expand Down Expand Up @@ -25642,6 +25716,15 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringFilter'
type: array
groupSignalsBy:
description: Additional grouping to perform on top of the existing groups
in the query section. Must be a subset of the existing groups.
example:
- service
items:
description: Field to group by.
type: string
type: array
hasExtendedTitle:
description: Whether the notifications include the triggering group-by values
in their title.
Expand Down Expand Up @@ -25719,6 +25802,15 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringFilter'
type: array
groupSignalsBy:
description: Additional grouping to perform on top of the existing groups
in the query section. Must be a subset of the existing groups.
example:
- service
items:
description: Field to group by.
type: string
type: array
hasExtendedTitle:
description: Whether the notifications include the triggering group-by values
in their title.
Expand Down
37 changes: 36 additions & 1 deletion api/datadogV2/model_job_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type JobDefinition struct {
Cases []SecurityMonitoringRuleCaseCreate `json:"cases"`
// Starting time of data analyzed by the job.
From int64 `json:"from"`
// Additional grouping to perform on top of the existing groups in the query section. Must be a subset of the existing groups.
GroupSignalsBy []string `json:"groupSignalsBy,omitempty"`
// Index used to load the data.
Index string `json:"index"`
// Message for generated results.
Expand Down Expand Up @@ -141,6 +143,34 @@ func (o *JobDefinition) SetFrom(v int64) {
o.From = v
}

// GetGroupSignalsBy returns the GroupSignalsBy field value if set, zero value otherwise.
func (o *JobDefinition) GetGroupSignalsBy() []string {
if o == nil || o.GroupSignalsBy == nil {
var ret []string
return ret
}
return o.GroupSignalsBy
}

// GetGroupSignalsByOk returns a tuple with the GroupSignalsBy field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *JobDefinition) GetGroupSignalsByOk() (*[]string, bool) {
if o == nil || o.GroupSignalsBy == nil {
return nil, false
}
return &o.GroupSignalsBy, true
}

// HasGroupSignalsBy returns a boolean if a field has been set.
func (o *JobDefinition) HasGroupSignalsBy() bool {
return o != nil && o.GroupSignalsBy != nil
}

// SetGroupSignalsBy gets a reference to the given []string and assigns it to the GroupSignalsBy field.
func (o *JobDefinition) SetGroupSignalsBy(v []string) {
o.GroupSignalsBy = v
}

// GetIndex returns the Index field value.
func (o *JobDefinition) GetIndex() string {
if o == nil {
Expand Down Expand Up @@ -407,6 +437,9 @@ func (o JobDefinition) MarshalJSON() ([]byte, error) {
}
toSerialize["cases"] = o.Cases
toSerialize["from"] = o.From
if o.GroupSignalsBy != nil {
toSerialize["groupSignalsBy"] = o.GroupSignalsBy
}
toSerialize["index"] = o.Index
toSerialize["message"] = o.Message
toSerialize["name"] = o.Name
Expand Down Expand Up @@ -440,6 +473,7 @@ func (o *JobDefinition) UnmarshalJSON(bytes []byte) (err error) {
CalculatedFields []CalculatedField `json:"calculatedFields,omitempty"`
Cases *[]SecurityMonitoringRuleCaseCreate `json:"cases"`
From *int64 `json:"from"`
GroupSignalsBy []string `json:"groupSignalsBy,omitempty"`
Index *string `json:"index"`
Message *string `json:"message"`
Name *string `json:"name"`
Expand Down Expand Up @@ -477,7 +511,7 @@ func (o *JobDefinition) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"calculatedFields", "cases", "from", "index", "message", "name", "options", "queries", "referenceTables", "tags", "thirdPartyCases", "to", "type"})
datadog.DeleteKeys(additionalProperties, &[]string{"calculatedFields", "cases", "from", "groupSignalsBy", "index", "message", "name", "options", "queries", "referenceTables", "tags", "thirdPartyCases", "to", "type"})
} else {
return err
}
Expand All @@ -486,6 +520,7 @@ func (o *JobDefinition) UnmarshalJSON(bytes []byte) (err error) {
o.CalculatedFields = all.CalculatedFields
o.Cases = *all.Cases
o.From = *all.From
o.GroupSignalsBy = all.GroupSignalsBy
o.Index = *all.Index
o.Message = *all.Message
o.Name = *all.Name
Expand Down
45 changes: 40 additions & 5 deletions api/datadogV2/model_security_monitoring_rule_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

// SecurityMonitoringRuleCase Case when signal is generated.
type SecurityMonitoringRuleCase struct {
// Action to perform for each rule case.
Actions []SecurityMonitoringRuleCaseAction `json:"actions,omitempty"`
// A rule case contains logical operations (`>`,`>=`, `&&`, `||`) to determine if a signal should be generated
// based on the event counts in the previously defined queries.
Condition *string `json:"condition,omitempty"`
Expand Down Expand Up @@ -41,6 +43,34 @@ func NewSecurityMonitoringRuleCaseWithDefaults() *SecurityMonitoringRuleCase {
return &this
}

// GetActions returns the Actions field value if set, zero value otherwise.
func (o *SecurityMonitoringRuleCase) GetActions() []SecurityMonitoringRuleCaseAction {
if o == nil || o.Actions == nil {
var ret []SecurityMonitoringRuleCaseAction
return ret
}
return o.Actions
}

// GetActionsOk returns a tuple with the Actions field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SecurityMonitoringRuleCase) GetActionsOk() (*[]SecurityMonitoringRuleCaseAction, bool) {
if o == nil || o.Actions == nil {
return nil, false
}
return &o.Actions, true
}

// HasActions returns a boolean if a field has been set.
func (o *SecurityMonitoringRuleCase) HasActions() bool {
return o != nil && o.Actions != nil
}

// SetActions gets a reference to the given []SecurityMonitoringRuleCaseAction and assigns it to the Actions field.
func (o *SecurityMonitoringRuleCase) SetActions(v []SecurityMonitoringRuleCaseAction) {
o.Actions = v
}

// GetCondition returns the Condition field value if set, zero value otherwise.
func (o *SecurityMonitoringRuleCase) GetCondition() string {
if o == nil || o.Condition == nil {
Expand Down Expand Up @@ -159,6 +189,9 @@ func (o SecurityMonitoringRuleCase) MarshalJSON() ([]byte, error) {
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
if o.Actions != nil {
toSerialize["actions"] = o.Actions
}
if o.Condition != nil {
toSerialize["condition"] = o.Condition
}
Expand All @@ -181,22 +214,24 @@ func (o SecurityMonitoringRuleCase) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *SecurityMonitoringRuleCase) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Condition *string `json:"condition,omitempty"`
Name *string `json:"name,omitempty"`
Notifications []string `json:"notifications,omitempty"`
Status *SecurityMonitoringRuleSeverity `json:"status,omitempty"`
Actions []SecurityMonitoringRuleCaseAction `json:"actions,omitempty"`
Condition *string `json:"condition,omitempty"`
Name *string `json:"name,omitempty"`
Notifications []string `json:"notifications,omitempty"`
Status *SecurityMonitoringRuleSeverity `json:"status,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"condition", "name", "notifications", "status"})
datadog.DeleteKeys(additionalProperties, &[]string{"actions", "condition", "name", "notifications", "status"})
} else {
return err
}

hasInvalidField := false
o.Actions = all.Actions
o.Condition = all.Condition
o.Name = all.Name
o.Notifications = all.Notifications
Expand Down
Loading
Loading