wazuh / wazuh-api

Wazuh - RESTful API
https://wazuh.com
GNU General Public License v2.0
69 stars 57 forks source link

Case insensitive parameter for Wazuh's API endpoints #468

Open AdriiiPRodri opened 4 years ago

AdriiiPRodri commented 4 years ago

Hi all,

This issues is related and close #467. As @skiingyac reported to us, the endpoint GET /agents/name/:agent_name is case sensitive.

We should add a new parameter to the endpoint (and any other affected endpoint) in order to search using case insensitive.

Before

curl -u foo:bar -k -X GET "https://127.0.0.1:55000/agents/name/NewHost?pretty"

{
   "error": 0,
   "data": {
      "ip": "10.0.0.9",
      "id": "009",
      "name": "NewHost",
      "dateAdd": "2019-08-30 09:31:01",
      "status": "Never connected",
      "registerIP": "10.0.0.9",
      "node_name": "unknown"
   }
}
curl -u foo:bar -k -X GET "https://127.0.0.1:55000/agents/name/newhost?pretty"

{
    "error": 1701,
    "message": "Agent does not exist: newhost"
}

After

curl -u foo:bar -k -X GET "https://127.0.0.1:55000/agents/name/newhost?pretty&insensitive"

{
   "error": 0,
   "data": {
      "ip": "10.0.0.9",
      "id": "009",
      "name": "NewHost",
      "dateAdd": "2019-08-30 09:31:01",
      "status": "Never connected",
      "registerIP": "10.0.0.9",
      "node_name": "unknown"
   }
}

Regards.