Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wazuh API usage - Management/Configuration #5242

Closed
Tracked by #5233
Desvelao opened this issue Mar 3, 2023 · 1 comment · Fixed by #5485, #5550 or #5549
Closed
Tracked by #5233

Wazuh API usage - Management/Configuration #5242

Desvelao opened this issue Mar 3, 2023 · 1 comment · Fixed by #5485, #5550 or #5549
Assignees
Labels
level/task Task issue type/enhancement Enhancement issue

Comments

@Desvelao
Copy link
Member

Desvelao commented Mar 3, 2023

Description

Analysis: #5233

Configuration

When clicking on the configuration section

image

Issue
2021/11/08 15:04:35 INFO: wazuh-wui 172.22.0.12 "GET /cluster/status" with parameters {} and body {} done in 0.029s: 200
2021/11/08 15:04:35 INFO: wazuh-wui 172.22.0.12 "GET /cluster/status" with parameters {} and body {} done in 0.028s: 200
2021/11/08 15:04:35 INFO: wazuh-wui 172.22.0.12 "GET /cluster/nodes" with parameters {} and body {} done in 0.054s: 200
2021/11/08 15:04:35 INFO: wazuh-wui 172.22.0.12 "GET /cluster/nodes" with parameters {} and body {} done in 0.016s: 200
2021/11/09 12:21:01 INFO: wazuh-wui 172.19.0.105 "GET /agents" with parameters {"q": "id=000"} and body {} done in 0.014s: 200
  • Improvements and suggestions

    1. Don't use a query to get only one agent. The following will be always faster:
      GET /agents?agents_list=000

    2. The requests used to check cluster health are done twice, could we avoid the second request to each endpoint?

  1. We should change the request
  2. This needs a deep analysis.

When choosing some configurations (global for instance)

image

Issue
2021/11/08 15:13:43 INFO: wazuh-wui 172.22.0.12 "GET /cluster/master-node/configuration/analysis/global" with parameters {} and body {} done in 0.017s: 200
2021/11/08 15:13:44 ERROR: Error connecting with socket
Traceback (most recent call last):
 File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/core/wazuh_socket.py", line 27, in _connect
   self.s.connect(self.path)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/core/configuration.py", line 780, in get_active_configuration
   s = WazuhSocket(dest_socket)
 File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/core/wazuh_socket.py", line 22, in __init__
   self._connect()
 File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/core/wazuh_socket.py", line 29, in _connect
   raise WazuhException(1013, str(e))
wazuh.core.exception.WazuhException: Error 1013 - Unable to connect with socket: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/core/cluster/dapi/dapi.py", line 256, in execute_local_request
    data = await asyncio.wait_for(task, timeout=timeout)
  File "/var/ossec/framework/python/lib/python3.9/asyncio/tasks.py", line 481, in wait_for
    return fut.result()
  File "/var/ossec/framework/python/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/core/cluster/dapi/dapi.py", line 230, in run_local
    data = self.f(**self.f_kwargs)
  File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/rbac/decorators.py", line 406, in wrapper
    result = func(*args, **kwargs) if not skip_execution else None
  File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/manager.py", line 222, in get_config
    data = configuration.get_active_configuration(agent_id='000', component=component, configuration=config)
  File "/var/ossec/framework/python/lib/python3.9/site-packages/wazuh-4.2.4-py3.9.egg/wazuh/core/configuration.py", line 782, in get_active_configuration
    raise WazuhInternalError(1121)
wazuh.core.exception.WazuhInternalError: Error 1121 - Error connecting with socket
2021/11/08 15:13:44 INFO: wazuh-wui 172.22.0.12 "GET /cluster/master-node/configuration/mail/global" with parameters {} and body {} done in 0.019s: 500
2021/11/08 15:13:44 INFO: wazuh-wui 172.22.0.12 "GET /security/user/authenticate" with parameters {} and body {} done in 0.171s: 200
2021/11/08 15:13:44 INFO: wazuh-wui 172.22.0.12 "GET /manager/info" with parameters {} and body {} done in 0.044s: 200
2021/11/08 15:13:44 INFO: wazuh-wui 172.22.0.12 "GET /agents" with parameters {"agents_list": "000"} and body {} done in 0.018s: 200
2021/11/08 15:13:44 INFO: wazuh-wui 172.22.0.12 "GET /cluster/status" with parameters {} and body {} done in 0.020s: 200
2021/11/08 15:13:44 INFO: wazuh-wui 172.22.0.12 "GET /cluster/local/info" with parameters {} and body {} done in 0.017s: 200
2021/11/08 15:13:44 INFO: wazuh-wui 172.22.0.12 "GET /cluster/master-node/configuration/request/remote" with parameters {} and body {} done in 0.016s: 200
2021/11/08 15:13:44 INFO: wazuh-wui 172.22.0.12 "GET /cluster/master-node/configuration/com/logging" with parameters {} and body {} done in 0.015s: 200

This needs a deep analysis.

@Desvelao Desvelao added the type/enhancement Enhancement issue label Mar 3, 2023
@Desvelao Desvelao changed the title Wazuh API usage - Management/Configuration clicking in the section Wazuh API usage - Management/Configuration Mar 3, 2023
@gdiazlo gdiazlo added the level/task Task issue label Mar 16, 2023
@wazuhci wazuhci moved this to Backlog in Release 4.6.0 Apr 21, 2023
@wazuhci wazuhci removed this from Release 4.6.0 May 19, 2023
@yenienserrano yenienserrano self-assigned this May 22, 2023
@yenienserrano
Copy link
Member

From what I was investigating the repeated requests were being executed to change the state of redux which is currently not being used and also sent by props to some components to check permissions, it was added in this commit but then in this other commit it is changed, and it is deprecated as well. Therefore, as it is code that is not being used, I am going to delete it to clean up the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment