Skip to content

Commit

Permalink
We were setting PersistChange at the wrong time in the update handler…
Browse files Browse the repository at this point in the history
… for detections. We'd set the value, update the detection, overwrite the detection with the result returned from the update that doesn't have the transient value set, then sync with PersistChange = false. Fixed.

When walking back the MarkChangedByUser context changes, the migration was updated to use context.Background. Instead we should use the server context, just don't call MarkChangedByUser on it.
  • Loading branch information
coreyogburn committed Aug 9, 2024
1 parent e696bad commit 44cebb6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion server/detectionhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ func (h *DetectionHandler) updateDetection(w http.ResponseWriter, r *http.Reques
}

statusModifiedByFilter := detect.IsEnabled != specifiedStatus
detect.PersistChange = true

err = h.PrepareForSave(ctx, detect, engine)
if err != nil {
Expand Down Expand Up @@ -367,6 +366,8 @@ func (h *DetectionHandler) updateDetection(w http.ResponseWriter, r *http.Reques
return
}

detect.PersistChange = true

errMap, err := SyncLocalDetections(ctx, h.server, []*model.Detection{detect})
if err != nil {
fixed := false
Expand Down
3 changes: 1 addition & 2 deletions server/modules/suricata/migration-2.4.70.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package suricata

import (
"context"
"fmt"
"os"
"regexp"
Expand Down Expand Up @@ -37,7 +36,7 @@ func (e *SuricataEngine) Migration2470(statePath string) error {

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

ctx := context.Background()
ctx := e.srv.Context

// read in idstools.yaml
enabled, disabled, err := e.m2470LoadEnabledDisabled()
Expand Down

0 comments on commit 44cebb6

Please sign in to comment.