Skip to content
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

[Endpoint]: Use common event model for determining if event is v0 or v1 #60667

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { ResolverEvent, LegacyEndpointEvent } from '../../../../common/types';

function isLegacyData(data: ResolverEvent): data is LegacyEndpointEvent {
return data.agent?.type === 'endgame';
}
import { ResolverEvent } from '../../../../common/types';
import { isLegacyEvent } from '../../../../common/models/event';

export function extractEventID(event: ResolverEvent) {
if (isLegacyData(event)) {
if (isLegacyEvent(event)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classic Resolver switcheroo 👍

return String(event.endgame.serial_event_id);
}
return event.event.id;
}

export function extractEntityID(event: ResolverEvent) {
if (isLegacyData(event)) {
if (isLegacyEvent(event)) {
return String(event.endgame.unique_pid);
}
return event.process.entity_id;
}

export function extractParentEntityID(event: ResolverEvent) {
if (isLegacyData(event)) {
if (isLegacyEvent(event)) {
const ppid = event.endgame.unique_ppid;
return ppid && String(ppid); // if unique_ppid is undefined return undefined
}
Expand Down