Skip to content

Commit

Permalink
fix alert consumers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelolo24 committed Aug 18, 2021
1 parent b6a37b6 commit f136bea
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 30 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/security_solution/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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];
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
Expand Down Expand Up @@ -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);

Expand All @@ -65,7 +61,7 @@ const TimelineDetailsPanel = ({ alertConsumers }: { alertConsumers?: AlertConsum
alertConsumers={alertConsumers}
browserFields={browserFields}
docValueFields={docValueFields}
entityType={EntityType.ALERTS}
entityType="alerts"
isFlyoutView
timelineId={TimelineId.casePage}
/>
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -219,9 +216,8 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
</InspectButtonContainer>
</FullScreenContainer>
<DetailsPanel
alertConsumers={alertConsumers}
browserFields={browserFields}
entityType={EntityType.ALERTS}
entityType={entityType}
docValueFields={docValueFields}
isFlyoutView
timelineId={id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { TimelineNonEcsData } from '../../../../../common';
import { Ecs } from '../../../../../common/ecs';
import { EventDetailsFooter } from './footer';
import { EntityType } from '../../../../../../timelines/common';
import { SECURITY_SOLUTION_ALERT_CONSUMERS } from '../../../../../common/constants';

const StyledEuiFlyoutBody = styled(EuiFlyoutBody)`
.euiFlyoutBody__overflow {
Expand Down Expand Up @@ -69,10 +70,10 @@ interface EventDetailsPanelProps {
}

const EventDetailsPanelComponent: React.FC<EventDetailsPanelProps> = ({
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -152,8 +151,6 @@ export type Props = OwnProps & PropsFromRedux;

const NO_SORTING: Sort[] = [];

const alertConsumers: AlertConsumers[] = [AlertConsumers.SIEM];

export const EqlTabContentComponent: React.FC<Props> = ({
activeTab,
columns,
Expand Down Expand Up @@ -349,7 +346,6 @@ export const EqlTabContentComponent: React.FC<Props> = ({
<VerticalRule />
<ScrollableFlexItem grow={1}>
<DetailsPanel
alertConsumers={alertConsumers}
browserFields={browserFields}
docValueFields={docValueFields}
tabType={TimelineTabs.eql}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
EuiPanel,
EuiHorizontalRule,
} from '@elastic/eui';
import { AlertConsumers } from '@kbn/rule-data-utils';

import React, { Fragment, useCallback, useMemo, useState } from 'react';
import { useDispatch } from 'react-redux';
Expand Down Expand Up @@ -71,8 +70,6 @@ const Username = styled(EuiText)`
font-weight: bold;
`;

const alertConsumers: AlertConsumers[] = [AlertConsumers.SIEM];

interface UsernameWithAvatar {
username: string;
}
Expand Down Expand Up @@ -185,7 +182,6 @@ const NotesTabContentComponent: React.FC<NotesTabContentProps> = ({ timelineId }
() =>
expandedDetail[TimelineTabs.notes]?.panelView ? (
<DetailsPanel
alertConsumers={alertConsumers}
browserFields={browserFields}
docValueFields={docValueFields}
handleOnPanelClosed={handleOnPanelClosed}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { EuiFlexGroup, EuiFlexItem, EuiFlyoutBody, EuiFlyoutFooter } from '@elastic/eui';
import { AlertConsumers } from '@kbn/rule-data-utils';
import { isEmpty } from 'lodash/fp';
import React, { useMemo, useCallback } from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -89,8 +88,6 @@ const VerticalRule = styled.div`

VerticalRule.displayName = 'VerticalRule';

const alertConsumers: AlertConsumers[] = [AlertConsumers.SIEM];

interface OwnProps {
renderCellValue: (props: CellValueElementProps) => React.ReactNode;
rowRenderers: RowRenderer[];
Expand Down Expand Up @@ -269,7 +266,6 @@ export const PinnedTabContentComponent: React.FC<Props> = ({
<VerticalRule />
<ScrollableFlexItem grow={1}>
<DetailsPanel
alertConsumers={alertConsumers}
browserFields={browserFields}
docValueFields={docValueFields}
handleOnPanelClosed={handleOnPanelClosed}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
EuiFlyoutFooter,
EuiBadge,
} from '@elastic/eui';
import { AlertConsumers } from '@kbn/rule-data-utils';
import { isEmpty } from 'lodash/fp';
import React, { useState, useMemo, useEffect, useCallback } from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -136,8 +135,6 @@ const EventsCountBadge = styled(EuiBadge)`
margin-left: ${({ theme }) => theme.eui.paddingSizes.s};
`;

const alertConsumers: AlertConsumers[] = [AlertConsumers.SIEM];

const isTimerangeSame = (prevProps: Props, nextProps: Props) =>
prevProps.end === nextProps.end &&
prevProps.start === nextProps.start &&
Expand Down Expand Up @@ -417,7 +414,6 @@ export const QueryTabContentComponent: React.FC<Props> = ({
<VerticalRule />
<ScrollableFlexItem grow={1}>
<DetailsPanel
alertConsumers={alertConsumers}
browserFields={browserFields}
docValueFields={docValueFields}
handleOnPanelClosed={handleOnPanelClosed}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ const TGridIntegratedComponent: React.FC<TGridIntegratedProps> = ({
loading,
{ events, loadPage, pageInfo, refetch, totalCount = 0, inspect },
] = useTimelineEvents({
// We rely on entityType to determine Events vs Alerts
alertConsumers: SECURITY_ALERTS_CONSUMERS,
docValueFields,
entityType,
Expand Down

0 comments on commit f136bea

Please sign in to comment.