From 2c9d0388870a48a96230c372eb732a9f3d8a7c52 Mon Sep 17 00:00:00 2001 From: Marshall Main Date: Thu, 3 Sep 2020 16:01:20 -0400 Subject: [PATCH] Rename buildAncestorsSignal to buildAncestors --- .../lib/detection_engine/signals/build_signal.test.ts | 11 +++-------- .../lib/detection_engine/signals/build_signal.ts | 7 ++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_signal.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_signal.test.ts index f3806b458ef73..dbc635e3815fd 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_signal.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_signal.test.ts @@ -5,12 +5,7 @@ */ import { sampleDocNoSortId } from './__mocks__/es_results'; -import { - buildSignal, - buildParent, - buildAncestorsSignal, - additionalSignalFields, -} from './build_signal'; +import { buildSignal, buildParent, buildAncestors, additionalSignalFields } from './build_signal'; import { Signal, Ancestor } from './types'; import { getPartialRulesSchemaMock } from '../../../../common/detection_engine/schemas/response/rules_schema.mocks'; @@ -215,7 +210,7 @@ describe('buildSignal', () => { kind: 'event', module: 'system', }; - const signal = buildAncestorsSignal(doc); + const signal = buildAncestors(doc); const expected: Ancestor[] = [ { id: 'd5e8eb51-a6a0-456d-8a15-4b79bfec3d71', @@ -255,7 +250,7 @@ describe('buildSignal', () => { }, depth: 1, }; - const signal = buildAncestorsSignal(doc); + const signal = buildAncestors(doc); const expected: Ancestor[] = [ { id: '730ddf9e-5a00-4f85-9ddf-5878ca511a87', diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_signal.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_signal.ts index dd5ce3de79f52..c78425f35773a 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_signal.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_signal.ts @@ -38,7 +38,7 @@ export const buildParent = (doc: SignalSourceHit): Ancestor => { * creating an array of N+1 ancestors. * @param doc The parent signal/event for which to extend the ancestry. */ -export const buildAncestorsSignal = (doc: SignalSourceHit): Signal['ancestors'] => { +export const buildAncestors = (doc: SignalSourceHit): Signal['ancestors'] => { const newAncestor = buildParent(doc); const existingAncestors = doc._source.signal?.ancestors; if (existingAncestors != null) { @@ -56,10 +56,7 @@ export const buildAncestorsSignal = (doc: SignalSourceHit): Signal['ancestors'] export const buildSignal = (docs: SignalSourceHit[], rule: Partial): Signal => { const parents = docs.map(buildParent); const depth = parents.reduce((acc, parent) => Math.max(parent.depth, acc), 0) + 1; - const ancestors = docs.reduce( - (acc: Ancestor[], doc) => acc.concat(buildAncestorsSignal(doc)), - [] - ); + const ancestors = docs.reduce((acc: Ancestor[], doc) => acc.concat(buildAncestors(doc)), []); return { parents, ancestors,