diff --git a/.gitignore b/.gitignore index 07cacdab1..46dd202b1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ sensoroni jobs/ logs/ nsm/ +coverage/ .vscode/ .DS_Store diff --git a/server/detectionhandler.go b/server/detectionhandler.go index b560e25a0..ce2386ffd 100644 --- a/server/detectionhandler.go +++ b/server/detectionhandler.go @@ -420,20 +420,22 @@ func (h *DetectionHandler) bulkUpdateDetection(w http.ResponseWriter, r *http.Re } else { for _, id := range body.IDs { IDs = append(IDs, id) - det, err := h.server.Detectionstore.GetDetection(ctx, id) - if err != nil { - web.Respond(w, r, http.StatusInternalServerError, err) - return - } - - if det.IsCommunity { - containsCommunity = true - break + if body.Delete { + det, err := h.server.Detectionstore.GetDetection(ctx, id) + if err != nil { + web.Respond(w, r, http.StatusInternalServerError, err) + return + } + + if det.IsCommunity { + containsCommunity = true + break + } } } } - if containsCommunity { + if containsCommunity && body.Delete { web.Respond(w, r, http.StatusBadRequest, "ERROR_BULK_COMMUNITY") return } diff --git a/server/modules/elastalert/elastalert.go b/server/modules/elastalert/elastalert.go index 31ac2ad6b..4e4c00d4c 100644 --- a/server/modules/elastalert/elastalert.go +++ b/server/modules/elastalert/elastalert.go @@ -1006,16 +1006,6 @@ func (e *ElastAlertEngine) syncCommunityDetections(ctx context.Context, detects } } - // carry forward existing overrides - for i := range detects { - det := detects[i] - - comDet, exists := community[det.PublicID] - if exists { - det.Overrides = comDet.Overrides - } - } - results := struct { Added int Updated int