From b03f72d11f17296d5a7e828d17e147b2ac803700 Mon Sep 17 00:00:00 2001 From: JuanGarriuz Date: Fri, 8 Mar 2024 11:25:11 +0100 Subject: [PATCH] Added pinned agent mode --- .../common/modules/modules-defaults.js | 4 +- .../overview/mitre/dashboard/dashboard.tsx | 11 ++++- .../mitre/dashboard/dashboard_panels.ts | 48 ++++++++++++++++++- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/plugins/main/public/components/common/modules/modules-defaults.js b/plugins/main/public/components/common/modules/modules-defaults.js index eb92f7cf79..97e0cda856 100644 --- a/plugins/main/public/components/common/modules/modules-defaults.js +++ b/plugins/main/public/components/common/modules/modules-defaults.js @@ -44,6 +44,8 @@ import { virustotalColumns } from '../../overview/virustotal/events/virustotal-c import { malwareDetectionColumns } from '../../overview/malware-detection/events/malware-detection-columns'; import { WAZUH_VULNERABILITIES_PATTERN } from '../../../../common/constants'; import { withVulnerabilitiesStateDataSource } from '../../overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern'; +import { withPinnedAgent } from '../hocs/withPinnedAgent'; +import dashboard from '../../agents/sca/dashboard/dashboard'; const DashboardTab = { id: 'dashboard', @@ -241,7 +243,7 @@ export const ModulesDefaults = { id: 'dashboard', name: 'Dashboard', buttons: [ButtonModuleExploreAgent, ButtonModuleGenerateReport], - component: DashboardMITRE, + component: withPinnedAgent(DashboardMITRE), }, { id: 'intelligence', diff --git a/plugins/main/public/components/overview/mitre/dashboard/dashboard.tsx b/plugins/main/public/components/overview/mitre/dashboard/dashboard.tsx index 42d9d0433b..50e1fe616e 100644 --- a/plugins/main/public/components/overview/mitre/dashboard/dashboard.tsx +++ b/plugins/main/public/components/overview/mitre/dashboard/dashboard.tsx @@ -5,6 +5,7 @@ import { getDashboardPanels } from './dashboard_panels'; import { I18nProvider } from '@osd/i18n/react'; import useSearchBar from '../../../common/search-bar/use-search-bar'; import { WAZUH_ALERTS_PATTERN } from '../../../../../common/constants'; +import { Filter } from '../../../../../../../src/plugins/data/common'; const plugins = getPlugins(); @@ -12,7 +13,13 @@ const SearchBar = getPlugins().data.ui.SearchBar; const DashboardByRenderer = plugins.dashboard.DashboardContainerByValueRenderer; -export const DashboardMITRE: React.FC = () => { +interface DashboardThreatHuntingProps { + pinnedAgent: Filter; +} + +export const DashboardMITRE: React.FC = ({ + pinnedAgent, +}) => { const MITRE_INDEX_PATTERN_ID = WAZUH_ALERTS_PATTERN; const { searchBarProps } = useSearchBar({ @@ -33,7 +40,7 @@ export const DashboardMITRE: React.FC = () => { { export const getDashboardPanels = ( indexPatternId: string, + pinnedAgent?: boolean, ): { [panelId: string]: DashboardPanelState< EmbeddableInput & { [k: string]: unknown } >; } => { - return { + const pinnedAgentPanels = { + '3': { + gridData: { + w: 16, + h: 12, + x: 0, + y: 12, + i: '3', + }, + type: 'visualization', + explicitInput: { + id: '3', + savedVis: getVisStateAttacksByTechnique(indexPatternId), + }, + }, + '4': { + gridData: { + w: 16, + h: 12, + x: 16, + y: 12, + i: '4', + }, + type: 'visualization', + explicitInput: { + id: '4', + savedVis: getVisStateTopTacticsByAgent(indexPatternId), + }, + }, + '5': { + gridData: { + w: 16, + h: 12, + x: 32, + y: 12, + i: '5', + }, + type: 'visualization', + explicitInput: { + id: '5', + savedVis: getVisStateTechniqueByAgent(indexPatternId), + }, + }, + }; + const panels = { '1': { gridData: { w: 36, @@ -715,4 +760,5 @@ export const getDashboardPanels = ( }, }, }; + return pinnedAgent ? pinnedAgentPanels : panels; };