Skip to content

Commit

Permalink
MarkChangedByUser in Migration
Browse files Browse the repository at this point in the history
Without updating the context, any changes made during this migration could be reset on next sync.
  • Loading branch information
coreyogburn committed Jul 25, 2024
1 parent 62d420c commit da4f7e2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/modules/suricata/migration-2.4.70.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"

"github.com/security-onion-solutions/securityonion-soc/model"
"github.com/security-onion-solutions/securityonion-soc/web"

"github.com/apex/log"
"gopkg.in/yaml.v3"
Expand All @@ -36,6 +37,8 @@ func (e *SuricataEngine) Migration2470(statePath string) error {

log.Info("suricata is now migrating to 2.4.70") // for support

ctx := web.MarkChangedByUser(e.srv.Context, true)

// read in idstools.yaml
enabled, disabled, err := e.m2470LoadEnabledDisabled()
if err != nil {
Expand All @@ -50,7 +53,7 @@ func (e *SuricataEngine) Migration2470(statePath string) error {
dirty := map[string]struct{}{} // map[sid]X

// retrieve all suricata rules
detects, err := e.srv.Detectionstore.GetAllDetections(e.srv.Context, model.WithEngine(model.EngineNameSuricata))
detects, err := e.srv.Detectionstore.GetAllDetections(ctx, model.WithEngine(model.EngineNameSuricata))
if err != nil {
return err
}
Expand Down Expand Up @@ -105,7 +108,7 @@ func (e *SuricataEngine) Migration2470(statePath string) error {

det.Kind = ""

_, err := e.srv.Detectionstore.UpdateDetection(e.srv.Context, det)
_, err := e.srv.Detectionstore.UpdateDetection(ctx, det)
if err != nil {
return err
}
Expand All @@ -114,7 +117,7 @@ func (e *SuricataEngine) Migration2470(statePath string) error {
}

// sync suricata
errMap, err := e.srv.DetectionEngines[model.EngineNameSuricata].SyncLocalDetections(e.srv.Context, dirtyDets)
errMap, err := e.srv.DetectionEngines[model.EngineNameSuricata].SyncLocalDetections(ctx, dirtyDets)
if err != nil {
return err
}
Expand Down

0 comments on commit da4f7e2

Please sign in to comment.