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

Move the registry to in-memory cache #6481

Merged
merged 169 commits into from
Apr 3, 2024

Conversation

Desvelao
Copy link
Member

@Desvelao Desvelao commented Mar 6, 2024

Description

This pull request moves the registry to an in-memory cache and removes some logic done by the frontend side that should do the backend side.

Changes

  • Move the registry management to an in-memory cache managed by ManageHosts
    service.
  • Initialize the registry data on the start
    • Update the registry on adding, editing, or deleting an API host
  • Move the logic to check if the run_as is enabled to the ManageHosts
    instead of cacheAPIUserAllowRunAs
  • Update the backend types of the core plugin
  • Remove the process to create/update the registry file when the plugin starts
  • Remove the Installation date from the About view
  • Remove the cacheAPIUserAllowRunAs of the ManageHosts service to use
    the registry data
  • Remove the cacheAPIUserAllowRunAs property of Manage hosts
  • Remove the UpdateRegistry service
  • Remove API endpoint PUT /hosts/update-hostname/{id}
    • Remove API endpoint (route and controller)
    • Remove API request of frontend side
  • Remove logic to create the registry file on start
  • Remove API endpoint and usage of GET /hosts/remove-orphan-entries
    • Remove API endpoint (route and controller)
    • Remove API request of frontend side
  • Remove unused API endpoint GET /api/timestamp

Issues Resolved

#6387

Evidence

image

Test

TEST

With an API connection using an with run_as capability enabled with run_as disabled, edit the API connection setting run_as as true, save. The Run as column should display the run_as is enabled with a check

Context: @yenienserrano

6387-registry-in-memory-cache

Legend:
⚫: none
🟢: pass
🟡: warning
🔴: fail
⚪: not applicable

UI

Test Chrome Firefox Safari
Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table.
Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table.
Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table.
Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table.
Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table.
Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table.
Go to About, it only should display the version and revision of the application. No reference to installation date.

Details

⚫ Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to About, it only should display the version and revision of the application. No reference to installation date.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

6387-registry-in-memory-cache

Legend:
⚫: none
🟢: pass
🟡: warning
🔴: fail
⚪: not applicable

UI

Test Chrome Firefox Safari
Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table.
Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table.
Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table.
Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table.
Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table.
Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table.
Go to About, it only should display the version and revision of the application. No reference to installation date.

Details

⚫ Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to About, it only should display the version and revision of the application. No reference to installation date.

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

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

- Enhance the logging messages
- Minor enhancements
- Replace the logging services
- Move services to core plugin
  - CacheAPIUserAllowRunAs
  - ManageHosts
  - ServerAPIClient (aka api-interceptor)
  - ServerAPIHostEntries (aka )
  - UpdateConfigurationFile
  - UpdateRegistry
- Adapt the usage of services in the main and check updates plugin from
  core plugin
- Remove plugin logger from main and core plugins
- Remove API endpoint
  - GET /utils/logs/ui
- Remove unused code
- Adapt the test suites
- Remove GET /utils/logs endpoint
  - Remove related tests
- Remove App logs application
- Create Configuration service
- Create ConfigurationStore (backend and frontend side)
- Register the plugin settings in the configuration services
…ration service

- API endpoints:
  - GET /utils/configuration
  - PUT /utils/configuration
  - PUT /utils/configuration/files/{key}
  - DELETE /utils/configuration/files/{key}
@Tostti Tostti self-requested a review March 18, 2024 11:58
@yenienserrano yenienserrano self-requested a review March 18, 2024 13:43
@yenienserrano
Copy link
Member

yenienserrano commented Mar 18, 2024

UI

Test Chrome Firefox Safari
Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table. 🟢
Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table. 🟢
Go to About, it only should display the version and revision of the application. No reference to installation date. 🟢

Details

🟢 Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - 🟢

image
🟢 Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - 🟢

image image
🟢 Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - 🟢

image image
🟢 Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - 🟢

image
🟢 Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - 🟢

image
🟢 Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - ⚫

Firefox - ⚫

Safari - 🟢

image
🟢 Go to About, it only should display the version and revision of the application. No reference to installation date.

Chrome - ⚫

Firefox - ⚫

Safari - 🟢

image

@yenienserrano
Copy link
Member

when I delete an API I get an error message but if I press the refresh button the API seems to have been deleted correctly because it does not appear in the table.

image image

Copy link
Member

@Tostti Tostti left a comment

Choose a reason for hiding this comment

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

UI

Test Chrome Firefox Safari
Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table. 🟢
Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table. 🟢
Go to About, it only should display the version and revision of the application. No reference to installation date. 🟢
Changing run as status 🔴
Removing an API 🔴

Details

🟢 Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - 🟢
image

Safari - ⚫

🟢 Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - 🟢
image
image

Safari - ⚫

🟢 Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - ⚫

Firefox - 🟢
image

Safari - ⚫

🟢 Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - 🟢
image

image

Safari - ⚫

🟢 Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table.

Chrome - ⚫

Firefox - 🟢
image

Safari - ⚫

🟢 Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - ⚫

Firefox - 🟢
image

Safari - ⚫

🟢 Go to About, it only should display the version and revision of the application. No reference to installation date.

Chrome - ⚫

Firefox - 🟢
image

Safari - ⚫

🔴 Changing run as status

Chrome - ⚫

Firefox - 🔴

Although the change is applied, it is not shown in the table
image
image
image

Safari - ⚫

🔴 Removing an API

Chrome - ⚫

Firefox - 🔴

If an API is removed (online or offline), this error is shown and the table have to be manually refreshed to show the change
image

Safari - ⚫

plugins/main/server/controllers/wazuh-api.ts Outdated Show resolved Hide resolved
@yenienserrano
Copy link
Member

when I edit an API I get an error message but if I press the update button the API seems to have been edited correctly.

image image

@Desvelao
Copy link
Member Author

Changes

Copy link
Contributor

github-actions bot commented Apr 3, 2024

Wazuh Core plugin code coverage (Jest) test % values
Statements 31.12% ( 286 / 919 )
Branches 29.88% ( 107 / 358 )
Functions 28.1% ( 86 / 306 )
Lines 30.71% ( 278 / 905 )

Copy link
Contributor

github-actions bot commented Apr 3, 2024

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 76.44% ( 172 / 225 )
Branches 58.65% ( 61 / 104 )
Functions 61.7% ( 29 / 47 )
Lines 76.44% ( 172 / 225 )

Copy link
Contributor

github-actions bot commented Apr 3, 2024

Main plugin code coverage (Jest) test % values
Statements 11.99% ( 4152 / 34612 )
Branches 7.77% ( 1764 / 22691 )
Functions 10.7% ( 881 / 8230 )
Lines 12.18% ( 4043 / 33179 )

@asteriscos
Copy link
Member

UI

Test Chrome Firefox Safari
Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table. 🟢
Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table. 🟢
Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table. 🟢
Go to About, it only should display the version and revision of the application. No reference to installation date. 🟢

Details

🟢 Go to Server APIs, and add an online API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

🟢 Go to Server APIs, and edit an offline API host that can be connected. The data about the cluster name or manager name should appear in the table.

Chrome - 🟢

image

image

Firefox - ⚫

Safari - ⚫

🟢 Go to Server APIs, and edit an online API host that can not be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - 🟢

image

image

Firefox - ⚫

Safari - ⚫

🟢 Go to Server APIs, change the cluster name or manager name of an offline API connection, and edit the API connection that can be connected. The new data about the cluster name or manager name should appear in the table.

Chrome - 🟢

image

image

Firefox - ⚫

Safari - ⚫

🟢 Go to Server APIs, change the cluster name or manager name of an offline API connection, and click on the Refresh button. The new data about the cluster name or manager name should appear in the table.

Chrome - 🟢

image

image

Firefox - ⚫

Safari - ⚫

🟢 Go to Server APIs, and add an offline API host that can be connected. The data about the cluster name or manager name should not appear in the table.

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

🟢 Go to About, it only should display the version and revision of the application. No reference to installation date.

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

@asteriscos asteriscos merged commit 1da123b into 4.9.0 Apr 3, 2024
4 checks passed
@asteriscos asteriscos deleted the enhancement/6387-registry-stateless branch April 3, 2024 15:16
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.

Move the plugin registry to stateless
4 participants