Skip to content

Skip agent 000 in GET /agents/summary/os-status endpoints#6574

Merged
davidjiglesias merged 12 commits into4.0.2from
fix/6502-skip-agent-000
Nov 16, 2020
Merged

Skip agent 000 in GET /agents/summary/os-status endpoints#6574
davidjiglesias merged 12 commits into4.0.2from
fix/6502-skip-agent-000

Conversation

@mcarmona99
Copy link
Copy Markdown
Contributor

Related issue
#6502

Hi team,

In this PR, I have changed the GET /agents/summary/os and GET /agents/summary/status endpoints behavior in order to not consider the agent 000. Not considering 000 will fix the error reported in the issue related.

  • Testing that the endpoints are not returning 000 information:

GET /agents/summary/status:

Response before changes:

{
  "data": {
    "active": 9,
    "disconnected": 0,
    "never_connected": 4,
    "pending": 0,
    "total": 13
  },
  "error": 0
}

Response after changes:

{
  "data": {
    "active": 8,
    "disconnected": 0,
    "never_connected": 4,
    "pending": 0,
    "total": 12
  },
  "error": 0
}

GET /agents/summary/os:

I have deleted all agents so the only agent we have is 000.

sqlite> select os_platform,id from agent;
ubuntu|0

Endpoint response:

{
  "data": {
    "affected_items": [],
    "total_affected_items": 0,
    "total_failed_items": 0,
    "failed_items": []
  },
  "message": "Could not get the operative system of the agents",
  "error": 0
}
  • API integration tests:
test_agents_GET_endpoints.tavern.yaml 
	 90 passed, 97 warnings
	 
test_rbac_black_agents_endpoints.tavern.yaml 
	 39 passed, 41 warnings

test_rbac_white_agents_endpoints.tavern.yaml 
	 39 passed, 41 warnings
  • Unit tests:
framework/wazuh/core/tests/test_agent.py
======================= 187 passed, 11 warnings in 3.33s =======================

framework/wazuh/tests/test_agent.py
======================= 89 passed, 11 warnings in 13.56s =======================

Regards,
Manuel.

@mcarmona99 mcarmona99 self-assigned this Nov 12, 2020
@mcarmona99 mcarmona99 changed the base branch from master to 4.0.2 November 12, 2020 09:41
Copy link
Copy Markdown
Member

@davidjiglesias davidjiglesias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to change code and tests for overview endpoint to not include 000.
Update changelog.

Comment thread framework/wazuh/agent.py Outdated
Comment thread framework/wazuh/agent.py Outdated
Comment thread framework/wazuh/agent.py Outdated
@mcarmona99
Copy link
Copy Markdown
Contributor Author

mcarmona99 commented Nov 16, 2020

  • Now the endpoint GET /overview/agents skip the agent with id 000. Changed the endpoint docstring to NumpyDoc.

  • Update CHANGELOG.md.

  • API integration test results:

test_overview_endpoints.tavern.yaml 
	 1 passed, 3 warnings

test_rbac_black_overview_endpoints.tavern.yaml 
	 1 passed, 3 warnings

test_rbac_white_overview_endpoints.tavern.yaml 
	 1 passed, 3 warnings

  • Unit test results:
framework/wazuh/core/tests/test_agent.py
================== 187 passed, 11 warnings in 15.43s ==================

framework/wazuh/tests/test_agent.py
================== 90 passed, 11 warnings in 3.45s ==================

@davidjiglesias davidjiglesias merged commit 9003506 into 4.0.2 Nov 16, 2020
@davidjiglesias davidjiglesias deleted the fix/6502-skip-agent-000 branch November 16, 2020 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API] [RBAC] Query param to skip some agent from the endpoint GET /agents/summary/status

2 participants