-
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] Resolver retrieve entity id of documents without field mapped #76562
Changes from 2 commits
3c3cba4
e4c5153
96392fa
b8af2f2
1e37369
dcf5369
e0a62b3
e97352c
97e14dd
e529bee
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
ResolverRelatedEvents, | ||
ResolverTree, | ||
ResolverEntityIndex, | ||
} from '../../../../common/endpoint/types'; | ||
import { mockEndpointEvent } from '../../mocks/endpoint_event'; | ||
import { mockTreeWithNoAncestorsAnd2Children } from '../../mocks/resolver_tree'; | ||
import { DataAccessLayer } from '../../types'; | ||
|
||
interface Metadata { | ||
/** | ||
* The `_id` of the document being analyzed. | ||
*/ | ||
databaseDocumentID: string; | ||
/** | ||
* A record of entityIDs to be used in tests assertions. | ||
*/ | ||
entityIDs: { | ||
/** | ||
* The entityID of the node related to the document being analyzed. | ||
*/ | ||
origin: 'origin'; | ||
/** | ||
* The entityID of the first child of the origin. | ||
*/ | ||
firstChild: 'firstChild'; | ||
/** | ||
* The entityID of the second child of the origin. | ||
*/ | ||
secondChild: 'secondChild'; | ||
}; | ||
} | ||
|
||
/** | ||
* A simple mock dataAccessLayer possible that returns a tree with 0 ancestors and 2 direct children. 1 related event is returned. The parameter to `entities` is ignored. | ||
*/ | ||
export function handleNoIndices(): { dataAccessLayer: DataAccessLayer; metadata: Metadata } { | ||
const metadata: Metadata = { | ||
databaseDocumentID: '_id', | ||
entityIDs: { origin: 'origin', firstChild: 'firstChild', secondChild: 'secondChild' }, | ||
}; | ||
return { | ||
metadata, | ||
dataAccessLayer: { | ||
/** | ||
* Fetch related events for an entity ID | ||
*/ | ||
relatedEvents(entityID: string): Promise<ResolverRelatedEvents> { | ||
return Promise.resolve({ | ||
entityID, | ||
events: [ | ||
mockEndpointEvent({ | ||
entityID, | ||
name: 'event', | ||
timestamp: 0, | ||
}), | ||
], | ||
nextEvent: null, | ||
}); | ||
}, | ||
|
||
/** | ||
* Fetch a ResolverTree for a entityID | ||
*/ | ||
resolverTree(): Promise<ResolverTree> { | ||
return Promise.resolve( | ||
mockTreeWithNoAncestorsAnd2Children({ | ||
originID: metadata.entityIDs.origin, | ||
firstChildID: metadata.entityIDs.firstChild, | ||
secondChildID: metadata.entityIDs.secondChild, | ||
}) | ||
); | ||
}, | ||
|
||
/** | ||
* Get entities matching a document. | ||
*/ | ||
entities({ indices }): Promise<ResolverEntityIndex> { | ||
if (indices.length === 1 && indices[0] === 'awesome_index') { | ||
return Promise.resolve([{ entity_id: metadata.entityIDs.origin }]); | ||
} | ||
return Promise.resolve([]); | ||
}, | ||
}, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import _ from 'lodash'; | ||
import { DatabaseParameters } from '../types'; | ||
|
||
export function equal(param1: DatabaseParameters, param2?: DatabaseParameters) { | ||
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. Why add this extra abstraction layer? For the type checking? 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. I think since timeline now sends resolver the ID and the indices we figured it'd be a good idea to combine them in a single object. Since 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. I was specifically talking about the abstraction of 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. Oh you mean like, why not just use I guess another option is we make 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. Yea, that was my thought, but since it's going to be something different from |
||
return _.isEqual(param1, param2); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,7 @@ interface AppReceivedNewExternalProperties { | |
/** | ||
* the `_id` of an ES document. This defines the origin of the Resolver graph. | ||
*/ | ||
databaseDocumentID?: string; | ||
databaseDocumentID: string; | ||
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. This is required by |
||
/** | ||
* An ID that uniquely identifies this Resolver instance from other concurrent Resolvers. | ||
*/ | ||
|
@@ -125,6 +125,11 @@ interface AppReceivedNewExternalProperties { | |
* The `search` part of the URL of this page. | ||
*/ | ||
locationSearch: string; | ||
|
||
/** | ||
* Indices that the backend will use to find the document. | ||
*/ | ||
indices: string[]; | ||
}; | ||
} | ||
|
||
|
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.
The indices to use are now passed in to Resolver via props from the Security Solution app.