-
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] adds WrapSequences method (RAC) #102106
Changes from 5 commits
afeacc5
d0ac8bc
0ecb444
0194fb3
4ae8dd4
e60b369
8081fa0
02056f3
adc7aa7
c1b57f6
65bcd0f
efa0b3f
6eff130
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 |
---|---|---|
|
@@ -25,11 +25,15 @@ export const wrapHitsFactory = ({ | |
const wrappedDocs: WrappedSignalHit[] = events.flatMap((doc) => [ | ||
{ | ||
_index: signalsIndex, | ||
// TODO: bring back doc._version | ||
_id: generateId(doc._index, doc._id, '', ruleSO.attributes.params.ruleId ?? ''), | ||
_id: generateId( | ||
doc._index, | ||
doc._id, | ||
doc._version ? doc._version.toString() : '', | ||
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. fwiw a lot of people use the constructor variant such as One other thing is that I do not think the In Saved Objects and other places if we are trying to identify if a document has changed and key off of that it's better to use Ref: https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html The caveat being we have to ensure we are passing the correct flags to return these two fields with our search results which you would have to check. You could fall back on However, overall I think we have older deprecated patterns of using Let me know if that doesn't sound right. 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. just pushed some changes and updated it as 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. created #102395 |
||
ruleSO.attributes.params.ruleId ?? '' | ||
), | ||
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. Is it possible to type the line below in the file above and then we avoid this as cast? _source: buildBulkBody(ruleSO, doc as SignalSourceHit), |
||
_source: buildBulkBody(ruleSO, doc as SignalSourceHit), | ||
}, | ||
]); | ||
|
||
return filterDuplicateSignals(ruleSO.id, wrappedDocs); | ||
return filterDuplicateSignals(ruleSO.id, wrappedDocs, false); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SearchAfterAndBulkCreateParams, WrappedSignalHit, WrapSequences } from './types'; | ||
import { buildSignalGroupFromSequence } from './build_bulk_body'; | ||
|
||
export const wrapSequencesFactory = ({ | ||
ruleSO, | ||
signalsIndex, | ||
}: { | ||
ruleSO: SearchAfterAndBulkCreateParams['ruleSO']; | ||
signalsIndex: string; | ||
}): WrapSequences => (sequences) => { | ||
const wrappedDocs = sequences.reduce( | ||
(acc: WrappedSignalHit[], sequence) => | ||
acc.concat(buildSignalGroupFromSequence(sequence, ruleSO, signalsIndex)), | ||
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. nit: can we do a splat and avoid the [...acc, buildSignalGroupFromSequence(sequence, ruleSO, signalsIndex)] |
||
[] | ||
); | ||
|
||
return wrappedDocs; | ||
}; |
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.
Can this
unknown
be typed and then we avoid the as casting below.