wazuh-dashboard-plugins icon indicating copy to clipboard operation
wazuh-dashboard-plugins copied to clipboard

Unpinning the agent from the menu is not removing the url param

Open frankeros opened this issue 3 years ago • 3 comments

Wazuh Elastic
4.x 7.x

Description Unpinning the agent from the menu tool is not removing the agent param from the URL, this is causing that the agent has been pinned again after refreshing the page.

Steps to reproduce

  1. Go to 'Agents'
  2. Click on one agent
  3. Go to 'Modules / Office365'
  4. Click on unpin button from the menu
  5. Refresh the page
  6. See the agent pinned again.

Screenshots

https://user-images.githubusercontent.com/26828184/129067680-c79b1d34-67db-4bc2-b0bb-19443448c3ac.mp4

frankeros avatar Aug 11 '21 16:08 frankeros

Research

I was researching about the problem and:

  • I could remove from the URL the agentId query param when using the Unpin agent button displayed on the Office 365 HOC.
  • But, I could not get to remove it using the button on the Wazuh menu when there is an agent pinned image

I attach a patch in that I am working to get a solution for this issue. It contains a workaround attaching a method to the $rootScope variable to be accessible in the WzMenu component because it doesn't receive the .setAgent method defined in https://github.com/wazuh/wazuh-kibana-app/blob/feature/Office365/public/controllers/overview/overview.js

❗ The method removeAgentsFilter in the https://github.com/wazuh/wazuh-kibana-app/blob/feature/Office365/public/components/wz-agent-selector/wz-agent-selector.js#L91-L107 defined the action to do when unpinning the agent from the agent selector and there is an agent pinned. This button could need some logic to remove the agentId query param too. We should check it image

Patch: remove_agentid_query_param_url_unppining_agent.patch.txt

I took a child branch from feature/office365. You should be able to apply the patch to a branch like that.

Apply the patch with:

git apply path/to/remove_agentid_query_param_url_unppining_agent.patch.txt

Annotations:

  • I am not sure if the .setAgent defined in the OverviewController is required to use. I could not get some more clear. We should research if there is a cleaner solution and review the required logic to solve the problem.

Desvelao avatar Aug 13 '21 16:08 Desvelao

I have found a bug checking this issue, when you pin an agent in Security Events or in any other part of Wazuh, the dashboards appears without any data even though there are data.

image (18)

Current state of the issue: I am trying to develop a better form to use of the method setAgent and trying to figure out what is happening with the blank visualizations, because there aren't any errors in terminal

CPAlejandro avatar Sep 09 '21 15:09 CPAlejandro

Today's feedback

  • Trying to upgrade Antonio's solution, trying with methods of Angular 1, but without solution because we are complicating the solution and extend the code.

  • Trying to find out the error that are making that visualizations are blank when we pin an agent

CPAlejandro avatar Sep 13 '21 15:09 CPAlejandro