Skip to content

Commit

Permalink
Revert "[RAC] integrating rbac search strategy with alert flyout (#10…
Browse files Browse the repository at this point in the history
…7748)"

This reverts commit e9ac0c6.
  • Loading branch information
jbudz committed Aug 12, 2021
1 parent 2ebdf3e commit 2ab5c2c
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 75 deletions.
5 changes: 1 addition & 4 deletions x-pack/plugins/cases/public/components/case_view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export const CaseComponent = React.memo<CaseComponentProps>(
const [initLoadingData, setInitLoadingData] = useState(true);
const init = useRef(true);
const timelineUi = useTimelineContext()?.ui;
const alertConsumers = useTimelineContext()?.alertConsumers;

const {
caseUserActions,
Expand Down Expand Up @@ -487,9 +486,7 @@ export const CaseComponent = React.memo<CaseComponentProps>(
</EuiFlexGroup>
</ContentWrapper>
</WhitePageWrapper>
{timelineUi?.renderTimelineDetailsPanel
? timelineUi.renderTimelineDetailsPanel({ alertConsumers })
: null}
{timelineUi?.renderTimelineDetailsPanel ? timelineUi.renderTimelineDetailsPanel() : null}
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import React, { useState } from 'react';
import { EuiMarkdownEditorUiPlugin, EuiMarkdownAstNodePosition } from '@elastic/eui';
import type { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';
import { Plugin } from 'unified';
/**
* @description - manage the plugins, hooks, and ui components needed to enable timeline functionality within the cases plugin
Expand All @@ -29,7 +28,6 @@ interface TimelineProcessingPluginRendererProps {
}

export interface CasesTimelineIntegration {
alertConsumers?: AlertConsumers[];
editor_plugins: {
parsingPlugin: Plugin;
processingPluginRenderer: React.FC<
Expand All @@ -45,11 +43,7 @@ export interface CasesTimelineIntegration {
};
ui?: {
renderInvestigateInTimelineActionComponent?: (alertIds: string[]) => JSX.Element;
renderTimelineDetailsPanel?: ({
alertConsumers,
}: {
alertConsumers?: AlertConsumers[];
}) => JSX.Element;
renderTimelineDetailsPanel?: () => JSX.Element;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import React, { useCallback, useRef, useState } from 'react';
import { useDispatch } from 'react-redux';
import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';

import {
getCaseDetailsUrl,
Expand All @@ -34,7 +33,6 @@ import { SpyRoute } from '../../../common/utils/route/spy_routes';
import * as timelineMarkdownPlugin from '../../../common/components/markdown_editor/plugins/timeline';
import { CaseDetailsRefreshContext } from '../../../common/components/endpoint/host_isolation/endpoint_host_isolation_cases_context';
import { getEndpointDetailsPath } from '../../../management/common/routing';
import { EntityType } from '../../../timelines/containers/details';

interface Props {
caseId: string;
Expand All @@ -55,17 +53,13 @@ export interface CaseProps extends Props {
updateCase: (newCase: Case) => void;
}

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

const TimelineDetailsPanel = ({ alertConsumers }: { alertConsumers?: AlertConsumers[] }) => {
const TimelineDetailsPanel = () => {
const { browserFields, docValueFields } = useSourcererScope(SourcererScopeName.detections);

return (
<DetailsPanel
alertConsumers={alertConsumers}
browserFields={browserFields}
docValueFields={docValueFields}
entityType={EntityType.ALERTS}
isFlyoutView
timelineId={TimelineId.casePage}
/>
Expand Down Expand Up @@ -234,7 +228,6 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) =
showAlertDetails,
subCaseId,
timelineIntegration: {
alertConsumers: ALERT_CONSUMER,
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/target/alerts_as_data_rbac';
import { inputsModel, inputsSelectors, State } from '../../store';
import { inputsActions } from '../../store/actions';
import { ControlColumnProps, RowRenderer, TimelineId } from '../../../../common/types/timeline';
Expand All @@ -31,7 +30,6 @@ import { useKibana } from '../../lib/kibana';
import { defaultControlColumn } from '../../../timelines/components/timeline/body/control_columns';
import { EventsViewer } from './events_viewer';
import * as i18n from './translations';
import { EntityType } from '../../../timelines/containers/details';

const EMPTY_CONTROL_COLUMNS: ControlColumnProps[] = [];
const leadingControlColumns: ControlColumnProps[] = [
Expand Down Expand Up @@ -69,8 +67,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 @@ -209,9 +205,7 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
</InspectButtonContainer>
</FullScreenContainer>
<DetailsPanel
alertConsumers={alertConsumers}
browserFields={browserFields}
entityType={EntityType.ALERTS}
docValueFields={docValueFields}
isFlyoutView
timelineId={id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import {
import React, { useState, useCallback, useMemo } from 'react';
import styled from 'styled-components';
import deepEqual from 'fast-deep-equal';
import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';
import { BrowserFields, DocValueFields } from '../../../../common/containers/source';
import { ExpandableEvent, ExpandableEventTitle } from './expandable_event';
import { EntityType, useTimelineEventsDetails } from '../../../containers/details';
import { useTimelineEventsDetails } from '../../../containers/details';
import { TimelineTabs } from '../../../../../common/types/timeline';
import { HostIsolationPanel } from '../../../../detections/components/host_isolation';
import { EndpointIsolateSuccess } from '../../../../common/components/endpoint/host_isolation';
Expand Down Expand Up @@ -50,10 +49,8 @@ const StyledEuiFlyoutBody = styled(EuiFlyoutBody)`
`;

interface EventDetailsPanelProps {
alertConsumers?: AlertConsumers[];
browserFields: BrowserFields;
docValueFields: DocValueFields[];
entityType?: EntityType;
expandedEvent: {
eventId: string;
indexName: string;
Expand All @@ -68,20 +65,16 @@ interface EventDetailsPanelProps {
}

const EventDetailsPanelComponent: React.FC<EventDetailsPanelProps> = ({
alertConsumers,
browserFields,
docValueFields,
entityType,
expandedEvent,
handleOnEventClosed,
isFlyoutView,
tabType,
timelineId,
}) => {
const [loading, detailsData] = useTimelineEventsDetails({
alertConsumers,
docValueFields,
entityType,
indexName: expandedEvent.indexName ?? '',
eventId: expandedEvent.eventId ?? '',
skip: !expandedEvent.eventId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import React, { useCallback, useMemo } from 'react';
import { useDispatch } from 'react-redux';
import { EuiFlyout, EuiFlyoutProps } from '@elastic/eui';
import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';

import { timelineActions, timelineSelectors } from '../../store/timeline';
import { timelineDefaults } from '../../store/timeline/defaults';
import { BrowserFields, DocValueFields } from '../../../common/containers/source';
Expand All @@ -18,13 +16,10 @@ import { useDeepEqualSelector } from '../../../common/hooks/use_selector';
import { EventDetailsPanel } from './event_details';
import { HostDetailsPanel } from './host_details';
import { NetworkDetailsPanel } from './network_details';
import { EntityType } from '../../containers/details';

interface DetailsPanelProps {
alertConsumers?: AlertConsumers[];
browserFields: BrowserFields;
docValueFields: DocValueFields[];
entityType?: EntityType;
handleOnPanelClosed?: () => void;
isFlyoutView?: boolean;
tabType?: TimelineTabs;
Expand All @@ -38,10 +33,8 @@ interface DetailsPanelProps {
*/
export const DetailsPanel = React.memo(
({
alertConsumers,
browserFields,
docValueFields,
entityType,
handleOnPanelClosed,
isFlyoutView,
tabType,
Expand Down Expand Up @@ -77,10 +70,8 @@ export const DetailsPanel = React.memo(
panelSize = 'm';
visiblePanel = (
<EventDetailsPanel
alertConsumers={alertConsumers}
browserFields={browserFields}
docValueFields={docValueFields}
entityType={entityType}
expandedEvent={currentTabDetail?.params}
handleOnEventClosed={closePanel}
isFlyoutView={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/target/alerts_as_data_rbac';
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,8 +16,6 @@ import {
EuiPanel,
EuiHorizontalRule,
} from '@elastic/eui';
import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';

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

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

interface UsernameWithAvatar {
username: string;
}
Expand Down Expand Up @@ -174,7 +170,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/target/alerts_as_data_rbac';
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/target/alerts_as_data_rbac';
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 @@ -9,7 +9,6 @@ import { isEmpty, noop } from 'lodash/fp';
import { useCallback, useEffect, useRef, useState } from 'react';
import deepEqual from 'fast-deep-equal';
import { Subscription } from 'rxjs';
import { AlertConsumers } from '@kbn/rule-data-utils/target/alerts_as_data_rbac';

import { inputsModel } from '../../../common/store';
import { useKibana } from '../../../common/lib/kibana';
Expand All @@ -24,28 +23,18 @@ import { isCompleteResponse, isErrorResponse } from '../../../../../../../src/pl
import { useAppToasts } from '../../../common/hooks/use_app_toasts';
import * as i18n from './translations';

export enum EntityType {
ALERTS = 'alerts',
EVENTS = 'events',
}
export interface EventsArgs {
detailsData: TimelineEventsDetailsItem[] | null;
}

export interface UseTimelineEventsDetailsProps {
alertConsumers?: AlertConsumers[];
entityType?: EntityType;
docValueFields: DocValueFields[];
indexName: string;
eventId: string;
skip: boolean;
}

const EMPTY_ARRAY: AlertConsumers[] = [];

export const useTimelineEventsDetails = ({
alertConsumers = EMPTY_ARRAY,
entityType = EntityType.EVENTS,
docValueFields,
indexName,
eventId,
Expand Down Expand Up @@ -115,9 +104,7 @@ export const useTimelineEventsDetails = ({
setTimelineDetailsRequest((prevRequest) => {
const myRequest = {
...(prevRequest ?? {}),
alertConsumers,
docValueFields,
entityType,
indexName,
eventId,
factoryQueryType: TimelineEventsQueries.details,
Expand All @@ -127,7 +114,7 @@ export const useTimelineEventsDetails = ({
}
return prevRequest;
});
}, [alertConsumers, docValueFields, entityType, eventId, indexName]);
}, [docValueFields, eventId, indexName]);

useEffect(() => {
timelineDetailsSearch(timelineDetailsRequest);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/timelines/common/utils/field_formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getDataFromSourceHits = (
category?: string,
path?: string
): TimelineEventsDetailsItem[] =>
Object.keys(sources ?? {}).reduce<TimelineEventsDetailsItem[]>((accumulator, source) => {
Object.keys(sources).reduce<TimelineEventsDetailsItem[]>((accumulator, source) => {
const item: EventSource = get(source, sources);
if (Array.isArray(item) || isString(item) || isNumber(item)) {
const field = path ? `${path}.${source}` : source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const timelineEventsDetails: TimelineFactory<TimelineEventsQueries.detail
const inspect = {
dsl: [inspectStringifyObject(buildTimelineDetailsQuery(indexName, eventId, docValueFields))],
};

if (response.isRunning) {
return {
...response,
Expand Down

0 comments on commit 2ab5c2c

Please sign in to comment.