wazuh / wazuh-dashboard-plugins

Plugins for Wazuh Dashboard
https://wazuh.com/
GNU General Public License v2.0
429 stars 176 forks source link

[Remove discover] Implement embeddable dashboard on Threat hunting module #6478

Closed asteriscos closed 5 months ago

asteriscos commented 6 months ago

Description

We have to implement the embeddable dashboard on Threat hunting -> dashboard tab and deprecate any use of kibana-integrations components.

[!WARNING]
The embeddable panel id must be unique including general and agents visualizations. Otherwise, the visualizations will not refresh when we pin an agent, because they are cached by id

Current Threat Hunting screens ![TH_A](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/23f8b9f2-5bfe-4b91-8c00-15e481999088) ![TH_B](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/854c0521-712d-4cb4-ba8e-9dd9225d3d70) ![TH_C](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/9a5ceb88-5187-4262-8d25-be39e161c5da) ![TH_A_Agent](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/3ef8798e-2d81-46f6-99eb-4388779410fb) ![TH_B_Agent](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/ac86334d-e6df-455a-b945-8f98148e137d)

Tasks

Source task

jbiset commented 6 months ago

Update 06/03/2024

Progress was made by migrating the Threat Hunting overview definitions. The visualizations are already made with embeddables. Likewise, the visualizations are integrated with the searchbar bidirectionally. To continue:

Evidence

image

jbiset commented 6 months ago

Update 07/03/2024

Added the withPinnedAgent HOC to add the pinnedAgent prop that allows DashboardThreatHunting to know which panels to render based on whether or not an agent is pinned. This pinnedAgent prop is then used as a parameter of the getDashboardPanels method which will return the corresponding panels depending on whether or not there is a pinned agent. It is important to note that changing the structure of normal panels to the panels of a pinned agent should not share the ids of their panels. Below is an example of each one:

[!NOTE]
The examples below only have the definitions changed from the first two visualizations. So does the screenshot shown below.

Structure of normal panels

  const panels = {
    '1': {
      gridData: {
        w: 28,
        h: 13,
        x: 0,
        y: 0,
        i: '1',
      },
      type: 'visualization',
      explicitInput: {
        id: '1',
        savedVis: getVisStateTop10AlertLevelEvolution(indexPatternId),
      },
    },
    '2': {
      gridData: {
        w: 20,
        h: 13,
        x: 28,
        y: 0,
        i: '2',
      },
      type: 'visualization',
      explicitInput: {
        id: '2',
        savedVis: getVisStateTop10MITREATTACKS(indexPatternId),
      },
    },
    '3': {
      gridData: {
        w: 15,
        h: 12,
        x: 0,
        y: 13,
        i: '3',
      },
      type: 'visualization',
      explicitInput: {
        id: '3',
        savedVis: getVisStateTop5Agents(indexPatternId),
      },
    },
    '4': {
      gridData: {
        w: 33,
        h: 12,
        x: 15,
        y: 13,
        i: '4',
      },
      type: 'visualization',
      explicitInput: {
        id: '4',
        savedVis: getVisStateAlertEvolutionTop5Agents(indexPatternId),
      },
    },
  };

Structure of panels with pinned agent

  const pinnedAgentPanels = {
    '5': {
      gridData: {
        w: 24,
        h: 13,
        x: 0,
        y: 0,
        i: '5',
      },
      type: 'visualization',
      explicitInput: {
        id: '5',
        savedVis:
          getVisStatePinnedAgentTop10AlertGroupsEvolution(indexPatternId),
      },
    },
    '6': {
      gridData: {
        w: 24,
        h: 13,
        x: 24,
        y: 0,
        i: '6',
      },
      type: 'visualization',
      explicitInput: {
        id: '6',
        savedVis: getVisStateTop5Alerts(indexPatternId),
      },
    },
    '3': {
      gridData: {
        w: 15,
        h: 12,
        x: 0,
        y: 13,
        i: '3',
      },
      type: 'visualization',
      explicitInput: {
        id: '3',
        savedVis: getVisStateTop5Agents(indexPatternId),
      },
    },
    '4': {
      gridData: {
        w: 33,
        h: 12,
        x: 15,
        y: 13,
        i: '4',
      },
      type: 'visualization',
      explicitInput: {
        id: '4',
        savedVis: getVisStateAlertEvolutionTop5Agents(indexPatternId),
      },
    },
  };

Capture showing the change of the dashboard depending on whether or not there is an agent pinned

Evidence_Change_Pinned_Agent.webm

jbiset commented 6 months ago

Update 08/03/2024

The aesthetics of the KPIs were adjusted using embeddable visualizations. It was decided to use embeddable visualizations for the KPIs to unlink them from the previous version and maintain a standard version to display the KPIs. Finished migrating visualization definitions when an agent is pinned Visualizations are changed from pie to donut Interaction with KPIs is analyzed so that it is filtered

It is analyzed that the queries for the new KPIs are correct according to the previous queries. **Total metric** ![Metric-Total_Endpoint](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/860c297f-705d-4f40-91af-dd63dedee9e4) **Level 12 or Above metric** ![Metric-Leve12orAbove_Endpoint](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/8fda79df-7555-453a-9fcc-88745592e41e) **Authentication failure metric** ![Metric-AuthenticationFailure_Endpoint](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/a818319a-8e73-4181-9d44-1611f12115bc) **Authentication success metric** ![Metric-AuthenticationSuccess_Endpoint](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/e89ef412-8a44-4074-9a72-a51c16de5ab2)

To continue:

Current screen without agent pinned

image

Current screen with pinned agent

image

jbiset commented 6 months ago

Update 13/03/2024

Evidence

Evidence_Changes_2024-03-13.webm

jbiset commented 5 months ago

Update 18/04/2024

Hide alerts and allow agents evidence

image

image

Current screen

image

Pinned agent behavior

Evidence_Pinned_Agent_2024-04-18.webm

jbiset commented 5 months ago

Update 19/04/2024

jbiset commented 5 months ago

Update 22/04/2024

Current behavior

Evidence_1.webm

jbiset commented 5 months ago

Update 24/04/2024