Skip to content

Commit

Permalink
Added pinned agent mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanGarriuz committed Mar 8, 2024
1 parent 796b3a8 commit b03f72d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -241,7 +243,7 @@ export const ModulesDefaults = {
id: 'dashboard',
name: 'Dashboard',
buttons: [ButtonModuleExploreAgent, ButtonModuleGenerateReport],
component: DashboardMITRE,
component: withPinnedAgent(DashboardMITRE),
},
{
id: 'intelligence',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ 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();

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<DashboardThreatHuntingProps> = ({
pinnedAgent,
}) => {
const MITRE_INDEX_PATTERN_ID = WAZUH_ALERTS_PATTERN;

const { searchBarProps } = useSearchBar({
Expand All @@ -33,7 +40,7 @@ export const DashboardMITRE: React.FC = () => {
<DashboardByRenderer
input={{
viewMode: ViewMode.VIEW,
panels: getDashboardPanels(MITRE_INDEX_PATTERN_ID),
panels: getDashboardPanels(MITRE_INDEX_PATTERN_ID, !!pinnedAgent),
isFullScreenMode: false,
filters: searchBarProps.filters ?? [],
useMargins: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,57 @@ const getVisStateTechniqueByAgent = (indexPatternId: string) => {

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,
Expand Down Expand Up @@ -715,4 +760,5 @@ export const getDashboardPanels = (
},
},
};
return pinnedAgent ? pinnedAgentPanels : panels;
};

0 comments on commit b03f72d

Please sign in to comment.