wazuh / wazuh-api

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

Add search and select to mitre endpoint #476

Closed davidjiglesias closed 4 years ago

davidjiglesias commented 4 years ago

Hello team,

This PR is related to https://github.com/wazuh/wazuh/issues/4285

This PR adds search and select parameter to mitre endpoint. It also adds new mocha tests for both cases.

Mocha test results:

Selutario commented 4 years ago

Hello team,

I have updated mocha tests for mitre endpoint. Many of them were failing after changing the name of this parameters: attack, phase and platform. It is deeper explained here #4322

I have added a few new tests that check whether select parameter works properly, as well as the number of items returned if the field json is included.

You can check the current result of the tests below:

mocha test/test_mitre.js

  Mitre
    GET/sca/:agent_id
      ✓ Request (253ms)
      ✓ Pagination: limit = 1 (173ms)
      ✓ Pagination: limit = 5 (178ms)
      ✓ Pagination: limit = 10 (178ms)
      ✓ Pagination: limit > 10 (175ms)
      ✓ Retrieve all elements with limit=0 (155ms)
      ✓ Sort: +id (176ms)
      ✓ Sort: -id (187ms)
      ✓ Filters: id (179ms)
      ✓ Filters: id (request returns 0 items) (168ms)
      ✓ Filters: phase_name=initial access (183ms)
      ✓ Filters: phase_name=persistence (177ms)
      ✓ Filters: phase_name (request returns 0 items) (170ms)
      ✓ Filters: platform_name=linux (175ms)
      ✓ Filters: platform_name=macos (187ms)
      ✓ Filters: platform_name=windows (178ms)
      ✓ Filters: platform_name=windows,phase_name=persistence (184ms)
      ✓ Filters: platform_name=linux,phase_name=execution (171ms)
      ✓ Filters: platform_name=macos,phase_name=impact (174ms)
      ✓ Filters: platform_name (request returns 0 items) (172ms)
      ✓ Filters: q=id=T1015 (168ms)
      ✓ Filters: q=platform_name=linux (184ms)
      ✓ Filters: q=phase_name=execution (174ms)
      ✓ Filters: q (request returns 0 items) (179ms)
      ✓ Filters: q (wrong query 1) (173ms)
      ✓ Filters: q (wrong query 2) (170ms)
      ✓ Filters: q (wrong query 3) (171ms)
      ✓ Filters: select=id,phase_name,platform_name (216ms)
      ✓ Filters: select=id,json,platform_name (194ms)
      ✓ Filters: select=platform (wrong field) (183ms)
      ✓ Search (185ms)
      ✓ Search (returns 0 items) (210ms)

  32 passing (6s)

Kind regards, Selu.