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

Feed the suggestion field for the new search bar #5370

Open
Desvelao opened this issue Apr 13, 2023 · 4 comments
Open

Feed the suggestion field for the new search bar #5370

Desvelao opened this issue Apr 13, 2023 · 4 comments
Assignees
Labels
level/task Task issue request/operational Operational requests type/enhancement Enhancement issue type/research Spikes, researchs, PoCs

Comments

@Desvelao
Copy link
Member

Desvelao commented Apr 13, 2023

Wazuh Elastic Rev Security
4.x 7.x 4xxx Basic, ODFE, Xpack
Browser
Chrome, Firefox, Safari, etc

Description

The new search bar component uses the q query parameter. This displays suggestions for the available fields that in the current WzSearchBar component, they are defined and maintained statically.

We would want to reduce the manual maintenance of this.

We could use the Wazuh API specification to get this data. The fields that are supported by q are not included in the API specification. In a meeting with the framework team, I asked about them, and they told me to use the example response because the field name follows a defined schema, and they are similar to the obtained response.

Some approaches to get and digest the data to feed the new search bar component are:

  • Realtime (best solution)
  • Generate the required data and add it to each plugin build.

This approach is used currently to feed the API Console for example.

@Desvelao Desvelao self-assigned this Apr 13, 2023
@Desvelao
Copy link
Member Author

Desvelao commented Apr 13, 2023

Research

I was following the approach to generate a pre-digested file to feed the new search bar component.

This is done through a script that can be used to save the results to a file that could be used by the new search bar component.

Script: generate-api-q-fields-endpoints.js.zip

This script uses the swagger-client dependency that is not included in the current plugins, to work you should install it. From the root of the plugin, run:

yarn add -D swagger-client

Combining the generation of data with the new search bar, we could get the field suggestions display all the supported fields of q query parameter, even there are more than the current WzSearchBar is displaying:
image

The current plugins get data from the API specification and save it to common/api-info/endpoints.json, so I think we could add the fields supported by the q query parameter to the same file and not create a new one. Due to there being an issue to refactor how the data of common/api-info is obtained #5036, I think we should obtain and merge the fields of q to the same file.

@Desvelao
Copy link
Member Author

Desvelao commented May 3, 2023

I moved this issue to on hold state, because the solution is a POC based in a workaround.

@gdiazlo gdiazlo added the type/research Spikes, researchs, PoCs label Jul 31, 2023
@gdiazlo gdiazlo added the request/operational Operational requests label Aug 14, 2023
@ArielIvanOjeda
Copy link
Member

Hi Team, any updates on this?

@Desvelao
Copy link
Member Author

Desvelao commented Sep 1, 2023

Hi @ArielIvanOjeda ,

this issue is on hold because the workaround to get the available fields in each API endpoint doesn't match in some use cases. For example, some current use cases of search bars should suggest more fields that got through the workaround. After seeing this problem, I moved the issue to hold. So for now, they will have to be maintained manually.

Maybe we should extend the analysis for each use case, and evaluate the results.

I am not sure why are you asking for this issue, @ArielIvanOjeda, but if your question is related to some missing field suggestions, the implementation of the new search bar added some fields that are not included in the previous search bar. The new search bar uses the fields available in the q query parameter, this doesn't display other query parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue request/operational Operational requests type/enhancement Enhancement issue type/research Spikes, researchs, PoCs
Projects
None yet
Development

No branches or pull requests

3 participants