Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent view Mitre ATT&CK exception #7116

Merged
merged 20 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed export formatted csv data with special characters from tables [#7048](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7048)
- Fixed column reordering feature [#7072](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7072)
- Fixed filter management to prevent hiding when adding multiple filters [#7077](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7077)
- Fixed the Mitre ATT&CK exception in the agent view and the ID, Tactics, Dashboard Icon and Event Icon redirects in the flyout [#7116](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7116)
- Fixed vulnerabilities inventory table scroll [#7118](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7118)
- Fixed the filter are displayed cropped on screens of 575px to 767px in vulnerability detection module [#7047](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7047)
- Fixed ability to filter from files inventory details flyout of File Integrity Monitoring [#7119](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7119)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import { FlyoutTechnique } from '../../../../overview/mitre/framework/components
import { getMitreCount } from './lib';
import { useAsyncActionRunOnStart, useTimeFilter } from '../../../hooks';
import NavigationService from '../../../../../react-services/navigation-service';
import { AppState } from '../../../../../react-services';
import { mitreAttack } from '../../../../../utils/applications';
import {
FILTER_OPERATOR,
PatternDataSourceFilterManager,
} from '../../../data-source/pattern/pattern-data-source-filter-manager';

const getTacticsData = async (agentId, timeFilter) => {
return await getMitreCount(agentId, timeFilter, undefined);
Expand Down Expand Up @@ -108,25 +114,48 @@ const MitreTopTacticsTechniques = ({
setShowTechniqueDetails('');
};

const openDiscover = (e, techniqueID) => {
NavigationService.getInstance().navigateToModule(e, 'overview', {
tab: 'mitre',
tabView: 'discover',
filters: { 'rule.mitre.id': techniqueID },
const goToDashboardWithFilter = async (e, techniqueID) => {
const indexPatternId = AppState.getCurrentPattern();
Desvelao marked this conversation as resolved.
Show resolved Hide resolved
const filters = [
PatternDataSourceFilterManager.createFilter(
FILTER_OPERATOR.IS,
`rule.mitre.id`,
techniqueID,
indexPatternId,
),
];

const params = `tab=mitre&tabView=dashboard&agentId=${agentId}&_g=${PatternDataSourceFilterManager.filtersToURLFormat(
filters,
)}`;
NavigationService.getInstance().navigateToApp(mitreAttack.id, {
path: `#/overview?${params}`,
});
};

const openDashboard = (e, techniqueID) => {
NavigationService.getInstance().navigateToModule(e, 'overview', {
tab: 'mitre',
tabView: 'dashboard',
filters: { 'rule.mitre.id': techniqueID },
const goToEventsWithFilter = async (e, techniqueID) => {
const indexPatternId = AppState.getCurrentPattern();
const filters = [
PatternDataSourceFilterManager.createFilter(
FILTER_OPERATOR.IS,
`rule.mitre.id`,
techniqueID,
indexPatternId,
),
];

const params = `tab=mitre&tabView=events&agentId=${agentId}&_g=${PatternDataSourceFilterManager.filtersToURLFormat(
filters,
)}`;
NavigationService.getInstance().navigateToApp(mitreAttack.id, {
path: `#/overview?${params}`,
});
};

return (
<FlyoutTechnique
openDashboard={(e, itemId) => openDashboard(e, itemId)}
openDiscover={(e, itemId) => openDiscover(e, itemId)}
openDashboard={(e, itemId) => goToDashboardWithFilter(e, itemId)}
openDiscover={(e, itemId) => goToEventsWithFilter(e, itemId)}
implicitFilters={[{ 'agent.id': agentId }]}
agentId={agentId}
onChangeFlyout={onChangeFlyout}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Find more information about this on the LICENSE file.
*/
import React, { useEffect, useState, useMemo } from 'react';
import React, { useEffect, useState, useMemo, Fragment } from 'react';
import $ from 'jquery';
import {
EuiFlyoutHeader,
Expand Down Expand Up @@ -39,14 +39,20 @@ import {
techniquesColumns,
agentTechniquesColumns,
} from './flyout-technique-columns';
import { PatternDataSource } from '../../../../../../../../components/common/data-source';
import {
FILTER_OPERATOR,
PatternDataSourceFilterManager,
PatternDataSource,
} from '../../../../../../../../components/common/data-source';
import { WazuhFlyoutDiscover } from '../../../../../../../common/wazuh-discover/wz-flyout-discover';
import { tFilterParams } from '../../../../mitre';
import TechniqueRowDetails from './technique-row-details';
import { buildPhraseFilter } from '../../../../../../../../../../../src/plugins/data/common';
import store from '../../../../../../../../redux/store';
import NavigationService from '../../../../../../../../react-services/navigation-service';
import { wzDiscoverRenderColumns } from '../../../../../../../common/wazuh-discover/render-columns';
import { AppState } from '../../../../../../../../react-services';
import { mitreAttack } from '../../../../../../../../utils/applications';
import { setFilters } from '../../../../../../../common/search-bar/set-filters';

type tFlyoutTechniqueProps = {
Expand Down Expand Up @@ -258,7 +264,43 @@ export const FlyoutTechnique = (props: tFlyoutTechniqueProps) => {
: addRenderColumn(techniquesColumns);
};

const renderBody = () => {
const goToTechniqueInIntellicense = async (e, currentTechnique) => {
const indexPatternId = AppState.getCurrentPattern();
const filters = [
PatternDataSourceFilterManager.createFilter(
FILTER_OPERATOR.IS,
`rule.mitre.id`,
currentTechnique,
indexPatternId,
),
];
const params = `tab=mitre&tabView=intelligence&tabRedirect=techniques&idToRedirect=${currentTechnique}&_g=${PatternDataSourceFilterManager.filtersToURLFormat(
filters,
)}`;
NavigationService.getInstance().navigateToApp(mitreAttack.id, {
path: `#/overview?${params}`,
});
};

const goToTacticInIntellicense = async (e, tactic) => {
const indexPatternId = AppState.getCurrentPattern();
const filters = [
PatternDataSourceFilterManager.createFilter(
FILTER_OPERATOR.IS,
`rule.mitre.id`,
tactic,
indexPatternId,
),
];
const params = `tab=mitre&tabView=intelligence&tabRedirect=tactics&idToRedirect=${
tactic.id
}&_g=${PatternDataSourceFilterManager.filtersToURLFormat(filters)}`;
NavigationService.getInstance().navigateToApp(mitreAttack.id, {
path: `#/overview?${params}`,
});
};

const renderBody = e => {
const { currentTechnique } = props;
const { techniqueData } = state;
const data = [
Expand All @@ -271,16 +313,7 @@ export const FlyoutTechnique = (props: tFlyoutTechniqueProps) => {
>
<EuiLink
onClick={e => {
NavigationService.getInstance().navigateToModule(
e,
'overview',
{
tab: 'mitre',
tabView: 'intelligence',
tabRedirect: 'techniques',
idToRedirect: currentTechnique,
},
);
goToTechniqueInIntellicense(e, currentTechnique);
e.stopPropagation();
}}
>
Expand All @@ -294,31 +327,22 @@ export const FlyoutTechnique = (props: tFlyoutTechniqueProps) => {
description: techniqueData.tactics
? techniqueData.tactics.map(tactic => {
return (
<>
<Fragment key={tactic.id}>
<EuiToolTip
position='top'
content={`Open ${tactic.name} details in the Intelligence section`}
>
<EuiLink
onClick={e => {
NavigationService.getInstance().navigateToModule(
e,
'overview',
{
tab: 'mitre',
tabView: 'intelligence',
tabRedirect: 'tactics',
idToRedirect: tactic.id,
},
);
goToTacticInIntellicense(e, tactic);
e.stopPropagation();
}}
>
{tactic.name}
</EuiLink>
</EuiToolTip>
<br />
</>
</Fragment>
);
})
: '',
Expand All @@ -332,12 +356,12 @@ export const FlyoutTechnique = (props: tFlyoutTechniqueProps) => {
<EuiFlyoutBody>
<EuiAccordion
id='details'
initialIsOpen={true}
buttonContent={
<EuiTitle size='s'>
<h3>Technique details</h3>
</EuiTitle>
}
initialIsOpen={true}
>
<div className='flyout-row details-row'>
<EuiFlexGroup direction='column' gutterSize='none'>
Expand Down Expand Up @@ -405,7 +429,7 @@ export const FlyoutTechnique = (props: tFlyoutTechniqueProps) => {
DataSource={PatternDataSource}
tableColumns={getDiscoverColumns()}
filterManager={filterManager}
initialFetchFilters={filterParams.filters}
initialFetchFilters={filterParams?.filters || []}
expandedRowComponent={expandedRow}
/>
</EuiAccordion>
Expand Down
Loading
Loading