Skip to content

Commit bb5130c

Browse files
fix[backend](rules): removed modifications on legacy rule schema as it does not have correlation param
1 parent ab79382 commit bb5130c

3 files changed

Lines changed: 4 additions & 24 deletions

File tree

backend/modules/eventprocessing/domain/correlation_rule.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package domain
22

33
import (
4-
"fmt"
54
"time"
65
)
76

@@ -31,10 +30,10 @@ type UtmCorrelationRules struct {
3130
SystemOwner bool `gorm:"column:system_owner;not null"`
3231

3332
// Nullable JSON TEXT columns for advanced rule configuration.
34-
//[deprecated] only keeped for compatibility
33+
//[deprecated] only kept for compatibility
3534
AfterEventsDef string `gorm:"column:rule_after_events_def"`
3635
//
37-
CorrelationDef string `gorm:"column:rule_correlation_def"`
36+
3837
RuleGroupByDef string `gorm:"column:rule_group_by_def"`
3938
DeduplicateByDef string `gorm:"column:rule_deduplicate_by_def"`
4039

@@ -44,16 +43,5 @@ type UtmCorrelationRules struct {
4443
DataTypes []UtmDataTypes `gorm:"many2many:utm_group_rules_data_type;joinForeignKey:rule_id;joinReferences:data_type_id"`
4544
}
4645

47-
func (self *UtmCorrelationRules) GetCorrelationDef() (string,error){
48-
var correlate string
49-
if self.AfterEventsDef!="" && self.CorrelationDef !=""{
50-
return "",fmt.Errorf("only one afterEvents or correlation allowed")
51-
}else if self.AfterEventsDef!="" {
52-
correlate = self.AfterEventsDef
53-
}else{
54-
correlate= self.CorrelationDef
55-
}
56-
return correlate,nil
57-
}
5846

5947
func (UtmCorrelationRules) TableName() string { return "utm_correlation_rules" }

backend/modules/eventprocessing/dto/correlation_rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type RuleDataTypeResponse struct {
2626

2727

2828
type CorrelationOwner struct{
29-
//[deprecated] only keeped for compatibility
29+
//[deprecated] only kept for compatibility
3030
AfterEventsDef json.RawMessage `json:"afterEvents"`
3131
//
3232
CorrelationDef json.RawMessage `json:"correlation"`

backend/modules/eventprocessing/usecase/rule_bootstrap.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,6 @@ func legacyToRule(row *domain.UtmCorrelationRules) Rule {
265265
names = append(names, dt.DataType)
266266
}
267267

268-
correlation,err:=row.GetCorrelationDef()
269-
if err!=nil{
270-
catcher.Error("skipping invalid after events of rule, %s",err,map[string]any{
271-
"rule":row.RuleName,
272-
"afterEvents":row.AfterEventsDef,
273-
"correlation":row.CorrelationDef,
274-
})
275-
}
276268

277269
return Rule{
278270
Name: row.RuleName,
@@ -284,7 +276,7 @@ func legacyToRule(row *domain.UtmCorrelationRules) Rule {
284276
Impact: Impact{Confidentiality: row.RuleConfidentiality, Integrity: row.RuleIntegrity, Availability: row.RuleAvailability},
285277
Where: rawToWhere(toRaw(row.RuleDefinitionDef)),
286278
References: rawToAnySlice(toRaw(row.RuleReferencesDef)),
287-
Correlation: rawToAny(toRaw(correlation)),
279+
Correlation: rawToAny(toRaw(row.AfterEventsDef)),
288280
GroupBy: rawToStrSlice(toRaw(row.RuleGroupByDef)),
289281
DeduplicateBy: rawToStrSlice(toRaw(row.DeduplicateByDef)),
290282
}

0 commit comments

Comments
 (0)