From 70d47df99ff8b61fdbc191a5012a5834ce585b0c Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Mon, 29 Jul 2024 20:47:22 +0200 Subject: [PATCH 1/8] Add switch route to flyout --- .../overview/mitre/intelligence/resource.tsx | 31 +++++++++++++------ .../overview/mitre/intelligence/resources.tsx | 11 +++++-- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/plugins/main/public/components/overview/mitre/intelligence/resource.tsx b/plugins/main/public/components/overview/mitre/intelligence/resource.tsx index 575a34ded8..d5250efe45 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/resource.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/resource.tsx @@ -19,6 +19,7 @@ import { UI_LOGGER_LEVELS } from '../../../../../common/constants'; import { UI_ERROR_SEVERITIES } from '../../../../react-services/error-orchestrator/types'; import { getErrorOrchestrator } from '../../../../react-services/common-services'; import NavigationService from '../../../../react-services/navigation-service'; +import { Route, Switch } from '../../../router-search'; export const ModuleMitreAttackIntelligenceResource = ({ label, @@ -40,12 +41,11 @@ export const ModuleMitreAttackIntelligenceResource = ({ const idToRedirect = urlParams.get('idToRedirect'); const endpoint = `/mitre/${redirectTab}?q=external_id=${idToRedirect}`; getMitreItemToRedirect(endpoint); - NavigationService.getInstance().updateAndNavigateSearchParams({ - tabRedirect: null, - idToRedirect: null, - }); } - }, []); + }, [ + navigationService.getParams().has('tabRedirect'), + navigationService.getParams().has('idToRedirect'), + ]); const getMitreItemToRedirect = async endpoint => { try { @@ -73,6 +73,10 @@ export const ModuleMitreAttackIntelligenceResource = ({ const closeFlyout = useCallback(() => { setDetails(null); + NavigationService.getInstance().updateAndNavigateSearchParams({ + tabRedirect: null, + idToRedirect: null, + }); }, []); return ( @@ -91,11 +95,18 @@ export const ModuleMitreAttackIntelligenceResource = ({ }} /> {details && ( - closeFlyout()} - onSelectResource={setDetails} - /> + + ( + closeFlyout()} + onSelectResource={setDetails} + /> + )} + /> + )} ); diff --git a/plugins/main/public/components/overview/mitre/intelligence/resources.tsx b/plugins/main/public/components/overview/mitre/intelligence/resources.tsx index f85b730c29..f394aceb53 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/resources.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/resources.tsx @@ -22,6 +22,8 @@ import { } from '../../../../../common/constants'; import { UI_ERROR_SEVERITIES } from '../../../../react-services/error-orchestrator/types'; import { getErrorOrchestrator } from '../../../../react-services/common-services'; +import { mitreAttack } from '../../../../utils/applications'; +import { WzLink } from '../../../wz-link/wz-link'; const getMitreAttackIntelligenceSuggestions = async ( endpoint: string, @@ -103,8 +105,13 @@ function buildResource(label: string) { field: 'external_id', name: 'ID', width: '12%', - render: (value, item) => ( - openResourceDetails(item)}>{value} + render: value => ( + + {value} + ), }, { From 3d45aa0437d596957050cf90ce5a120f1ab3e545 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Tue, 30 Jul 2024 16:37:13 +0200 Subject: [PATCH 2/8] Update redirections --- .../overview/mitre/intelligence/resource.tsx | 1 - .../overview/mitre/intelligence/resources.tsx | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/main/public/components/overview/mitre/intelligence/resource.tsx b/plugins/main/public/components/overview/mitre/intelligence/resource.tsx index d5250efe45..37b3451573 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/resource.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/resource.tsx @@ -74,7 +74,6 @@ export const ModuleMitreAttackIntelligenceResource = ({ const closeFlyout = useCallback(() => { setDetails(null); NavigationService.getInstance().updateAndNavigateSearchParams({ - tabRedirect: null, idToRedirect: null, }); }, []); diff --git a/plugins/main/public/components/overview/mitre/intelligence/resources.tsx b/plugins/main/public/components/overview/mitre/intelligence/resources.tsx index f394aceb53..e55a088763 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/resources.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/resources.tsx @@ -15,7 +15,6 @@ import { WzRequest } from '../../../../react-services'; import { Markdown } from '../../../common/util'; import { formatUIDate } from '../../../../react-services'; import React from 'react'; -import { EuiLink } from '@elastic/eui'; import { SEARCH_BAR_WQL_VALUE_SUGGESTIONS_COUNT, UI_LOGGER_LEVELS, @@ -100,7 +99,7 @@ function buildResource(label: string) { apiEndpoint: endpoint, fieldName: 'name', initialSortingField: 'name', - tableColumnsCreator: openResourceDetails => [ + tableColumnsCreator: () => [ { field: 'external_id', name: 'ID', @@ -108,7 +107,7 @@ function buildResource(label: string) { render: value => ( {value} @@ -120,7 +119,12 @@ function buildResource(label: string) { sortable: true, width: '30%', render: (value, item) => ( - openResourceDetails(item)}>{value} + + {value} + ), }, { From b30952ae2c8257e6765dd5fb1bc405f5bcd589f8 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Tue, 30 Jul 2024 16:38:22 +0200 Subject: [PATCH 3/8] Add tabRedirect to know subTab --- .../mitre/intelligence/intelligence.tsx | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/plugins/main/public/components/overview/mitre/intelligence/intelligence.tsx b/plugins/main/public/components/overview/mitre/intelligence/intelligence.tsx index 5372e0185e..287675a0b8 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/intelligence.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/intelligence.tsx @@ -17,17 +17,19 @@ import { EuiPanel } from '@elastic/eui'; import { MitreAttackResources } from './resources'; import { ModuleMitreAttackIntelligenceLeftPanel } from './intelligence_left_panel'; import { ModuleMitreAttackIntelligenceRightPanel } from './intelligence_right_panel'; -import { useAsyncAction } from '../../../common/hooks'; +import { useAsyncAction, useRouterSearch } from '../../../common/hooks'; import { WzRequest } from '../../../../react-services'; import { PanelSplit } from '../../../common/panels'; import { withUserAuthorizationPrompt } from '../../../common/hocs'; import { compose } from 'redux'; +import NavigationService from '../../../../react-services/navigation-service'; export const ModuleMitreAttackIntelligence = compose( withUserAuthorizationPrompt([{ action: 'mitre:read', resource: '*:*:*' }]), )(() => { + const paramTabRedirect = useRouterSearch().tabRedirect; const [selectedResource, setSelectedResource] = useState( - MitreAttackResources[0].id, + paramTabRedirect || MitreAttackResources[0].id, ); const [searchTermAllResources, setSearchTermAllResources] = useState(''); const searchTermAllResourcesLastSearch = useRef(''); @@ -50,8 +52,8 @@ export const ModuleMitreAttackIntelligence = compose( params: { ...(searchTerm ? { - q: fields.map(key => `${key}~${searchTerm}`).join(','), - } + q: fields.map(key => `${key}~${searchTerm}`).join(','), + } : {}), limit: limitResults, }, @@ -70,13 +72,13 @@ export const ModuleMitreAttackIntelligence = compose( setResourceFilters({ ...(searchTermAllResourcesLastSearch.current ? { - q: fields - .map( - key => - `${key}~${searchTermAllResourcesLastSearch.current}`, - ) - .join(','), - } + q: fields + .map( + key => + `${key}~${searchTermAllResourcesLastSearch.current}`, + ) + .join(','), + } : {}), }); setSelectedResource(resource.id); @@ -93,19 +95,26 @@ export const ModuleMitreAttackIntelligence = compose( ); useEffect(() => { - const urlParams = new URLSearchParams(location.href); - const redirectTab = urlParams.get('tabRedirect'); - if (redirectTab) { - setSelectedResource(redirectTab); + if (!paramTabRedirect) { + NavigationService.getInstance().updateAndNavigateSearchParams({ + tabRedirect: selectedResource, + }); } }, []); + useEffect(() => { + setSelectedResource(paramTabRedirect); + }, [paramTabRedirect]); + const onSelectResource = useCallback( resourceID => { + NavigationService.getInstance().updateAndNavigateSearchParams({ + tabRedirect: resourceID, + }); setResourceFilters({}); setSelectedResource(prevSelectedResource => prevSelectedResource === resourceID && - searchTermAllResourcesUsed.current + searchTermAllResourcesUsed.current ? null : resourceID, ); @@ -118,7 +127,12 @@ export const ModuleMitreAttackIntelligence = compose( }, []); return ( - + Date: Tue, 30 Jul 2024 16:48:25 +0200 Subject: [PATCH 4/8] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 030de56af7..26ca45bdb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Improvement of the filter management system by implementing new standard modules [#6534](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6534) [#6772](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6772) [#6873](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6873) - Changed permalink field in the Events tab table in Virustotal to show an external link [#6839](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6839) - Changed the logging system to use the provided by the platform [#6161](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6161) +- Change the internal control from Mitre > intelligence > Table to a control via url. [#6882](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6882) ### Fixed From 2a61e3b0e90e8b7cdc6f0c2d105e1a4d76c185f0 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Tue, 30 Jul 2024 17:15:02 +0200 Subject: [PATCH 5/8] Fix(intelligence test): Mock service --- .../mitre/intelligence/intelligence.test.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/main/public/components/overview/mitre/intelligence/intelligence.test.tsx b/plugins/main/public/components/overview/mitre/intelligence/intelligence.test.tsx index 8528b41f58..2f18e4262d 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/intelligence.test.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/intelligence.test.tsx @@ -46,7 +46,18 @@ jest.mock('react', () => ({ })); jest.mock('../../../../react-services/navigation-service', () => ({ - getInstance() {}, + getInstance() { + return { + getLocation: () => { + return { search: '?tabRedirect=groups' }; + }, + getParams: () => { + return { + has: () => 'groups', + }; + }, + }; + }, })); const mockStore = configureMockStore(); From bc8a973fce188227916617db01ab1ad787114712 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 31 Jul 2024 14:54:16 +0200 Subject: [PATCH 6/8] Fix(intelligence): Fix comment --- .../components/overview/mitre/intelligence/intelligence.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/main/public/components/overview/mitre/intelligence/intelligence.tsx b/plugins/main/public/components/overview/mitre/intelligence/intelligence.tsx index 287675a0b8..fa20f0e82f 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/intelligence.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/intelligence.tsx @@ -100,9 +100,6 @@ export const ModuleMitreAttackIntelligence = compose( tabRedirect: selectedResource, }); } - }, []); - - useEffect(() => { setSelectedResource(paramTabRedirect); }, [paramTabRedirect]); From 4b79664e7c07925bd0323065fdf2208c339a218a Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 31 Jul 2024 14:54:52 +0200 Subject: [PATCH 7/8] Change(Visualizations): Change donut: true --- .../components/overview/github/dashboards/dashboard-panels.ts | 2 +- .../components/overview/office/panel/config/visualizations.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/main/public/components/overview/github/dashboards/dashboard-panels.ts b/plugins/main/public/components/overview/github/dashboards/dashboard-panels.ts index 1eb52f1b8a..4c8d85e059 100644 --- a/plugins/main/public/components/overview/github/dashboards/dashboard-panels.ts +++ b/plugins/main/public/components/overview/github/dashboards/dashboard-panels.ts @@ -600,7 +600,7 @@ const getVisStateAgentTopOrganizationsByAlertCount = ( addTooltip: true, addLegend: true, legendPosition: 'right', - isDonut: false, + isDonut: true, labels: { show: false, values: true, diff --git a/plugins/main/public/components/overview/office/panel/config/visualizations.ts b/plugins/main/public/components/overview/office/panel/config/visualizations.ts index 1d8a7567cc..4d449d0c1d 100644 --- a/plugins/main/public/components/overview/office/panel/config/visualizations.ts +++ b/plugins/main/public/components/overview/office/panel/config/visualizations.ts @@ -90,7 +90,7 @@ export const getVisStateOfficeTopsEventsPie = (indexPatternId: string) => { addTooltip: true, addLegend: true, legendPosition: 'right', - isDonut: false, + isDonut: true, labels: { show: false, values: true, From 4cd1b2616b194d62c672e679535c47c8b63517d5 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 31 Jul 2024 14:58:39 +0200 Subject: [PATCH 8/8] Fix(tableColumnsCreator): remove parameter unused --- .../public/components/overview/mitre/intelligence/resource.tsx | 2 +- .../overview/mitre/intelligence/resource_detail_flyout.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/main/public/components/overview/mitre/intelligence/resource.tsx b/plugins/main/public/components/overview/mitre/intelligence/resource.tsx index 37b3451573..a49a6f4f41 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/resource.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/resource.tsx @@ -69,7 +69,7 @@ export const ModuleMitreAttackIntelligenceResource = ({ } }; - const tableColumns = useMemo(() => tableColumnsCreator(setDetails), []); + const tableColumns = useMemo(() => tableColumnsCreator(), []); const closeFlyout = useCallback(() => { setDetails(null); diff --git a/plugins/main/public/components/overview/mitre/intelligence/resource_detail_flyout.tsx b/plugins/main/public/components/overview/mitre/intelligence/resource_detail_flyout.tsx index a043af9897..57299494f8 100644 --- a/plugins/main/public/components/overview/mitre/intelligence/resource_detail_flyout.tsx +++ b/plugins/main/public/components/overview/mitre/intelligence/resource_detail_flyout.tsx @@ -95,7 +95,7 @@ export const ModuleMitreAttackIntelligenceFlyout = ({ { startReference.current?.scrollIntoView(); }}