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

Updated Broadcast Permissions #469

Merged
merged 1 commit into from
May 6, 2024
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
2 changes: 1 addition & 1 deletion server/detectionhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func (h *DetectionHandler) bulkUpdateDetectionAsync(ctx context.Context, body *B
"totalTime": totalTime.Seconds(),
}).Error("bulk update Detections finished")

h.server.Host.Broadcast("detections:bulkUpdate", "detection", map[string]interface{}{
h.server.Host.Broadcast("detections:bulkUpdate", "detections", map[string]interface{}{
"error": len(errMap),
"total": len(IDs),
"modified": len(modified),
Expand Down
16 changes: 8 additions & 8 deletions server/modules/elastalert/elastalert.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func (e *ElastAlertEngine) startCommunityRuleImport() {
log.WithError(err).Error("unable to check for detection index template")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameElastAlert,
Status: "error",
})
Expand All @@ -472,7 +472,7 @@ func (e *ElastAlertEngine) startCommunityRuleImport() {
log.Warn("detection index template does not exist, skipping import")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameElastAlert,
Status: "error",
})
Expand Down Expand Up @@ -502,7 +502,7 @@ func (e *ElastAlertEngine) startCommunityRuleImport() {
log.WithField("errorMap", errMap).Error("something went wrong loading sigma packages")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameElastAlert,
Status: "error",
})
Expand All @@ -522,7 +522,7 @@ func (e *ElastAlertEngine) startCommunityRuleImport() {
log.WithError(err).Error("unable to update Sigma repos")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameElastAlert,
Status: "error",
})
Expand Down Expand Up @@ -572,7 +572,7 @@ func (e *ElastAlertEngine) startCommunityRuleImport() {
lastSyncSuccess = util.Ptr(true)

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameElastAlert,
Status: "success",
})
Expand Down Expand Up @@ -617,7 +617,7 @@ func (e *ElastAlertEngine) startCommunityRuleImport() {
log.WithError(err).Error("unable to sync elastalert community detections")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameElastAlert,
Status: "error",
})
Expand All @@ -637,7 +637,7 @@ func (e *ElastAlertEngine) startCommunityRuleImport() {
}).Error("unable to sync all ElastAlert community detections")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameElastAlert,
Status: "partial",
})
Expand All @@ -654,7 +654,7 @@ func (e *ElastAlertEngine) startCommunityRuleImport() {
}

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameElastAlert,
Status: "success",
})
Expand Down
14 changes: 7 additions & 7 deletions server/modules/strelka/strelka.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (e *StrelkaEngine) startCommunityRuleImport() {
log.WithError(err).Error("unable to check for detection index template")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameStrelka,
Status: "error",
})
Expand All @@ -313,7 +313,7 @@ func (e *StrelkaEngine) startCommunityRuleImport() {
log.Warn("detection index template does not exist, skipping import")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameStrelka,
Status: "error",
})
Expand Down Expand Up @@ -347,7 +347,7 @@ func (e *StrelkaEngine) startCommunityRuleImport() {
lastSyncSuccess = util.Ptr(true)

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameStrelka,
Status: "success",
})
Expand All @@ -367,7 +367,7 @@ func (e *StrelkaEngine) startCommunityRuleImport() {
log.WithError(err).Error("Failed to get all community SIDs")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameStrelka,
Status: "error",
})
Expand Down Expand Up @@ -506,7 +506,7 @@ func (e *StrelkaEngine) startCommunityRuleImport() {
log.WithError(err).Error("unable to sync YARA community detections")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameStrelka,
Status: "error",
})
Expand All @@ -520,12 +520,12 @@ func (e *StrelkaEngine) startCommunityRuleImport() {

if e.notify {
if len(errMap) > 0 {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameStrelka,
Status: "partial",
})
} else {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameStrelka,
Status: "success",
})
Expand Down
18 changes: 9 additions & 9 deletions server/modules/suricata/suricata.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (e *SuricataEngine) watchCommunityRules() {
log.WithError(err).Error("unable to check for detection index template")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "error",
})
Expand All @@ -324,7 +324,7 @@ func (e *SuricataEngine) watchCommunityRules() {
log.Warn("detection index template does not exist, skipping import")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "error",
})
Expand All @@ -339,7 +339,7 @@ func (e *SuricataEngine) watchCommunityRules() {
rules, hash, err := readAndHash(e.communityRulesFile)
if err != nil {
if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "error",
})
Expand Down Expand Up @@ -370,7 +370,7 @@ func (e *SuricataEngine) watchCommunityRules() {
lastSyncSuccess = util.Ptr(true)

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "success",
})
Expand All @@ -383,7 +383,7 @@ func (e *SuricataEngine) watchCommunityRules() {
allSettings, err := e.srv.Configstore.GetSettings(ctx)
if err != nil {
if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "error",
})
Expand All @@ -403,7 +403,7 @@ func (e *SuricataEngine) watchCommunityRules() {
commDetections, err := e.ParseRules(rules, ruleset.Value)
if err != nil {
if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "error",
})
Expand All @@ -426,7 +426,7 @@ func (e *SuricataEngine) watchCommunityRules() {
}

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "error",
})
Expand All @@ -448,7 +448,7 @@ func (e *SuricataEngine) watchCommunityRules() {
}).Error("unable to sync all community detections")

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "partial",
})
Expand All @@ -460,7 +460,7 @@ func (e *SuricataEngine) watchCommunityRules() {
}

if e.notify {
e.srv.Host.Broadcast("detection-sync", "detection", server.SyncStatus{
e.srv.Host.Broadcast("detection-sync", "detections", server.SyncStatus{
Engine: model.EngineNameSuricata,
Status: "success",
})
Expand Down
Loading