-
Notifications
You must be signed in to change notification settings - Fork 22
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
WIP: Elasticsearch Matcher #28
base: main
Are you sure you want to change the base?
Conversation
Hi there! Thanks a lot for the PR, this is great and I'll be happy to actively help with it. At a high level, it would be desirable to have the following:
Otherwise looks good overall, let me know when you'd like me to test this / a more in-depth review! |
var containsUuid bool | ||
for _,alert := range alerts { | ||
containsUuid = false | ||
for _,v := range alert.Source { | ||
if strings.Contains(v.(string), uuid) { | ||
containsUuid = true | ||
break | ||
} | ||
} | ||
if containsUuid { | ||
filteredAlerts = append(filteredAlerts, alert) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var containsUuid bool | |
for _,alert := range alerts { | |
containsUuid = false | |
for _,v := range alert.Source { | |
if strings.Contains(v.(string), uuid) { | |
containsUuid = true | |
break | |
} | |
} | |
if containsUuid { | |
filteredAlerts = append(filteredAlerts, alert) | |
} | |
} | |
for _, alert := range alerts { | |
containsUuid := false | |
for _, v := range alert.Source { | |
if strings.Contains(v.(string), uuid) { | |
containsUuid = true | |
break | |
} | |
} | |
if containsUuid { | |
filteredAlerts = append(filteredAlerts, alert) | |
} | |
} |
Spacing in the for loops and moving the variable inside the loop
// Parse the response | ||
strippedResponse, err := StripHTTPStatusCode(res.String()) | ||
if err != nil { | ||
log.Fatal("Error while stripping prepended HTTP status code") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to include the error here? Fatal
will exit immediately and so the return won't do anything and you will lose the original error. Although maybe you don't need it because there is only one error it can be 🤔
} | ||
var data ElasticsearchQueryResponse | ||
if err := json.Unmarshal([]byte(strippedResponse), &data); err != nil { | ||
log.Fatal("Error unmarshalling JSON string into ElasticsearchQueryResponse struct") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to log the error here so it is easier to debug
WORK IN PROGRESS!
This PR is by no means ready, just wanted to have it out there so structural issues and next steps can be discussed sooner rather than later! It currently comes with no documentation and no unit tests.
What does this PR do?
.siem-signals-default
index and retrieve recent, open alerts associated with a particular rule that have thedetonationUuid
in a specified fieldMotivation
This implements issue #24 : Alert Matching with Elastic
Want to see E2E detection testing brought to our organisation. We use Elasticsearch instead of Datadog. No reason this project couldn't be extended to add an Elasticsearch matcher.
Checklist