-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Create new events api (#78326)
* Creating new events route * Trying to get github to recognize the indent change * Using paginated name for events api return type * Updating comment * Updating comment * Adding deprecated comments * Adding more comments Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
d7538a3
commit 8081a85
Showing
11 changed files
with
470 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
x-pack/plugins/security_solution/server/endpoint/routes/resolver/queries/related_events.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
/** | ||
* @deprecated use the `events.ts` file's query instead | ||
*/ | ||
import { SearchResponse } from 'elasticsearch'; | ||
import { esKuery } from '../../../../../../../../src/plugins/data/server'; | ||
import { SafeResolverEvent } from '../../../../../common/endpoint/types'; | ||
import { ResolverQuery } from './base'; | ||
import { PaginationBuilder } from '../utils/pagination'; | ||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common'; | ||
|
||
/** | ||
* Builds a query for retrieving related events for a node. | ||
*/ | ||
export class EventsQuery extends ResolverQuery<SafeResolverEvent[]> { | ||
private readonly kqlQuery: JsonObject[] = []; | ||
|
||
constructor( | ||
private readonly pagination: PaginationBuilder, | ||
indexPattern: string | string[], | ||
endpointID?: string, | ||
kql?: string | ||
) { | ||
super(indexPattern, endpointID); | ||
if (kql) { | ||
this.kqlQuery.push(esKuery.toElasticsearchQuery(esKuery.fromKueryExpression(kql))); | ||
} | ||
} | ||
|
||
protected legacyQuery(endpointID: string, uniquePIDs: string[]): JsonObject { | ||
return { | ||
query: { | ||
bool: { | ||
filter: [ | ||
...this.kqlQuery, | ||
{ | ||
terms: { 'endgame.unique_pid': uniquePIDs }, | ||
}, | ||
{ | ||
term: { 'agent.id': endpointID }, | ||
}, | ||
{ | ||
term: { 'event.kind': 'event' }, | ||
}, | ||
{ | ||
bool: { | ||
must_not: { | ||
term: { 'event.category': 'process' }, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
...this.pagination.buildQueryFields('endgame.serial_event_id', 'desc'), | ||
}; | ||
} | ||
|
||
protected query(entityIDs: string[]): JsonObject { | ||
return { | ||
query: { | ||
bool: { | ||
filter: [ | ||
...this.kqlQuery, | ||
{ | ||
terms: { 'process.entity_id': entityIDs }, | ||
}, | ||
{ | ||
term: { 'event.kind': 'event' }, | ||
}, | ||
{ | ||
bool: { | ||
must_not: { | ||
term: { 'event.category': 'process' }, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
...this.pagination.buildQueryFields('event.id', 'desc'), | ||
}; | ||
} | ||
|
||
formatResponse(response: SearchResponse<SafeResolverEvent>): SafeResolverEvent[] { | ||
return this.getResults(response); | ||
} | ||
} |
Oops, something went wrong.