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

Fix health check error when there is no vulnerabilities indices #6231

Conversation

jbiset
Copy link
Member

@jbiset jbiset commented Dec 15, 2023

Description

This pull request resolve an error when there's no vulnerabilities indices. Now when there is a warning in the health check due to the vulnerability index, it shows the warning and does not continue with the redirection but instead shows a button to continue. If everything is fine if the redirection continues.
A problem is also resolved when errors are logged in the warning health-check, which generated an error instead of a warning in the production environment.
Finally, the rendering behavior of the vulnerability dashboard tab is also changed when there is no data, showing a notification that there is no data.

Issues Resolved

Evidence

Warning and continue button in health-check

01_Evidence_Continue_button

Health-check with everything OK before redirecting

image

Vulnerabilities dashboard tab when search does not return data

image

Vulnerabilities inventory tab when search does not return data

image

Health-check on Vagrant test

image

Vulnerabilities dashboard tab when no indices on Vagrant test

image

Test

  • When setting up the environment for the first time, as the vulnerability index does not exist, the health-check must display a warning and show a continue button waiting for user interaction. If you want to simulate this case, you only need to go to /health-check, taking into account that it does not have the ?debug query.
  • The health-check should not throw an error when there are no vulnerability indexes, but rather a warning.
  • If everything is fine with the vulnerability index, the health-check should not show warnings and should continue. In order to create the index and insert data into the manager, you can use the script in this comment. To test this you can go to /health-check, taking into account that it does not have the ?debug query.
  • Try a search in the searchbar that does not return data, both the dashboard tab and the inventory tab should display a message "No results match your search criteria".
  • Using vagrant, set up an environment and install the manually generated Wazuh package in this github action. Remember to uninstall the wazuh plugin and then install the one that comes in the zip. You must test that the health-check throws a warning with the continue button.
Considerations with the Vagrant test

In principle it is necessary to have the wazuh plugin package (wazuh-2.10.0.zip) that is inside the github actions zip at the same level as the Vagrantfile archive and, when vagrant up, inside the container in /vagrant files appear. If they do not appear it is because the vagrant vbguest plugin is missing.
Then you need to connect via ssh (vagrant ssh), go to /usr/share/wazuh-dashboard/bin, uninstall the wazuh plugin with ./opensearch-dashboards-plugin remove wazuh and install the package version with ./opensearch-dashboards-plugin install file:///vagrant/wazuh-2.10.0.zip. If everything goes well, the application will be able to load and test the health-check at the IP listed in the Vagrantfile (192.168.56.10) on port 443.

Check List

  • All tests pass
    • yarn test:jest
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@jbiset jbiset linked an issue Dec 15, 2023 that may be closed by this pull request
@jbiset jbiset marked this pull request as ready for review December 18, 2023 18:26
@jbiset jbiset requested a review from a team as a code owner December 18, 2023 18:26
@jbiset jbiset self-assigned this Dec 18, 2023
@lucianogorza lucianogorza self-requested a review December 18, 2023 19:08
@Tostti Tostti self-requested a review December 19, 2023 11:54
@lucianogorza
Copy link
Member

lucianogorza commented Dec 19, 2023

Test 🟢

Warning and continue button in health-check 🟢

image

Health-check with everything OK before redirecting 🟢

image

Vulnerabilities dashboard tab when search does not return data 🟢

image

Vulnerabilities inventory tab when search does not return data 🟢

With data
image

Without data
image

Health-check on Vagrant test 🟢

image

Vulnerabilities dashboard tab when no indices on Vagrant test 🟢

image

Copy link
Member

@lucianogorza lucianogorza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vulnerabilities Dashboard doesn't show any data but the index has data

Copy link
Contributor

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 76.68% ( 171 / 223 )
Branches 57.57% ( 57 / 99 )
Functions 61.7% ( 29 / 47 )
Lines 76.68% ( 171 / 223 )

Copy link
Contributor

Wazuh Core plugin code coverage (Jest) test % values
Statements 21.42% ( 186 / 868 )
Branches 17.99% ( 79 / 439 )
Functions 14.22% ( 36 / 253 )
Lines 21.65% ( 183 / 845 )

Copy link
Contributor

Main plugin code coverage (Jest) test % values
Statements 12.07% ( 4160 / 34441 )
Branches 8.18% ( 1893 / 23129 )
Functions 11.53% ( 944 / 8181 )
Lines 12.25% ( 4047 / 33032 )

Copy link
Member

@asteriscos asteriscos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: ✔️
Test: ✔️

Warning and continue button in health-check - Dev environment

image

Health-check with everything OK before redirecting

image

Vulnerabilities dashboard tab when search does not return data

image

Vulnerabilities inventory tab when search does not return data

image

Health-check on Vagrant test

image

Vulnerabilities dashboard tab when no indices on Vagrant test

image
image
image

Copy link
Member

@lucianogorza lucianogorza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Machi3mfl Machi3mfl merged commit bcbd3b3 into 4.8.0 Dec 20, 2023
4 checks passed
@Machi3mfl Machi3mfl deleted the 6209-fix-health-check-error-when-there-is-no-vulnerabilities-indices branch December 20, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Health-check error when there's no vulnerabilities indices
4 participants