diff --git a/x-pack/plugins/endpoint/public/embeddables/resolver/models/process_event.ts b/x-pack/plugins/endpoint/public/embeddables/resolver/models/process_event.ts index 5dcf7ece8808d64..37979ffd75b611c 100644 --- a/x-pack/plugins/endpoint/public/embeddables/resolver/models/process_event.ts +++ b/x-pack/plugins/endpoint/public/embeddables/resolver/models/process_event.ts @@ -6,10 +6,17 @@ import { ProcessEvent } from '../types'; +/* + * Returns true is the process's eventType is either 'processCreated' or 'processRan'. + * Resolver will only render 'graphable' process events. + */ export function isGraphableProcess(event: ProcessEvent) { return eventType(event) === 'processCreated' || eventType(event) === 'processRan'; } +/* + * Returns a custom event type for a process event based on the event's metadata. + */ export function eventType(event: ProcessEvent) { const { data_buffer: { event_type_full: type, event_subtype_full: subType }, @@ -31,10 +38,16 @@ export function eventType(event: ProcessEvent) { return 'unknownEvent'; } +/* + * Returns the process event's pid + */ export function uniquePidForProcess(event: ProcessEvent) { return event.data_buffer.node_id; } +/* + * Returns the process event's parent pid + */ export function uniqueParentPidForProcess(event: ProcessEvent) { return event.data_buffer.source_id; } diff --git a/x-pack/plugins/endpoint/public/embeddables/resolver/models/process_event_test_helpers.ts b/x-pack/plugins/endpoint/public/embeddables/resolver/models/process_event_test_helpers.ts index 199ca0b15708e64..3306f489abe847b 100644 --- a/x-pack/plugins/endpoint/public/embeddables/resolver/models/process_event_test_helpers.ts +++ b/x-pack/plugins/endpoint/public/embeddables/resolver/models/process_event_test_helpers.ts @@ -7,6 +7,12 @@ import { ProcessEvent } from '../types'; type DeepPartial = { [K in keyof T]?: DeepPartial }; +/* + * Creates a mock process event given the 'parts' argument, which can + * include all or some process event fields as determined by the ProcessEvent type. + * The only field that must be provided is the event's 'node_id' field. + * The other fields are populated by the function unless provided in 'parts' + */ export function mockProcessEvent( parts: { data_buffer: { node_id: ProcessEvent['data_buffer']['node_id'] }; diff --git a/x-pack/plugins/endpoint/public/embeddables/resolver/store/data/selectors.ts b/x-pack/plugins/endpoint/public/embeddables/resolver/store/data/selectors.ts index 10cb6e0c90abade..c94aa74806bc77a 100644 --- a/x-pack/plugins/endpoint/public/embeddables/resolver/store/data/selectors.ts +++ b/x-pack/plugins/endpoint/public/embeddables/resolver/store/data/selectors.ts @@ -29,6 +29,23 @@ import { const unit = 100; const distanceBetweenNodesInUnits = 1; +/* An isometric projection is a method for representing three dimensional objects in 2 dimensions. + * More information about isometric projections can be found here https://en.wikipedia.org/wiki/Isometric_projection. + * In our case, we obtain the isometric projection by rotating the objects 45 degrees in the plane of the screen + * and arctan(1/sqrt(2)) (~35.3 degrees) through the horizontal axis. + * + * A rotation by 45 degrees in the plane of the screen is given by: + * [ sqrt(2)/2 -sqrt(2)/2 0 + * sqrt(2)/2 sqrt(2)/2 0 + * 0 0 1] + * + * A rotation by arctan(1/sqrt(2)) through the horizantal axis is given by: + * [ 1 0 0 + * 0 sqrt(3)/3 -sqrt(6)/3 + * 0 sqrt(6)/3 sqrt(3)/3] + * + * We can multiply both of these matrices to get the final transformation below. + */ /* prettier-ignore */ const isometricTransformMatrix: Matrix3 = [ Math.sqrt(2) / 2, -(Math.sqrt(2) / 2), 0,