Skip to content

Commit 90b7651

Browse files
committed
Fix mustNot assignment and use fmt.Sprintf for dynamic keyword generation in OpenSearch queries
Signed-off-by: Osmany Montero <osmontero@icloud.com>
1 parent d7f30e8 commit 90b7651

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

plugins/alerts/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"fmt"
56
"github.com/threatwinds/go-sdk/catcher"
67
"github.com/threatwinds/go-sdk/opensearch"
78
"github.com/threatwinds/go-sdk/plugins"
@@ -182,7 +183,7 @@ func getPreviousAlertId(alert *plugins.Alert) *string {
182183
},
183184
})
184185

185-
mustNot = append(filters, opensearch.Query{
186+
mustNot = append(mustNot, opensearch.Query{
186187
Exists: map[string]string{
187188
"field": "parentId",
188189
},
@@ -197,7 +198,7 @@ func getPreviousAlertId(alert *plugins.Alert) *string {
197198
if value.Type == gjson.String {
198199
filters = append(filters, opensearch.Query{
199200
Term: map[string]map[string]interface{}{
200-
d: {
201+
fmt.Sprintf("%s.keyword", d): {
201202
"value": value.String(),
202203
},
203204
},

0 commit comments

Comments
 (0)