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

Refine filter mechanism #6672

Closed
14 tasks done
asteriscos opened this issue May 15, 2024 · 3 comments · Fixed by #6674, #6675, #6677, #6679 or #6682
Closed
14 tasks done

Refine filter mechanism #6672

asteriscos opened this issue May 15, 2024 · 3 comments · Fixed by #6674, #6675, #6677, #6679 or #6682
Assignees
Labels
level/task Task issue type/bug Bug issue

Comments

@asteriscos
Copy link
Member

asteriscos commented May 15, 2024

Wazuh Rev
4.9.0 00

Description

After testing all main features integrated we detected some odd behaviors that need fixing.

Tasks

@asteriscos asteriscos added type/bug Bug issue level/task Task issue labels May 15, 2024
@Machi3mfl Machi3mfl self-assigned this May 15, 2024
@wazuhci wazuhci moved this to In progress in Release 4.9.0 May 15, 2024
@Machi3mfl
Copy link
Member

Machi3mfl commented May 15, 2024

In the Vulnerabilities module, when we change the index pattern the view doesn't render any visualization

#6674

Before

Screen.Recording.2024-05-15.at.11.39.19.mov

This error

Screenshot 2024-05-15 at 11 42 51

After

Screen.Recording.2024-05-15.at.11.45.17.mov

@yenienserrano yenienserrano self-assigned this May 15, 2024
@yenienserrano yenienserrano linked a pull request May 15, 2024 that will close this issue
9 tasks
@yenienserrano yenienserrano linked a pull request May 16, 2024 that will close this issue
6 tasks
@jbiset jbiset self-assigned this May 16, 2024
@yenienserrano yenienserrano linked a pull request May 17, 2024 that will close this issue
6 tasks
@yenienserrano yenienserrano linked a pull request May 17, 2024 that will close this issue
6 tasks
@jbiset jbiset linked a pull request May 17, 2024 that will close this issue
6 tasks
@lucianogorza lucianogorza self-assigned this May 21, 2024
@lucianogorza lucianogorza linked a pull request May 21, 2024 that will close this issue
6 tasks
@Machi3mfl
Copy link
Member

Fix modules redirections with predefined filters via URL

Tasks

  • Create a mechanism to make a redirect with filters by default.
  • Add to the current solution the possibility to add filters that will be applied when entering the module.

Current solution

  1. Using the getUrlForApp to get the redirect href
<EuiButtonEmpty
                iconType='popout'
                aria-label='popout'
                href={getCore().application.getUrlForApp(threatHunting.id, {
                  path: `#/overview/?tab=general&tabView=panels&addRuleFilter=1001`
                })}
                target='blank'
              >
                View alerts of this Rule
              </EuiButtonEmpty>
  1. In plugins/wazuh/public/services/common-data.js, globally check the URL query, search the addRuleFilter and add directly to the filter manager the filter
const regex = new RegExp('addRuleFilter=' + '[^&]*');
      const match = this.$window.location.href.match(regex);
      if (match && match[0]) {
        const id = match[0].split('=')[1];
        let filter = filterHandler.ruleIdQuery(id);
        filter.$state.isImplicit = false;
        filters.push(filter);
        this.$window.location.href = this.$window.location.href.replace(
          regex,
          '',
        );
      }

Disadvantages

  • Not scalable, for every filter that we want to add we must add a condition to check the param received, like for example, the addRuleFilter param.
  • To many responsibilities, the redirect touches the filter manager directly

# Possible solutions

  • Encapsulate the getCore().application.getUrlForApp method and create a function that creates the redirect URL with all the necessary params like:

    • panel
    • tab
    • predefined filters (one or more)

    For instance:

     // redirect manager or something 
     
    redirector.redirectToApp({
      tab: 'general',
      tabView: 'panels',
     applicationId: 'threat-hunting',
    filters: [{ key: 'rule.id', value: '1001' }]
    })

Then this service construct the URL with the params like:

  • ruleId=1001 or inner a_ filters query

Problem

When the URL is refreshed using enter or F5 the a_ content is cleaned

  • Use the same solution, adding custom query params manually and evaluate this query params in the data-source-pattern-filter-manager and add the filters

For instance:

getCore().application.getUrlForApp(threatHunting.id, {
                  path: `#/overview/?tab=general&tabView=panels&filters='ruleId=1001&ruleMitreId=T100`
                })

Then, when the data source is loaded the data source filter manager gets the query params, creates the filters and add on it.

@lucianogorza
Copy link
Contributor

lucianogorza commented May 24, 2024

Proposals to display implicit filters in the search bar

Currently, to display the implicit filters, the search bar component native to OpenSearch is manipulated and the close buttons for the filter badges are removed. This practice sometimes results in incorrect functionality because we are interfering with the behavior of a component outside our control.

To achieve a stable behavior for displaying implicit filters, the following alternatives are proposed.

All options have the same technical solution but with different visual proposals.

Option 1: Show all implicit filters without the close button

This option, visually, is identical to how it is currently displayed, but technically the solution is different. We would be hiding the implicit filters from the native search bar and adding them as components of our application outside the bar in the DOM.

image

Option 2: Show all implicit filters without the close button and with another background color

image

Option 3: Hide the implicit filters and show a Tooltip to display the info

image

Option 4: Hide the implicit filters and show a Popover to display the info

image

Due to the scope and size of the proposed solution, we decided to create another issue to continue the development: #6711

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment