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

Add group configuration sync status to GET /agents response #12362

Closed
13 tasks done
vicferpoy opened this issue Feb 18, 2022 · 2 comments · Fixed by #12483
Closed
13 tasks done

Add group configuration sync status to GET /agents response #12362

vicferpoy opened this issue Feb 18, 2022 · 2 comments · Fixed by #12483
Assignees

Comments

@vicferpoy
Copy link
Contributor

vicferpoy commented Feb 18, 2022

Description

As part of #9334, we need to use the new column which will be introduced in #12361 to add the agent groups configuration synchronization status to every agent for the GET /agents response.

Requirements

  1. Retrieve group sync status from the table agent, column group_config_status (global.db).

  2. Addition of group_config_status to the response.

{
  "data": {
    "affected_items": [
      {
        "os": {
          "arch": "x86_64",
          "codename": "Focal Fossa",
          "major": "20",
          "minor": "04",
          "name": "Ubuntu",
          "platform": "ubuntu",
          "uname": "Linux |wazuh-master |5.14.18-100.fc33.x86_64 |#1 SMP Fri Nov 12 17:38:44 UTC 2021 |x86_64",
          "version": "20.04.3 LTS"
        },
        "manager": "wazuh-master",
        "registerIP": "127.0.0.1",
        "lastKeepAlive": "9999-12-31T23:59:59Z",
        "id": "000",
        "ip": "127.0.0.1",
        "dateAdd": "2022-02-15T15:04:08Z",
        "status": "active",
        "name": "wazuh-master",
        "node_name": "master-node",
        "version": "Wazuh v4.4.0",
        "group_config_status": "synced"
      }
    ],
    "total_affected_items": 1,
    "total_failed_items": 0,
    "failed_items": []
  },
  "message": "All selected agents information was returned",
  "error": 0
}
  1. New filter for GET /agents.

Checks

wazuh/wazuh

  • Unit tests without failures. Updated and/or expanded if there are new functions/methods/outputs:
    • Cluster (framework/wazuh/core/cluster/tests/ & framework/wazuh/core/cluster/dapi/tests/)
    • Core (framework/wazuh/core/tests/)
    • SDK (framework/wazuh/tests/)
    • RBAC (framework/wazuh/rbac/tests/)
    • API (api/api/tests/)
  • API tavern integration tests without failures. Updated and/or expanded if needed (api/test/integration/):
    • Affected tests
    • Affected RBAC (black and white) tests
  • Review integration test mapping using the script (api/test/integration/mapping/integration_test_api_endpoints.json)
  • Review of spec.yaml examples and schemas (api/api/spec/spec.yaml)
  • Review exceptions remediation when any endpoint path changes or is removed (framework/wazuh/core/exception.py)
  • Changelog (CHANGELOG.md)

wazuh/wazuh-documentation

  • Migration from 3.X for changed endpoints (source/user-manual/api/equivalence.rst)
  • Update RBAC reference with new/modified actions/resources/relationships (source/user-manual/api/rbac/reference.rst)
@vicferpoy
Copy link
Contributor Author

Status update

Development has been finished. As the core issue has not been implemented yet, a change in the global.db has been done to manual test this implementation.

Global database status

sqlite> select id, group_config_status from agent;
0|synced
1|not synced

GET /agents response

2022/02/21 08:51:06 INFO: wazuh 172.26.0.1 "GET /agents" with parameters {"select": "group_config_status"} and body {} done in 0.047s: 200
{
  "data": {
    "affected_items": [
      {
        "group_config_status": "synced",
        "id": "000"
      },
      {
        "group_config_status": "not synced",
        "id": "001"
      }
    ],
    "total_affected_items": 2,
    "total_failed_items": 0,
    "failed_items": []
  },
  "message": "All selected agents information was returned",
  "error": 0
}

GET /agents using group_config_status

2022/02/21 08:54:05 INFO: wazuh 172.26.0.1 "GET /agents" with parameters {"select": "group_config_status", "group_config_status": "not synced"} and body {} done in 0.013s: 200
{
  "data": {
    "affected_items": [
      {
        "group_config_status": "not synced",
        "id": "001"
      }
    ],
    "total_affected_items": 1,
    "total_failed_items": 0,
    "failed_items": []
  },
  "message": "All selected agents information was returned",
  "error": 0
}

GET /agents using invalid group_config_status

2022/02/21 08:55:29 INFO: wazuh 172.26.0.1 "GET /agents" with parameters {"group_config_status": "whatever"} and body {} done in 0.007s: 400
{
  "title": "Bad Request",
  "detail": "'whatever' is not one of ['synced', 'not synced']. Failed validating 'enum' in schema: {'enum': ['synced', 'not synced'], 'type': 'string'}. On instance: 'whatever'"
}

Pending

  • Add and update related unit tests.
  • Add new API integration tests.

@vicferpoy
Copy link
Contributor Author

vicferpoy commented Feb 21, 2022

Status update

Unit and API integration tests have been updated and new ones have been added following TDD. This issue will remain blocked until #12361 is merged.

Issue development branch: feature/12362-get-agents-group-conf-sync-status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants