elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.71k stars 8.12k forks source link

[Fleet] Errors in the UI and API when creating agent policies with special characters in their ID #189652

Open mrodm opened 1 month ago

mrodm commented 1 month ago

Kibana version: 8.14.1

Elasticsearch version: 8.14.1

Server OS version:

Browser version:

Browser OS version:

Original install method (e.g. download page, yum, from source, etc.):

Describe the bug:

Creating an agent policy with special characters like ( in their ID causes that the agent policies UI could not show any policy (see in the screenshot below).

Once that Agent Policy is created, running these API calls would fail too:

GET kbn:/api/fleet/agent_policies

POST kbn:/api/fleet/agent_policies/delete
{
   "agentPolicyId": "test-(environment)"
}

with the following error:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": """Kuery is malformed: Expected AND, OR, end of input, whitespace but "(" found.
policy_id:test-(environment)
---------------^"""
}

Steps to reproduce:

  1. Create agent policy with an special character
    POST kbn:/api/fleet/agent_policies
    {
     "name": "policytest",
     "id": "test-(environment)",
     "description": "",
     "namespace": "default",
     "monitoring_enabled": [
       "logs",
       "metrics"
     ],
     "inactivity_timeout": 1209600,
     "is_protected": false
    }
  2. Try to retrieve agent policies via API
    GET kbn:/api/fleet/agent_policies
  3. Try to check Agent Policies via UI: https://<kibana>/app/fleet/policies

Expected behavior:

Screenshots (if relevant):

Screenshot from 2024-07-31 17-27-45

Errors in browser console (if relevant):

Provide logs and/or server output (if relevant):

Any additional context:

elasticmachine commented 1 month ago

Pinging @elastic/fleet (Team:Fleet)