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

Rollback the system to save the configuration to configuration file #6570

Closed
15 tasks done
Tracked by #6127
Desvelao opened this issue Apr 2, 2024 · 13 comments · Fixed by #6573 or #6612
Closed
15 tasks done
Tracked by #6127

Rollback the system to save the configuration to configuration file #6570

Desvelao opened this issue Apr 2, 2024 · 13 comments · Fixed by #6573 or #6612
Assignees
Labels

Comments

@Desvelao
Copy link
Member

Desvelao commented Apr 2, 2024

Description
In a previous issue #6201, we replaced the system to save the plugin settings into a saved object. We have considered the new system includes some breaking changes, so we delay the change of the configuration system to a future release. So, we will do a rollback to the previous system based on the configuration file, but we keep the enhancements applied in the other issue.

Tasks

  • Replace the system to save the plugin configuration from a saved object to a configuration file on the ConfiguratioStore service of the backend side
  • Remove the management of API connections
    • Backend side
      • API endpoints
      • methods in ManageHosts service
    • Frontend side
  • Remove ability to import the file
    • On start
    • API endpoint
  • Add reference to the path of the configuration file in App settings
  • Add property to the setting to define that setting is configurable from file
  • Add process to create the default configuration file if it does not exist
  • Remove task to migrate the configuration in a configuration file to saved object
  • Replace the management of the administrator user
  • Add tests related to the configuration file
@Desvelao Desvelao self-assigned this Apr 2, 2024
@Desvelao Desvelao changed the title Rollback the sytem to save the configuration to configuration file Rollback the system to save the configuration to configuration file Apr 2, 2024
@Desvelao
Copy link
Member Author

Desvelao commented Apr 2, 2024

Changes (24/04/02)

  • Revert the changes to store the configuration from a saved object to a configuration file (wazuh.yml)

@Desvelao
Copy link
Member Author

Desvelao commented Apr 2, 2024

Declare the setting is configurable from file

type TPluginSetting = {
  store: {
    file: {
      configurable?: boolean
    }
  }
}

@Desvelao
Copy link
Member Author

Desvelao commented Apr 2, 2024

Refactor the path to the configuration file displayed on the UI

The path to the configuration file displayed on the UI had a hardcoded value. This will be a bug if the configuration file is stored in another path.

I created a mechanism to retrieve the path of the configuration file from the backend through the GET /api/setup endpoint adding the configuration_file property to the response:

This value is coming from the ConfigurationStore service from the backend side.

GET /api/setup

{
  configuration_file: 'path/to/configuration/file'
}

@Desvelao
Copy link
Member Author

Desvelao commented Apr 2, 2024

Remove the management of the Server APIs

Frontend side

Replace the add API connection flyout

The Add API connection flyout had a form to create the new API host. This ability has been removed to display data about editing the configuration file.

I took the view and moved to the flyout, then I removed the check of the API connections in favor of the main table. I added a callout to display information about the configuration cache.
image

Edit and delete buttons

  • Removed the buttons in the API connections table

Backend side

Removed the API endpoints and controllers to manage the API connections:

  • POST /hosts/apis/{id}
  • PUT /hosts/apis/{id}
  • DELETE /hosts/apis/{id}
  • Remove methods to manage the API connections in the ManageHosts
    service

@Desvelao
Copy link
Member Author

Desvelao commented Apr 2, 2024

Fix the inaccessible view of Miscellaneous tab on App Settings

The pull request https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337/files#diff-b75dc065dc395d5362392d5d6c18b449c4334a8ad31b2af1c698f25b37fde225L156-L165 removed the logic that does possible the Miscellaneous tab was displayed on the App Settings.

I have fixed to be accessible again.

@Desvelao
Copy link
Member Author

Desvelao commented Apr 3, 2024

Research

I am researching a found bug that was introduced on #6337 causing some settings could not be updated from App Settings due to a validation error in the Configuration service of the backend side.

Update:

I fixed the problem refactoring the validations in the backend and frontend side.

Changes:

  • Renamed setting properties:
    • validate -> validateUIForm
    • validateBackend -> validate
      • Removed the usage of schema package allowing these methods can used by the Configuration service.
    • Adapted the validation on the affected API endpoints
  • Removed transformation of changed values of useForm hook. This
    transformation is now done externally.

@Desvelao
Copy link
Member Author

Desvelao commented Apr 3, 2024

Changes

  • Remove API endpoint POST /utils/configuration/import
  • Fix error clearing the settings of customization logos

@Desvelao
Copy link
Member Author

Desvelao commented Apr 4, 2024

Changes

  • Enhance validation of plugin settings
  • Enhance validation of enrollment.dns plugin setting
    • Replace the validation of the server address input on Deploy new agent
      guide by the validation of enrollment.dns plugin setting
    • Remove validateServerAddress method and related tests. Move method and to SettingsValidator
  • Minor tasks of cleaning code
  • Remove ability to import configuration from file
  • Enhance Configuration service:
    • Create getSettingValueIfNotSet method for Configuration services to
      manage the customization settings
      • Adapt the getCustomizationSetting method of Configuration service
        to use getSettingValueIfNotSet
      • Change the parameters of getCustomizationSetting of Configuration
        service to support multiple settings
      • Adapt printer to the usage of getCustomizationSettings redefinition
      • Enhance code typings

@Desvelao
Copy link
Member Author

Desvelao commented Apr 5, 2024

Rollback the consideration of the administrator user

The users considered as administrator was changed on #6337, that was based on the permissions to access to the security API of Wazuh indexer.

We do a rollback to the previous system based on the Wazuh API roles that the user must have the administrator role.

Changes

  • Remove consideration of administrator user based on the access to the security REST API of platform:
    • Remove API endpoint GET /utils/account and getPluginScopedAccount controller
    • Remove fetch user account data from the frontend side
    • Remove fetchAccount method of DashboardSecurity service on the frontend side
  • Create logic related to the consideration of administrator user based on administrator API connection role
    • Add getAccountFromJWTAPIDecodedToken method to frontend side
    • Adapt the WzAuthentication service to use the getAccountFromJWTAPIDecodedToken
    • Add a constant that defines the ID for the administrator role of the API connection
    • Adapt routeDecoratorProtectedAdministrator route decorator
  • Enhance the message about the administrator missing requirements
  • Rename administrator_error_message to administrator_requirements related to the consideration of administrator user

Screenshots

image
image
image

@Desvelao
Copy link
Member Author

Desvelao commented Apr 5, 2024

WIP

  • Adding tests for the ConfigurationStore service related to the configuration file

@Desvelao
Copy link
Member Author

Desvelao commented Apr 8, 2024

Changes

  • Add tests for the ConfigurationStore service related to the configuration file
  • Update development branch with latest changes of base branch
  • Research a problem with the creation of the configuration file directory
  • Minor fixes related to rollback

@Desvelao
Copy link
Member Author

Desvelao commented Apr 9, 2024

Declare the setting is configurable from file

type TPluginSetting = {
  store: {
    file: {
      configurableManaged?: boolean
      defaultBlock?: string
      transformFrom?: (value: any) => any
      
    }
  }
}

@Desvelao
Copy link
Member Author

Desvelao commented Apr 9, 2024

Changes

  • Add plugin setting category: API_CONNECTION (related to hosts setting)
  • Replace the category of hosts plugin setting
  • Refactor the setting.store.file interface:
    • Remove configurable
    • Add configurableManaged and defaultBlock
    • Adapt the plugin settings definitions with these changes
  • Remove the configuration block related to the API connections from the ConfigurationStore service to the plugin setting definition through the defaultBlock
  • Enhance logging on ManageHosts
  • Fix tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
2 participants