-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solution][Detections] Reduce detection engine reliance on _source #89371
Changes from all commits
1a0a6ed
084ba5e
2ff44e1
8d8b62a
286e8d5
47297b6
6420cff
9b9d1b6
9479bfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { get } from 'lodash/fp'; | ||
import { SearchResponse } from '../../../types'; | ||
import { FilterEventsOptions } from './types'; | ||
|
||
|
@@ -22,13 +21,17 @@ export const filterEvents = <T>({ | |
return events.filter((item) => { | ||
return fieldAndSetTuples | ||
.map((tuple) => { | ||
const eventItem = get(tuple.field, item._source); | ||
if (eventItem == null) { | ||
return true; | ||
} else if (tuple.operator === 'included') { | ||
const eventItem = item.fields ? item.fields[tuple.field] : undefined; | ||
if (tuple.operator === 'included') { | ||
if (eventItem == null) { | ||
return true; | ||
} | ||
// only create a signal if the event is not in the value list | ||
return !tuple.matchedSet.has(JSON.stringify(eventItem)); | ||
} else if (tuple.operator === 'excluded') { | ||
if (eventItem == null) { | ||
return false; | ||
} | ||
// only create a signal if the event is in the value list | ||
return tuple.matchedSet.has(JSON.stringify(eventItem)); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since there's only two operators, not sure this else path ever hits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be hit, but since the operator is a string it's possible for it to get into an invalid state so it's good to handle that possibility. Looking at it again we'd probably want to return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Wonder if we'd want to log there too. Worry about just letting through invalid states. |
||
|
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.
Super nit: wonder if we're gonna be doing this a lot if it's worth just creating a tiny util to extract
x
field fromfields
.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.
Yeah if it becomes a common pattern I'd support pulling it out into a function