Skip to content

Commit

Permalink
fixed trigger edit; show callout in detector details view
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan committed Dec 17, 2024
1 parent bd32ac6 commit b0a4404
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ export default class AlertConditionPanel extends Component<
this.prepareMessage(false /* updateMessage */, true /* onMount */);
}

componentDidUpdate(
prevProps: Readonly<AlertConditionPanelProps>,
_prevState: Readonly<AlertConditionPanelState>
): void {
if (prevProps.rulesOptions !== this.props.rulesOptions) {
const selectedNames: EuiComboBoxOptionOption<string>[] = [];
this.props.alertCondition.ids.forEach((ruleId) => {
const rule = this.props.rulesOptions.find((option) => option.id === ruleId);
if (rule) {
selectedNames.push({ label: rule.name, value: ruleId });
}
});
this.setState({ selectedNames });
}
}

onDetectionTypeChange(detectionType: 'rules' | 'threat_intel', enabled: boolean) {
const detectionTypes = new Set(this.props.alertCondition.detection_types);
enabled ? detectionTypes.add(detectionType) : detectionTypes.delete(detectionType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiSmallButton, EuiSpacer, EuiLink, EuiIcon, EuiText } from '@elastic/eui';
import { EuiSmallButton, EuiSpacer, EuiLink, EuiIcon, EuiText, EuiCallOut } from '@elastic/eui';
import React from 'react';
import { ContentPanel } from '../../../../components/ContentPanel';
import { createTextDetailsGroup, parseSchedule } from '../../../../utils/helpers';
import { createTextDetailsGroup, navigateToRoute, parseSchedule } from '../../../../utils/helpers';
import moment from 'moment';
import { DEFAULT_EMPTY_DATA, logTypesWithDashboards } from '../../../../utils/constants';
import {
DEFAULT_EMPTY_DATA,
logTypesWithDashboards,
ROUTES,
THREAT_INTEL_NAV_ID,
} from '../../../../utils/constants';
import { Detector } from '../../../../../types';
import { getLogTypeLabel } from '../../../LogTypes/utils/helpers';
import { RouteComponentProps } from 'react-router-dom';

export interface DetectorBasicDetailsViewProps {
detector: Detector;
Expand All @@ -20,6 +26,7 @@ export interface DetectorBasicDetailsViewProps {
last_update_time?: number;
onEditClicked: () => void;
isEditable: boolean;
history: RouteComponentProps['history'];
}

export const DetectorBasicDetailsView: React.FC<DetectorBasicDetailsViewProps> = ({
Expand All @@ -29,6 +36,7 @@ export const DetectorBasicDetailsView: React.FC<DetectorBasicDetailsViewProps> =
rulesCanFold,
children,
dashboardId,
history,
onEditClicked,
isEditable = true,
}) => {
Expand All @@ -51,7 +59,10 @@ export const DetectorBasicDetailsView: React.FC<DetectorBasicDetailsViewProps> =
actions={
isEditable
? [
<EuiSmallButton onClick={onEditClicked} data-test-subj={'edit-detector-basic-details'}>
<EuiSmallButton
onClick={onEditClicked}
data-test-subj={'edit-detector-basic-details'}
>
Edit
</EuiSmallButton>,
]
Expand Down Expand Up @@ -101,6 +112,27 @@ export const DetectorBasicDetailsView: React.FC<DetectorBasicDetailsViewProps> =
{createTextDetailsGroup([
{ label: 'Threat intelligence', content: threat_intel_enabled ? 'Enabled' : 'Disabled' },
])}
{threat_intel_enabled && (
<EuiCallOut
size="s"
title={
<EuiText>
<p>
To match multiple data sources against known indicators of compromise we recommend
to configure logs scan with threat intel sources on the
<EuiLink
onClick={() =>
navigateToRoute(history, THREAT_INTEL_NAV_ID, ROUTES.THREAT_INTEL_OVERVIEW)
}
>
Threat intelligence
</EuiLink>{' '}
page and removing threat intel feeds from the detectors.
</p>
</EuiText>
}
/>
)}
{rulesCanFold ? children : null}
</ContentPanel>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DetectorRulesView } from '../../components/DetectorRulesView/DetectorRu
import { RuleItem } from '../../../CreateDetector/components/DefineDetector/components/DetectionRules/types/interfaces';
import { NotificationsStart } from 'opensearch-dashboards/public';
import { Detector } from '../../../../../types';
import { RouteComponentProps } from 'react-router-dom';

export interface DetectorDetailsViewProps {
detector: Detector;
Expand All @@ -21,6 +22,7 @@ export interface DetectorDetailsViewProps {
editBasicDetails: () => void;
editDetectorRules: (enabledRules: RuleItem[], allRuleItems: RuleItem[]) => void;
isEditable?: boolean;
history: RouteComponentProps['history'];
}

export interface DetectorDetailsViewState {}
Expand Down
17 changes: 12 additions & 5 deletions public/pages/Overview/containers/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiPopover,
EuiSuperDatePicker,
EuiTitle,
EuiSpacer,
EuiSmallButton,
EuiCard,
EuiPanel,
Expand Down Expand Up @@ -107,7 +104,11 @@ export const Overview: React.FC<OverviewProps> = (props) => {
const isSecurityAnalyticsUseCase = currentNavGroup?.id === SECURITY_ANALYTICS_USE_CASE_ID;

useEffect(() => {
setBreadcrumbs(isSecurityAnalyticsUseCase ? [ BREADCRUMBS.OVERVIEW] : [{...BREADCRUMBS.OVERVIEW, text: 'Security Analytics overview'}]);
setBreadcrumbs(
isSecurityAnalyticsUseCase
? [BREADCRUMBS.OVERVIEW]
: [{ ...BREADCRUMBS.OVERVIEW, text: 'Security Analytics overview' }]
);
overviewViewModelActor.registerRefreshHandler(updateState, true /* allowPartialResults */);
overviewViewModelActor.registerRefreshHandler(
onLoadingComplete,
Expand Down Expand Up @@ -273,7 +274,13 @@ export const Overview: React.FC<OverviewProps> = (props) => {
<EuiFlexGroup gutterSize="m">
{getOverviewsCardsProps().map((p, idx) => (
<EuiFlexItem key={idx}>
<EuiCard {...p} layout="vertical" textAlign="left" titleElement='h4' titleSize='s'/>
<EuiCard
{...p}
layout="vertical"
textAlign="left"
titleElement="h4"
titleSize="s"
/>
</EuiFlexItem>
))}
</EuiFlexGroup>
Expand Down

0 comments on commit b0a4404

Please sign in to comment.