wazuh / wazuh-dashboard-plugins

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

Change log collector socket configuration response property #6636

Closed asteriscos closed 6 months ago

asteriscos commented 6 months ago
Wazuh Rev Browser
4.9.0 00 -

Description

A change has been made in the endpoint: https://documentation.wazuh.com/current/user-manual/api/reference.html#operation/api.controllers.agent_controller.get_agent_config

This change involves a property name change in the response of the API:

{
  "data": {
    "target": [
      {
        "name": "custom_socket",
        "location": "/var/run/custom.sock",
        "mode": "tcp",
        "prefix": "custom_syslog: "
      },
      {
        "name": "test_socket",
        "location": "/var/run/test.sock",
        "mode": "udp"
      }
    ]
  },
  "error": 0
}

As we can see, the name of the property target has been changed to socket, therefore we need to modify the component that parses the response to read the new value.

Task

Additional context

Origin issue:

The log-collection socket file is: https://github.com/wazuh/wazuh-dashboard-plugins/blob/4.9.0/plugins/main/public/controllers/management/components/management/configuration/log-collection/log-collection-sockets.js#L56-L70

JuanGarriuz commented 6 months ago

Update 07/03

Research

Files where the endpoint is called from plugins/main/. (Ignoring the imposter)

Imposter files:

Changes

Imposter response:

image

To Do

JuanGarriuz commented 6 months ago

Update 08/03

I'm trying to test it with a real manager, but the API response in the agent logs collector sockets target is not changed to socket.

wazuh-manager-config:

wazuh-manager-master:
    build:
      context: /home/usuario/wazuh-app-environments/images/wazuh_manager_filebeat_sources_cmake
      args:
        WAZUH_VERSION: 'fix/17662-fix-socket-conf-not--displayed'
        FILEBEAT_VERSION: '7.10.2'
        FILEBEAT_WAZUH_TEMPLATE_URL: https://raw.githubusercontent.com/wazuh/wazuh/fix/17662-fix-socket-conf-not--displayed/extensions/elasticsearch/7.x/wazuh-template.json
        FILEBEAT_WAZUH_MODULE_URL: https://packages.wazuh.com/4.x/filebeat/wazuh-filebeat-0.2.tar.gz
    image: wazuh-manager:4.9.0-7.10.2
    hostname: wazuh-manager-4.9.0-7102
    volumes:
      - '/home/usuario/wazuh-app-environments/config/filebeat/filebeat.odfe.yml:/etc/filebeat/filebeat.yml'
    ports:
      - '514:514'
      - '1514:1514'
      - '1515:1515'
      - '1516:1516'
      - '55000:55000'
    depends_on:
      - os1
    environment:
      NODE_IP: wazuh-manager-master
      NODE_NAME: manager-node
      NODE_TYPE: master
    networks:
      - os-dev

image

Agent log collector API response:

image

image

image

image

But, when I reproduce the API response into the manager log collection, the response is correctly formed:

image

JuanGarriuz commented 6 months ago

Update 10/05

Now, the dashboard renders the response of the agent correctly when it is a 4.9.0 version, but the API response has been lost, I'm researching why this happened and how to repair it.

Evidence ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/124377319/b6072125-8fe3-4d2d-b129-b3611656ad83) ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/124377319/0280fc05-07d5-429f-af45-d3d68038737e)

Workflow

v4.9.0 ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/124377319/b5624b60-e9c0-4cc5-8f12-4d6abd28aad2) ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/124377319/90ae3a9f-f75d-422d-a4dd-52dec11bf01b)
v4.8.0 ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/124377319/91979d86-bbfd-4afc-9505-087295bd61be) ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/124377319/e52354f6-cadc-456d-8484-7a32910f767b)
v4.7.0 ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/124377319/a4695fe1-1ffd-4c20-a2ba-6805248a1e0f) ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/124377319/2d077e61-dd09-4592-a3c9-304eb5f13bc0)