OpenSearch-Dashboards icon indicating copy to clipboard operation
OpenSearch-Dashboards copied to clipboard

[BUG] "Edit as Query DSL" functionality is generating both bad and incorrect DSL

Open JTMosaic opened this issue 1 year ago • 6 comments

The "Edit as Query DSL" functionality is generating both bad and incorrect DSL

To Reproduce

  1. Log into Wazuh Dashboard and go to Security Events
  2. Add a rule where rule.level is one of 3,4 or 5 image
  3. Edit the query and click on the Edit Query as DSL link to see:
 "query": {
   "bool": {
     "should": [
       {
         "match_phrase": {
           "rule.level": "3"
         }
       },
       {
         "match_phrase": {
           "rule.level": "4"
         }
       },
       {
         "match_phrase": {
           "rule.level": "5"
         }
       }
     ],
     "minimum_should_match": 1
   }
 }
}
  1. Click Cancel, edit the filter again and change the Operator to is not one of and save the query
  2. Edit the query and click on the Edit Query as DSL link to see:
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "rule.level": "3"
          }
        },
        {
          "match_phrase": {
            "rule.level": "4"
          }
        },
        {
          "match_phrase": {
            "rule.level": "5"
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}

This is the exact same DSL. The negation of the operator is not present.

Additionally, if you copy this DSL into a new filter you get a filter which is not editable as filter values and does not display correctly on the dashboard though it does seem to work, albeit without the NOT:

image

Expected behavior Correct DSL should be generated to make queries easier to save and document

OpenSearch Version wazuh-indexer 4.7.0-1

Dashboards Version wazuh-dashboards 4.7.0-1

Plugins Amazon AWS

This has already been reported to the Wazuh team. See the discussion here

JTMosaic avatar Jan 02 '24 16:01 JTMosaic

Although this issue mentions Wazuh Dashboard, Security Events section, it is reproducible in the Discover section of OSD.

I just reproduced it on 2.11.1 image

image

Tostti avatar Jan 03 '24 11:01 Tostti

Hello @JTMosaic,

Will check this out as soon as possible and will try to read up on the other thread. In the meantime, could you verify if this is a relatively recent issue and worked prior to an upgraded version? Or has this been a persisting issue?

kavilla avatar Jan 10 '24 18:01 kavilla

Thank you, @kavilla . I've not tried it in prior versions

JTMosaic avatar Jan 10 '24 18:01 JTMosaic

Any update on this?

JTMosaic avatar Feb 19 '24 16:02 JTMosaic

Will look into this as soon as possible.

kavilla avatar Feb 20 '24 18:02 kavilla

Did a deep dive into this area so will check it out again. Apologies on the delay here. Will have to move it to 2.15.

kavilla avatar May 07 '24 23:05 kavilla