From 002f502ce098e98a1f199ff1beb705bbfef47a88 Mon Sep 17 00:00:00 2001 From: Umberto Pepato Date: Tue, 21 Jan 2025 15:41:22 +0100 Subject: [PATCH] [ResponseOps][Alerts] Fix optional eventId in security cell value renderers --- .../common/types/timeline/cells/index.ts | 2 +- .../preview_table_cell_renderer.tsx | 3 ++- .../render_cell_value.tsx | 22 +++++++++++-------- .../explore/network/components/port/index.tsx | 2 +- .../timelines/components/duration/index.tsx | 2 +- .../components/formatted_ip/index.tsx | 10 ++++----- .../renderers/asset_criticality_level.tsx | 2 +- .../timeline/body/renderers/bytes/index.tsx | 2 +- .../body/renderers/column_renderer.ts | 2 +- .../body/renderers/empty_column_renderer.tsx | 2 +- .../event_summary_column_renderer.tsx | 2 +- .../body/renderers/formatted_field.tsx | 2 +- .../renderers/formatted_field_helpers.tsx | 6 ++--- .../timeline/body/renderers/host_name.tsx | 2 +- .../body/renderers/plain_column_renderer.tsx | 2 +- .../body/renderers/reason_column_renderer.tsx | 2 +- .../timeline/body/renderers/rule_status.tsx | 2 +- .../timeline/body/renderers/service_name.tsx | 2 +- .../timeline/body/renderers/user_name.tsx | 2 +- .../body/renderers/user_profile_renderer.tsx | 2 +- 20 files changed, 39 insertions(+), 34 deletions(-) diff --git a/x-pack/solutions/security/plugins/security_solution/common/types/timeline/cells/index.ts b/x-pack/solutions/security/plugins/security_solution/common/types/timeline/cells/index.ts index 5575254ca886c..09164cddb30cf 100644 --- a/x-pack/solutions/security/plugins/security_solution/common/types/timeline/cells/index.ts +++ b/x-pack/solutions/security/plugins/security_solution/common/types/timeline/cells/index.ts @@ -21,7 +21,7 @@ export type CellValueElementProps = EuiDataGridCellValueElementProps & { browserFields?: BrowserFields; data: TimelineNonEcsData[]; ecsData?: Ecs; - eventId: string; // _id + eventId?: string; // _id header: ColumnHeaderOptions; isDraggable: boolean; isTimeline?: boolean; // Default cell renderer is used for both the alert table and timeline. This allows us to cheaply separate concerns diff --git a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/rule_preview/preview_table_cell_renderer.tsx b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/rule_preview/preview_table_cell_renderer.tsx index 096346312e193..a9c5a6b904e66 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/rule_preview/preview_table_cell_renderer.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation_ui/components/rule_preview/preview_table_cell_renderer.tsx @@ -32,7 +32,7 @@ export const PreviewRenderCellValue: React.FC< return ( ); }; diff --git a/x-pack/solutions/security/plugins/security_solution/public/detections/configurations/security_solution_detections/render_cell_value.tsx b/x-pack/solutions/security/plugins/security_solution/public/detections/configurations/security_solution_detections/render_cell_value.tsx index 857265b6c7d62..6656c1cccd84d 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detections/configurations/security_solution_detections/render_cell_value.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detections/configurations/security_solution_detections/render_cell_value.tsx @@ -28,6 +28,7 @@ import { VIEW_SELECTION } from '../../../../common/constants'; import { getAllFieldsByName } from '../../../common/containers/source'; import { eventRenderedViewColumns, getColumns } from './columns'; import type { GetSecurityAlertsTableProp } from '../../components/alerts_table/types'; +import type { CellValueElementProps, ColumnHeaderOptions } from '../../../../common/types'; /** * This implementation of `EuiDataGrid`'s `renderCellValue` @@ -51,13 +52,15 @@ type RenderCellValueProps = Pick< | 'colIndex' | 'setCellProps' | 'truncate' + | 'sourcererScope' + | 'userProfiles' > & - Record; + Partial>; export const CellValue = memo(function RenderCellValue({ columnId, rowIndex, - scopeId, + sourcererScope, tableId, tableType, header, @@ -73,7 +76,7 @@ export const CellValue = memo(function RenderCellValue({ eventId, setCellProps, truncate, - context, + userProfiles, }: RenderCellValueProps) { const isTourAnchor = useMemo( () => @@ -83,7 +86,7 @@ export const CellValue = memo(function RenderCellValue({ !isDetails, [columnId, isDetails, rowIndex, tableType] ); - const { browserFields } = useSourcererDataView(scopeId); + const { browserFields } = useSourcererDataView(sourcererScope); const browserFieldsByName = useMemo(() => getAllFieldsByName(browserFields), [browserFields]); const getTable = useMemo(() => dataTableSelectors.getTableByIdSelector(), []); const license = useLicense(); @@ -134,7 +137,8 @@ export const CellValue = memo(function RenderCellValue({ }, [ecsAlert, legacyAlert]); const Renderer = useMemo(() => { - const myHeader = header ?? { id: columnId, ...browserFieldsByName[columnId] }; + const myHeader = + header ?? ({ id: columnId, ...browserFieldsByName[columnId] } as ColumnHeaderOptions); const colHeader = columnHeaders.find((col) => col.id === columnId); const localLinkValues = getOr([], colHeader?.linkField ?? '', ecsAlert); return ( @@ -159,10 +163,10 @@ export const CellValue = memo(function RenderCellValue({ colIndex={colIndex} rowRenderers={rowRenderers ?? defaultRowRenderers} setCellProps={setCellProps} - scopeId={scopeId} + scopeId={sourcererScope} truncate={truncate} asPlainText={false} - context={context} + context={userProfiles} /> ); @@ -185,9 +189,9 @@ export const CellValue = memo(function RenderCellValue({ colIndex, rowRenderers, setCellProps, - scopeId, + sourcererScope, truncate, - context, + userProfiles, ]); return columnId === SIGNAL_RULE_NAME_FIELD_NAME && actualSuppressionCount ? ( diff --git a/x-pack/solutions/security/plugins/security_solution/public/explore/network/components/port/index.tsx b/x-pack/solutions/security/plugins/security_solution/public/explore/network/components/port/index.tsx index 102143e54c959..6a71b2a74dfca 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/explore/network/components/port/index.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/explore/network/components/port/index.tsx @@ -15,7 +15,7 @@ import { PortOrServiceNameLink } from '../../../../common/components/links'; export const Port = React.memo<{ contextId: string; Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; - eventId: string; + eventId?: string; fieldName: string; fieldType?: string; isAggregatable?: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/duration/index.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/duration/index.tsx index cc4950c762401..0af54d9bf8fdb 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/duration/index.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/duration/index.tsx @@ -18,7 +18,7 @@ export const EVENT_DURATION_FIELD_NAME = 'event.duration'; */ export const Duration = React.memo<{ contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/formatted_ip/index.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/formatted_ip/index.tsx index 3871a20f6b695..742c268c4fc81 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/formatted_ip/index.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/formatted_ip/index.tsx @@ -35,7 +35,7 @@ const getUniqueId = ({ address, }: { contextId: string; - eventId: string; + eventId?: string; fieldName: string; address: string | object | null | undefined; }) => `formatted-ip-data-provider-${contextId}-${fieldName}-${address}-${eventId}`; @@ -55,7 +55,7 @@ const getDataProvider = ({ address, }: { contextId: string; - eventId: string; + eventId?: string; fieldName: string; address: string | object | null | undefined; }): DataProvider => ({ @@ -74,7 +74,7 @@ const getDataProvider = ({ const NonDecoratedIpComponent: React.FC<{ contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; @@ -276,7 +276,7 @@ interface AddressLinksProps { addresses: string[]; Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; @@ -357,7 +357,7 @@ const AddressLinks = React.memo( const FormattedIpComponent: React.FC<{ Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/asset_criticality_level.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/asset_criticality_level.tsx index ce98498d9523f..dc277799076c2 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/asset_criticality_level.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/asset_criticality_level.tsx @@ -14,7 +14,7 @@ import { DefaultDraggable } from '../../../../../common/components/draggables'; interface Props { contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/bytes/index.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/bytes/index.tsx index 263a80d16307e..4e84434a19c57 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/bytes/index.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/bytes/index.tsx @@ -18,7 +18,7 @@ export const BYTES_FORMAT = 'bytes'; */ export const Bytes = React.memo<{ contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/column_renderer.ts b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/column_renderer.ts index ae63ef972e565..45a0d7b300e5a 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/column_renderer.ts +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/column_renderer.ts @@ -39,7 +39,7 @@ export interface ColumnRenderer { className?: string; columnName: string; ecsData?: Ecs; - eventId: string; + eventId?: string; field: ColumnHeaderOptions; globalFilters?: Filter[]; isDetails?: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/empty_column_renderer.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/empty_column_renderer.tsx index b5a527a65abb2..29aaa0c9c05e0 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/empty_column_renderer.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/empty_column_renderer.tsx @@ -34,7 +34,7 @@ export const emptyColumnRenderer: ColumnRenderer = { truncate, }: { columnName: string; - eventId: string; + eventId?: string; field: ColumnHeaderOptions; isDraggable?: boolean; scopeId: string; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/event_summary_column_renderer.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/event_summary_column_renderer.tsx index 42b7435e62406..8c662896ebce7 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/event_summary_column_renderer.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/event_summary_column_renderer.tsx @@ -42,7 +42,7 @@ export const eventSummaryColumnRenderer: ColumnRenderer = { }: { columnName: string; ecsData?: Ecs; - eventId: string; + eventId?: string; field: ColumnHeaderOptions; isDetails?: boolean; isDraggable?: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field.tsx index 379bf6c544fe3..4f6de85d32a65 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field.tsx @@ -66,7 +66,7 @@ const FormattedFieldValueComponent: React.FC<{ /** `Component` is only used with `EuiDataGrid`; the grid keeps a reference to `Component` for show / hide functionality */ Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; contextId: string; - eventId: string; + eventId?: string; isAggregatable?: boolean; isObjectArray?: boolean; isUnifiedDataTable?: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field_helpers.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field_helpers.tsx index 057f108834ee6..23e81441341a4 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field_helpers.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field_helpers.tsx @@ -36,7 +36,7 @@ interface RenderRuleNameProps { children?: React.ReactNode; Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; @@ -233,7 +233,7 @@ export const renderEventModule = ({ value, }: { contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; @@ -339,7 +339,7 @@ export const renderUrl = ({ contextId: string; /** `Component` is only used with `EuiDataGrid`; the grid keeps a reference to `Component` for show / hide functionality */ Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/host_name.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/host_name.tsx index b99f634d5a3cf..c6a2ccf4f277f 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/host_name.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/host_name.tsx @@ -20,7 +20,7 @@ import { useIsInSecurityApp } from '../../../../../common/hooks/is_in_security_a interface Props { contextId: string; Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_column_renderer.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_column_renderer.tsx index 5a23f4182355a..99f08dbb3f11f 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_column_renderer.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/plain_column_renderer.tsx @@ -34,7 +34,7 @@ export const plainColumnRenderer: ColumnRenderer = { }: { asPlainText?: boolean; columnName: string; - eventId: string; + eventId?: string; field: ColumnHeaderOptions; globalFilters?: Filter[]; isDraggable?: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/reason_column_renderer.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/reason_column_renderer.tsx index 97e5c3fe5f033..29ea91f3fc272 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/reason_column_renderer.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/reason_column_renderer.tsx @@ -35,7 +35,7 @@ export const reasonColumnRenderer: ColumnRenderer = { }: { columnName: string; ecsData?: Ecs; - eventId: string; + eventId?: string; field: ColumnHeaderOptions; isDetails?: boolean; isDraggable?: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/rule_status.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/rule_status.tsx index a3a2bb17cdd43..65b215acc9643 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/rule_status.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/rule_status.tsx @@ -25,7 +25,7 @@ const StyledEuiBadge = styled(EuiBadge)` interface BaseProps { contextId: string; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/service_name.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/service_name.tsx index 9832a21b6e8a3..de2fe8e728e48 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/service_name.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/service_name.tsx @@ -21,7 +21,7 @@ import { useIsInSecurityApp } from '../../../../../common/hooks/is_in_security_a interface Props { contextId: string; Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.tsx index 27ae105632b94..3842430b0a3b1 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.tsx @@ -20,7 +20,7 @@ import { useIsInSecurityApp } from '../../../../../common/hooks/is_in_security_a interface Props { contextId: string; Component?: typeof EuiButtonEmpty | typeof EuiButtonIcon; - eventId: string; + eventId?: string; fieldName: string; fieldType: string; isAggregatable: boolean; diff --git a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_profile_renderer.tsx b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_profile_renderer.tsx index e767685272356..e7ab1304176f1 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_profile_renderer.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_profile_renderer.tsx @@ -33,7 +33,7 @@ export const userProfileColumnRenderer: ColumnRenderer = { }: { columnName: string; ecsData?: Ecs; - eventId: string; + eventId?: string; field: ColumnHeaderOptions; isDetails?: boolean; isDraggable?: boolean;