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 configuration store from saved object to configuration file #6573

Merged
merged 36 commits into from Apr 9, 2024

Conversation

Desvelao
Copy link
Member

@Desvelao Desvelao commented Apr 4, 2024

Description

This pull request rollbacks the configuration stored in a saved object to a configuration file.

Changes:

  • Rollback:
    • Remove ability to manage the API connections from the Server APIs
      • Remove API endpoints
        • POST /hosts/apis/{id}
        • PUT /hosts/apis/{id}
        • DELETE /hosts/apis/{id}
      • Remove methods in ManageHosts
      • Remove form to create or edit the API connection entry
      • Remove buttons to edit or delete the API connection
    • Add information about adding a new API connection
      • Enhance information message with message about configuration cache
    • Remove task to migrate the configuration file to saved object
    • Remove API endpoint to import the configuration file POST /utils/configuration/import
    • Remove Encryption service of the backend side
    • Replace the store system of the configuration based on a saved object with the configuration file
    • Change the cache time of configuration from 60 to 10 to match with the previous system
    • Replace the consideration of the administrator user to the previous one based on the administrator API
      connection role
      • Remove API endpoint to get data about the account GET /utils/account
  • Other enhancements:
    • Redefine the validation of plugins settings:
      • Rename the validation methods:

      validate -> validateUIForm
      validateBackend -> validate

      • Reduce the usage of @osd/config-schema package (used in the related API endpoints)
    • Remove the transformation of input values to configuration values done by the useForm hook and managed externally
    • Minify the references to branding on the default configuration file
    • Change the validation for enrollment.dns on App Settings application. Move the validateServerAddress to SettingsValidators and replace its usage in the Deploy new agent guide
    • Replace the hard-coded value for the path of the configuration file. It is retrieved from the backend side.
    • Refactor the definition of getCustomizationSetting and its usage to get the plugin settings taking into account the hidden values.
    • Remove the default values of some customization settings were displayed on App Settings
    • Fix a problem the Miscellaneous tab of App Settings application was not accessible from UI
    • Remove deprecated createLogFileIfNotExists method
    • Add tests for ConfigurationStore service of the backend side

Issues Resolved

#6570

Evidence

image
image
image
image

Test

rollback-configuraiton-store

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

UI

Test Chrome Firefox Safari
Ensure the Server APIs application does not have the buttons to edit or remove the API application on the Actions column of the table
In the Server APIs application, click on the Add API connection and should display information about modifying the configuration file
Ensure the customization settings are applied when they are defined and the customization is enabled
Go to App Settings application and check it displays the tabs of Configuration and Miscellaneous

Details

⚫ Ensure the Server APIs application does not have the buttons to edit or remove the API application on the Actions column of the table

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ In the Server APIs application, click on the Add API connection and should display information about modifying the configuration file

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Ensure the customization settings are applied when they are defined and the customization is enabled

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ Go to App Settings application and check it displays the tabs of Configuration and Miscellaneous

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

Backend

Test Result
With no configuration file, start Wazuh dashboard, the configuration file should be created with the default configuration
With a defined configuration file, start Wazuh dashboard, and the configuration file should not be replaced by the default content
Go to App Settings, edit a setting, this should be saved into the configuration file

Details

⚫ With no configuration file, start Wazuh dashboard, the configuration file should be created with the default configuration
⚫ With a defined configuration file, start Wazuh dashboard, and the configuration file should not be replaced by the default content
⚫ Go to App Settings, edit a setting, this should be saved into the configuration file

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

…tion file

- Rollback the store system to configuration file
  - Change WAZUH_CORE_CONFIGURATION_CACHE_SECONDS from 60 to 10
  - Create logic to ensure the configuration file is created else create
    it with default configuration on start
  - Remove task to migrate the configuration file to saved object
- Enhance the Configuration service to include references to categories
  and some utility functions
- Remove plugin settings:
  - wazuh_core.instance
  - wazuh_core.encryption_key
…n App Settings application

- Display the real path of the configuration file instead of the fixed value on App Settings
- Add configuration_file property to the response of GET /api/setup
- Refactor the ConfigurationStore services
- Minor enhancements typed code
…er APIs

- Remove buttons to edit and remove from the table
- Change the form to add an API connection by information about editing
  the configuration file
… backend side

- Remove API endpoints and related controllers
  - POST /hosts/apis/{id}
  - PUT /hosts/apis/{id}
  - DELETE /hosts/apis/{id}
- Remove methods to manage the API connections in the ManageHosts
  service
…ue to an error in the backend side

- Renamed setting properties:
  - validate -> validateUIForm
  - validateBackend -> validate
  - Adapted the validation on the affected API endpoints
- Removed transformation of changed values of useForm hook. This
  transformation is now done externally.
- Enhance the validation of enrollment.dns 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 tests to
    apply to SettingsValidator
…ization settings on App Settings

- 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 Desvelao self-assigned this Apr 4, 2024
@Desvelao Desvelao linked an issue Apr 4, 2024 that may be closed by this pull request
15 tasks
- Rollback to the consideration of administrator user based on
  the administrator API connection role
  - Create logic to check this consideration to the DashboardSecurity
    services in frontend and backend side
   - 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
  - Remove previous consideration based on the access to the security
    REST API of the 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
    - 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
…o feat/6570-rollback-plugins-configuration
@Desvelao Desvelao marked this pull request as ready for review April 8, 2024 10:59
@asteriscos asteriscos self-requested a review April 8, 2024 11:09
@JuanGarriuz JuanGarriuz self-requested a review April 8, 2024 11:18
@JuanGarriuz
Copy link
Member

JuanGarriuz commented Apr 8, 2024

Test

rollback-configuration-store

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

UI

Test Chrome Firefox Safari
Ensure the Server APIs application does not have the buttons to edit or remove the API application on the Actions column of the table 🟢
In the Server APIs application, click on the Add API connection and should display information about modifying the configuration file 🟢
Ensure the customization settings are applied when they are defined and the customization is enabled 🟢
Go to App Settings application and check it displays the tabs of Configuration and Miscellaneous 🟢

Details

🟢 Ensure the Server APIs application does not have the buttons to edit or remove the API application on the Actions column of the table

Chrome - 🟢
image

Firefox - ⚫

Safari - ⚫

🟢 In the Server APIs application, click on the Add API connection and should display information about modifying the configuration file

Chrome - 🟢
image

Firefox - ⚫

Safari - ⚫

🟢 Ensure the customization settings are applied when they are defined and the customization is enabled

Chrome - 🟢
image

Firefox - ⚫

Safari - ⚫

🟢 Go to App Settings application and check it displays the tabs of Configuration and Miscellaneous

Chrome - 🟢
image

Firefox - ⚫

Safari - ⚫

Backend

Test Result
With no configuration file, start Wazuh dashboard, the configuration file should be created with the default configuration 🟢
With a defined configuration file, start Wazuh dashboard, and the configuration file should be replaced by the default content 🟢
Go to App Settings, edit a setting, this should be saved into the configuration file

Details

🟢 With no configuration file, start Wazuh dashboard, the configuration file should be created with the default configuration

image
image
image
image

🟢 With a defined configuration file, start Wazuh dashboard, and the configuration file should not be replaced by the default content

image
image

🟡 Go to App Settings, edit a setting, this should be saved into the configuration file

image

🟡 Warning => #6573 (comment)

@asteriscos
Copy link
Member

asteriscos commented Apr 8, 2024

UI

Test Chrome Firefox Safari
Ensure the Server APIs application does not have the buttons to edit or remove the API application on the Actions column of the table 🟢
In the Server APIs application, click on the Add API connection and should display information about modifying the configuration file 🟢
Ensure the customization settings are applied when they are defined and the customization is enabled 🟢
Go to App Settings application and check it displays the tabs of Configuration and Miscellaneous 🟢

Details

🟢 Ensure the Server APIs application does not have the buttons to edit or remove the API application on the Actions column of the table

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

🟢 In the Server APIs application, click on the Add API connection and should display information about modifying the configuration file

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

🟢 Ensure the customization settings are applied when they are defined and the customization is enabled

Chrome - 🟢

image

image

image

Firefox - ⚫

Safari - ⚫

🟢 Go to App Settings application and check it displays the tabs of Configuration and Miscellaneous

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

Backend

Test Result
With no configuration file, start Wazuh dashboard, the configuration file should be created with the default configuration 🟢
With a defined configuration file, start Wazuh dashboard, and the configuration file should be replaced by the default content 🟢
Go to App Settings, edit a setting, this should be saved into the configuration file 🟢

Details

🟢 With no configuration file, start Wazuh dashboard, the configuration file should be created with the default configuration

image

🟢 With a defined configuration file, start Wazuh dashboard, and the configuration file should be replaced by the default content
🟢 Go to App Settings, edit a setting, this should be saved into the configuration file

@JuanGarriuz
Copy link
Member

When I removed the custom logo quickly, the console got an error related with API

image
image

asteriscos
asteriscos previously approved these changes Apr 9, 2024
…n/clear

- Remove API endpoint POST /utils/configuration/clear
  - Remove route controller
… period of time

- 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 defitions 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
Copy link
Contributor

github-actions bot commented Apr 9, 2024

Wazuh Core plugin code coverage (Jest) test % values
Statements 45.37% ( 397 / 875 )
Branches 41.31% ( 157 / 380 )
Functions 43.83% ( 135 / 308 )
Lines 45.61% ( 395 / 866 )

Copy link
Contributor

github-actions bot commented Apr 9, 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 )

@Desvelao
Copy link
Member Author

Desvelao commented Apr 9, 2024

Changes

@Desvelao Desvelao requested a review from asteriscos April 9, 2024 12:24
Copy link
Contributor

github-actions bot commented Apr 9, 2024

Main plugin code coverage (Jest) test % values
Statements 10.81% ( 3750 / 34669 )
Branches 7.27% ( 1653 / 22713 )
Functions 10.52% ( 870 / 8263 )
Lines 10.96% ( 3644 / 33226 )

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: ✔️

Peek 2024-04-09 15-07

@asteriscos asteriscos merged commit 5efc20f into 4.9.0 Apr 9, 2024
4 checks passed
@asteriscos asteriscos deleted the feat/6570-rollback-plugins-configuration branch April 9, 2024 13:11
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.

Rollback the system to save the configuration to configuration file
3 participants