From f136beaaea968c970f796f16a3f448c24faf129c Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Tue, 17 Aug 2021 22:20:24 -0400 Subject: [PATCH] fix alert consumers --- x-pack/plugins/security_solution/common/constants.ts | 3 +++ .../public/cases/components/case_view/index.tsx | 10 +++------- .../public/common/components/events_viewer/index.tsx | 6 +----- .../components/side_panel/event_details/index.tsx | 5 +++-- .../components/timeline/eql_tab_content/index.tsx | 4 ---- .../components/timeline/notes_tab_content/index.tsx | 4 ---- .../components/timeline/pinned_tab_content/index.tsx | 4 ---- .../components/timeline/query_tab_content/index.tsx | 4 ---- .../public/components/t_grid/integrated/index.tsx | 1 + 9 files changed, 11 insertions(+), 30 deletions(-) diff --git a/x-pack/plugins/security_solution/common/constants.ts b/x-pack/plugins/security_solution/common/constants.ts index 346568c3a9609..a89d204bb79b3 100644 --- a/x-pack/plugins/security_solution/common/constants.ts +++ b/x-pack/plugins/security_solution/common/constants.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { AlertConsumers } from '@kbn/rule-data-utils'; import type { TransformConfigSchema } from './transforms/types'; import { ENABLE_CASE_CONNECTOR } from '../../cases/common'; import { metadataTransformPattern } from './endpoint/constants'; @@ -310,3 +311,5 @@ export const showAllOthersBucket: string[] = [ export const ELASTIC_NAME = 'estc'; export const TRANSFORM_STATS_URL = `/api/transform/transforms/${metadataTransformPattern}-*/_stats`; + +export const SECURITY_SOLUTION_ALERT_CONSUMERS: AlertConsumers[] = [AlertConsumers.SIEM]; diff --git a/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx b/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx index ddc739b05f4c2..0342c995b9215 100644 --- a/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx @@ -7,8 +7,6 @@ import React, { useCallback, useRef, useState } from 'react'; import { useDispatch } from 'react-redux'; -import { AlertConsumers } from '@kbn/rule-data-utils'; - import { getCaseDetailsUrl, getCaseDetailsUrlWithCommentId, @@ -21,7 +19,7 @@ import { Case, CaseViewRefreshPropInterface } from '../../../../../cases/common' import { TimelineId } from '../../../../common/types/timeline'; import { SecurityPageName } from '../../../app/types'; import { useKibana } from '../../../common/lib/kibana'; -import { APP_ID } from '../../../../common/constants'; +import { APP_ID, SECURITY_SOLUTION_ALERT_CONSUMERS } from '../../../../common/constants'; import { timelineActions } from '../../../timelines/store/timeline'; import { useSourcererScope } from '../../../common/containers/sourcerer'; import { SourcererScopeName } from '../../../common/store/sourcerer/model'; @@ -55,8 +53,6 @@ export interface CaseProps extends Props { updateCase: (newCase: Case) => void; } -const ALERT_CONSUMER: AlertConsumers[] = [AlertConsumers.SIEM]; - const TimelineDetailsPanel = ({ alertConsumers }: { alertConsumers?: AlertConsumers[] }) => { const { browserFields, docValueFields } = useSourcererScope(SourcererScopeName.detections); @@ -65,7 +61,7 @@ const TimelineDetailsPanel = ({ alertConsumers }: { alertConsumers?: AlertConsum alertConsumers={alertConsumers} browserFields={browserFields} docValueFields={docValueFields} - entityType={EntityType.ALERTS} + entityType="alerts" isFlyoutView timelineId={TimelineId.casePage} /> @@ -234,7 +230,7 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) = showAlertDetails, subCaseId, timelineIntegration: { - alertConsumers: ALERT_CONSUMER, + alertConsumers: SECURITY_SOLUTION_ALERT_CONSUMERS, editor_plugins: { parsingPlugin: timelineMarkdownPlugin.parser, processingPluginRenderer: timelineMarkdownPlugin.renderer, diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx index 710f7c7907ae8..1b21eafc2ba2b 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx @@ -11,7 +11,6 @@ import deepEqual from 'fast-deep-equal'; import styled from 'styled-components'; import { isEmpty } from 'lodash/fp'; -import { AlertConsumers } from '@kbn/rule-data-utils'; import { inputsModel, inputsSelectors, State } from '../../store'; import { inputsActions } from '../../store/actions'; import { ControlColumnProps, RowRenderer, TimelineId } from '../../../../common/types/timeline'; @@ -69,8 +68,6 @@ export interface OwnProps { type Props = OwnProps & PropsFromRedux; -const alertConsumers: AlertConsumers[] = [AlertConsumers.SIEM]; - /** * The stateful events viewer component is the highest level component that is utilized across the security_solution pages layer where * timeline is used BESIDES the flyout. The flyout makes use of the `EventsViewer` component which is a subcomponent here @@ -219,9 +216,8 @@ const StatefulEventsViewerComponent: React.FC = ({ = ({ - alertConsumers, + alertConsumers = SECURITY_SOLUTION_ALERT_CONSUMERS, // Default to Security Solution so only other applications have to pass this in browserFields, docValueFields, - entityType, + entityType = 'events', // Default to events so only alerts have to pass entityType in expandedEvent, handleOnEventClosed, isFlyoutView, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/eql_tab_content/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/eql_tab_content/index.tsx index 28b795378d249..b67b9348f51aa 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/eql_tab_content/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/eql_tab_content/index.tsx @@ -13,7 +13,6 @@ import { EuiFlyoutFooter, EuiBadge, } from '@elastic/eui'; -import { AlertConsumers } from '@kbn/rule-data-utils'; import { isEmpty } from 'lodash/fp'; import React, { useEffect, useCallback } from 'react'; import styled from 'styled-components'; @@ -152,8 +151,6 @@ export type Props = OwnProps & PropsFromRedux; const NO_SORTING: Sort[] = []; -const alertConsumers: AlertConsumers[] = [AlertConsumers.SIEM]; - export const EqlTabContentComponent: React.FC = ({ activeTab, columns, @@ -349,7 +346,6 @@ export const EqlTabContentComponent: React.FC = ({ = ({ timelineId } () => expandedDetail[TimelineTabs.notes]?.panelView ? ( React.ReactNode; rowRenderers: RowRenderer[]; @@ -269,7 +266,6 @@ export const PinnedTabContentComponent: React.FC = ({ theme.eui.paddingSizes.s}; `; -const alertConsumers: AlertConsumers[] = [AlertConsumers.SIEM]; - const isTimerangeSame = (prevProps: Props, nextProps: Props) => prevProps.end === nextProps.end && prevProps.start === nextProps.start && @@ -417,7 +414,6 @@ export const QueryTabContentComponent: React.FC = ({ = ({ loading, { events, loadPage, pageInfo, refetch, totalCount = 0, inspect }, ] = useTimelineEvents({ + // We rely on entityType to determine Events vs Alerts alertConsumers: SECURITY_ALERTS_CONSUMERS, docValueFields, entityType,