-
Notifications
You must be signed in to change notification settings - Fork 187
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
Add validation to the plugin settings #4503
Conversation
Create the plugin setting schema Define the current plugin settings Remove refactored code
Use dynamically the definition of the plugin settings
Add new hooks to manage when a input value or form has changed Add new inputs components
Refactor Header, BottomBar, Configuration components Remove deprecated files
Changed the endpoint that updating the plugin setting to support multiple settings at the same time Refactor the getConfiguration service. Split the logic to: - Read the file and transform to JSON - Obfuscate the password key of the host configuration
Create services to validate Add the validation to the plugin settings
`Settings/Configuration`
…wazuh/wazuh-kibana-app into feat/settings-validation
…wazuh/wazuh-kibana-app into feat/settings-validation
…wazuh/wazuh-kibana-app into feat/settings-validation
…n` to control the global state of the form
…wazuh/wazuh-kibana-app into feat/settings-validation
…wazuh/wazuh-kibana-app into feat/settings-validation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
TR: ✔️ Screencast.from.26-10-22.10.02.57.webmScreencast.from.26-10-22.09.37.23.webm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
77fcd93
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TR: ✔️
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.4-2.3-wzd 4.4-2.3-wzd
# Navigate to the new working tree
cd .worktrees/backport-4.4-2.3-wzd
# Create a new branch
git switch --create backport-4503-to-4.4-2.3-wzd
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 5c0c413f7357afe7388af748007fec62c25dd9a0
# Push it to GitHub
git push --set-upstream origin backport-4503-to-4.4-2.3-wzd
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.4-2.3-wzd Then, create a pull request where the |
* feat(settings): centralize the plugin settings Create the plugin setting schema Define the current plugin settings Remove refactored code * feat(settings): add setting services and replaced the references to constants * feat(settings): refactor the content of the default configuration file Use dynamically the definition of the plugin settings * feat(inputs): create new inputs components Add new hooks to manage when a input value or form has changed Add new inputs components * feat(configuration): refactor the form of Settings/Configuration Refactor Header, BottomBar, Configuration components Remove deprecated files * feat(settings): support updating multiple setting at the same time Changed the endpoint that updating the plugin setting to support multiple settings at the same time Refactor the getConfiguration service. Split the logic to: - Read the file and transform to JSON - Obfuscate the password key of the host configuration * feat: add validation to the plugin settings Create services to validate Add the validation to the plugin settings * feat(validation): add validation to the `PUT /utils/configuration` endpoint * feat(validation): add validation to the configuration form in `Settings/Configuration` * feat(validatio): remove no used import * clean: remove not used code * fix: fixed category name in `Settings/Configuration` * fix(settings): Fix accessing to `validate` of undefined error * fix(settings): fixed error due to missing service * fix(settings): refactor the form and inputs of `Settings/Configuration` to control the global state of the form * fix: add value transformation for the form inputs and output of fields changed * fix: Fixed some settings validation * fix(settings): fixed validation of literals * fix(settings): removed unused import * fix(settings): renamed properties related to transform the value of the input * feat(settings): add description to the plugin setting definition properties * fix(settings): fix getConfiguration service when the configuration file has no `hosts` entry * fix(settings): Fixed error when do changes of the `useForm` hook an rename methods of this * tests(settings): add test related to the plugin settings and its configuration from the UI * feat(settings): rename plugin setting options of type select to match its type * feat(settings): add plugin settings services and enhance the description of the plugin settings in default configuration file and UI * tests(input-form): update tests of InputForm component * test(configuration-file): add tests of the default configuration file * feat(settings): remove `extensions.mitre` plugin setting * test(settings): add test to validate the plugin setting when updating it through PUT /utils/configuration fix some plugin settings validation * feat(settings): add documentation to some setting services and test some of them * fix: fixed documentation of setting service * doc(settings): move the documentation of the plugin setting properties * fix(settings): rename some plugin setting properties because of request changes - Rename plugin setting properties: - `default` to `defaultValue` - `defaultHidden` to `defaultValueIfNotSet` - `configurableFile` to `isConfigurableFromFile` - configurableUI` to `isConfigurableFromUI` - `requireHealthCheck` to `requiresRunningHealthCheck` - `requireReload` to `requiresReloadingBrowserTab` - `requireRestart` to `requiresRestartingPluginPlatform` - Fix tests * tests: fix tests of InputForm component * fix: response properties when saving the configuration * fix(settings): fix validation plugin settings value in the UI * fix(settings): fix validation of numbers * fix(settings): fix validation of numbers * test(settings): Add tests related to validation for the `useForm` hook and the `InputForm` component * fix(settings): fix displaying toast to run the healthcheck when saving the configuration * Added category sorting + description + docs link * Added settings sorting within their category * Fixed constant types definition * Checks if localCompare exists validation * fix(settings): fixed plugin setting description doesn't display the minimum number value when it is falsy (0) * fix(settings): fix setting type of `wazuh.monitoring.replicas` and limit the valid number for the number input * feat(settins): add plugin settings category description * fix(settings): fix a problem comparing the initial and current value for the plugin settings of the `number` type * fix(settings): fix typo in setting description * feat(settings): enhance the validation of plugin settings related to indices or index patterns taking in account the supported characters * feat(settings): add validation of setting values in the inputs * fix(tests): format tables of the tests * Fix small typo * fix(settings): fix a typo in a toast related to modify the plugin settings from UI * Changed Custom Branding documentation link * Merge centralize plugin settings PR * Delete unused imports * fix(settings): fix a problem with the useForm hook * fix(settings): refactor the settings validation function to a class and rename the file * feat(settings): add check for integer numbers and adapt the affected settings * Fix semi-colon error * changelog: add entries to changelog * Change validation error for inputs that don't allow whitespaces Co-authored-by: Federico Rodriguez <[email protected]> Co-authored-by: Álex <[email protected]> (cherry picked from commit 5c0c413)
Add validation to the plugin settings (#4503) * feat(settings): centralize the plugin settings Create the plugin setting schema Define the current plugin settings Remove refactored code * feat(settings): add setting services and replaced the references to constants * feat(settings): refactor the content of the default configuration file Use dynamically the definition of the plugin settings * feat(inputs): create new inputs components Add new hooks to manage when a input value or form has changed Add new inputs components * feat(configuration): refactor the form of Settings/Configuration Refactor Header, BottomBar, Configuration components Remove deprecated files * feat(settings): support updating multiple setting at the same time Changed the endpoint that updating the plugin setting to support multiple settings at the same time Refactor the getConfiguration service. Split the logic to: - Read the file and transform to JSON - Obfuscate the password key of the host configuration * feat: add validation to the plugin settings Create services to validate Add the validation to the plugin settings * feat(validation): add validation to the `PUT /utils/configuration` endpoint * feat(validation): add validation to the configuration form in `Settings/Configuration` * feat(validatio): remove no used import * clean: remove not used code * fix: fixed category name in `Settings/Configuration` * fix(settings): Fix accessing to `validate` of undefined error * fix(settings): fixed error due to missing service * fix(settings): refactor the form and inputs of `Settings/Configuration` to control the global state of the form * fix: add value transformation for the form inputs and output of fields changed * fix: Fixed some settings validation * fix(settings): fixed validation of literals * fix(settings): removed unused import * fix(settings): renamed properties related to transform the value of the input * feat(settings): add description to the plugin setting definition properties * fix(settings): fix getConfiguration service when the configuration file has no `hosts` entry * fix(settings): Fixed error when do changes of the `useForm` hook an rename methods of this * tests(settings): add test related to the plugin settings and its configuration from the UI * feat(settings): rename plugin setting options of type select to match its type * feat(settings): add plugin settings services and enhance the description of the plugin settings in default configuration file and UI * tests(input-form): update tests of InputForm component * test(configuration-file): add tests of the default configuration file * feat(settings): remove `extensions.mitre` plugin setting * test(settings): add test to validate the plugin setting when updating it through PUT /utils/configuration fix some plugin settings validation * feat(settings): add documentation to some setting services and test some of them * fix: fixed documentation of setting service * doc(settings): move the documentation of the plugin setting properties * fix(settings): rename some plugin setting properties because of request changes - Rename plugin setting properties: - `default` to `defaultValue` - `defaultHidden` to `defaultValueIfNotSet` - `configurableFile` to `isConfigurableFromFile` - configurableUI` to `isConfigurableFromUI` - `requireHealthCheck` to `requiresRunningHealthCheck` - `requireReload` to `requiresReloadingBrowserTab` - `requireRestart` to `requiresRestartingPluginPlatform` - Fix tests * tests: fix tests of InputForm component * fix: response properties when saving the configuration * fix(settings): fix validation plugin settings value in the UI * fix(settings): fix validation of numbers * fix(settings): fix validation of numbers * test(settings): Add tests related to validation for the `useForm` hook and the `InputForm` component * fix(settings): fix displaying toast to run the healthcheck when saving the configuration * Added category sorting + description + docs link * Added settings sorting within their category * Fixed constant types definition * Checks if localCompare exists validation * fix(settings): fixed plugin setting description doesn't display the minimum number value when it is falsy (0) * fix(settings): fix setting type of `wazuh.monitoring.replicas` and limit the valid number for the number input * feat(settins): add plugin settings category description * fix(settings): fix a problem comparing the initial and current value for the plugin settings of the `number` type * fix(settings): fix typo in setting description * feat(settings): enhance the validation of plugin settings related to indices or index patterns taking in account the supported characters * feat(settings): add validation of setting values in the inputs * fix(tests): format tables of the tests * Fix small typo * fix(settings): fix a typo in a toast related to modify the plugin settings from UI * Changed Custom Branding documentation link * Merge centralize plugin settings PR * Delete unused imports * fix(settings): fix a problem with the useForm hook * fix(settings): refactor the settings validation function to a class and rename the file * feat(settings): add check for integer numbers and adapt the affected settings * Fix semi-colon error * changelog: add entries to changelog * Change validation error for inputs that don't allow whitespaces Co-authored-by: Federico Rodriguez <[email protected]> Co-authored-by: Álex <[email protected]> (cherry picked from commit 5c0c413) Co-authored-by: Antonio <[email protected]>
* feat(settings): centralize the plugin settings Create the plugin setting schema Define the current plugin settings Remove refactored code * feat(settings): add setting services and replaced the references to constants * feat(settings): refactor the content of the default configuration file Use dynamically the definition of the plugin settings * feat(inputs): create new inputs components Add new hooks to manage when a input value or form has changed Add new inputs components * feat(configuration): refactor the form of Settings/Configuration Refactor Header, BottomBar, Configuration components Remove deprecated files * feat(settings): support updating multiple setting at the same time Changed the endpoint that updating the plugin setting to support multiple settings at the same time Refactor the getConfiguration service. Split the logic to: - Read the file and transform to JSON - Obfuscate the password key of the host configuration * feat: add validation to the plugin settings Create services to validate Add the validation to the plugin settings * feat(validation): add validation to the `PUT /utils/configuration` endpoint * feat(validation): add validation to the configuration form in `Settings/Configuration` * feat(validatio): remove no used import * clean: remove not used code * fix: fixed category name in `Settings/Configuration` * fix(settings): Fix accessing to `validate` of undefined error * fix(settings): fixed error due to missing service * fix(settings): refactor the form and inputs of `Settings/Configuration` to control the global state of the form * fix: add value transformation for the form inputs and output of fields changed * fix: Fixed some settings validation * fix(settings): fixed validation of literals * fix(settings): removed unused import * fix(settings): renamed properties related to transform the value of the input * feat(settings): add description to the plugin setting definition properties * fix(settings): fix getConfiguration service when the configuration file has no `hosts` entry * fix(settings): Fixed error when do changes of the `useForm` hook an rename methods of this * tests(settings): add test related to the plugin settings and its configuration from the UI * feat(settings): rename plugin setting options of type select to match its type * feat(settings): add plugin settings services and enhance the description of the plugin settings in default configuration file and UI * tests(input-form): update tests of InputForm component * test(configuration-file): add tests of the default configuration file * feat(settings): remove `extensions.mitre` plugin setting * test(settings): add test to validate the plugin setting when updating it through PUT /utils/configuration fix some plugin settings validation * feat(settings): add documentation to some setting services and test some of them * fix: fixed documentation of setting service * doc(settings): move the documentation of the plugin setting properties * fix(settings): rename some plugin setting properties because of request changes - Rename plugin setting properties: - `default` to `defaultValue` - `defaultHidden` to `defaultValueIfNotSet` - `configurableFile` to `isConfigurableFromFile` - configurableUI` to `isConfigurableFromUI` - `requireHealthCheck` to `requiresRunningHealthCheck` - `requireReload` to `requiresReloadingBrowserTab` - `requireRestart` to `requiresRestartingPluginPlatform` - Fix tests * tests: fix tests of InputForm component * fix: response properties when saving the configuration * fix(settings): fix validation plugin settings value in the UI * fix(settings): fix validation of numbers * fix(settings): fix validation of numbers * test(settings): Add tests related to validation for the `useForm` hook and the `InputForm` component * fix(settings): fix displaying toast to run the healthcheck when saving the configuration * Added category sorting + description + docs link * Added settings sorting within their category * Fixed constant types definition * Checks if localCompare exists validation * fix(settings): fixed plugin setting description doesn't display the minimum number value when it is falsy (0) * fix(settings): fix setting type of `wazuh.monitoring.replicas` and limit the valid number for the number input * feat(settins): add plugin settings category description * fix(settings): fix a problem comparing the initial and current value for the plugin settings of the `number` type * fix(settings): fix typo in setting description * feat(settings): enhance the validation of plugin settings related to indices or index patterns taking in account the supported characters * feat(settings): add validation of setting values in the inputs * fix(tests): format tables of the tests * Fix small typo * fix(settings): fix a typo in a toast related to modify the plugin settings from UI * Changed Custom Branding documentation link * Merge centralize plugin settings PR * Delete unused imports * fix(settings): fix a problem with the useForm hook * fix(settings): refactor the settings validation function to a class and rename the file * feat(settings): add check for integer numbers and adapt the affected settings * Fix semi-colon error * changelog: add entries to changelog * Change validation error for inputs that don't allow whitespaces Co-authored-by: Federico Rodriguez <[email protected]> Co-authored-by: Álex <[email protected]> (cherry picked from commit 5c0c413)
Add validation to the plugin settings (#4503) * feat(settings): centralize the plugin settings Create the plugin setting schema Define the current plugin settings Remove refactored code * feat(settings): add setting services and replaced the references to constants * feat(settings): refactor the content of the default configuration file Use dynamically the definition of the plugin settings * feat(inputs): create new inputs components Add new hooks to manage when a input value or form has changed Add new inputs components * feat(configuration): refactor the form of Settings/Configuration Refactor Header, BottomBar, Configuration components Remove deprecated files * feat(settings): support updating multiple setting at the same time Changed the endpoint that updating the plugin setting to support multiple settings at the same time Refactor the getConfiguration service. Split the logic to: - Read the file and transform to JSON - Obfuscate the password key of the host configuration * feat: add validation to the plugin settings Create services to validate Add the validation to the plugin settings * feat(validation): add validation to the `PUT /utils/configuration` endpoint * feat(validation): add validation to the configuration form in `Settings/Configuration` * feat(validatio): remove no used import * clean: remove not used code * fix: fixed category name in `Settings/Configuration` * fix(settings): Fix accessing to `validate` of undefined error * fix(settings): fixed error due to missing service * fix(settings): refactor the form and inputs of `Settings/Configuration` to control the global state of the form * fix: add value transformation for the form inputs and output of fields changed * fix: Fixed some settings validation * fix(settings): fixed validation of literals * fix(settings): removed unused import * fix(settings): renamed properties related to transform the value of the input * feat(settings): add description to the plugin setting definition properties * fix(settings): fix getConfiguration service when the configuration file has no `hosts` entry * fix(settings): Fixed error when do changes of the `useForm` hook an rename methods of this * tests(settings): add test related to the plugin settings and its configuration from the UI * feat(settings): rename plugin setting options of type select to match its type * feat(settings): add plugin settings services and enhance the description of the plugin settings in default configuration file and UI * tests(input-form): update tests of InputForm component * test(configuration-file): add tests of the default configuration file * feat(settings): remove `extensions.mitre` plugin setting * test(settings): add test to validate the plugin setting when updating it through PUT /utils/configuration fix some plugin settings validation * feat(settings): add documentation to some setting services and test some of them * fix: fixed documentation of setting service * doc(settings): move the documentation of the plugin setting properties * fix(settings): rename some plugin setting properties because of request changes - Rename plugin setting properties: - `default` to `defaultValue` - `defaultHidden` to `defaultValueIfNotSet` - `configurableFile` to `isConfigurableFromFile` - configurableUI` to `isConfigurableFromUI` - `requireHealthCheck` to `requiresRunningHealthCheck` - `requireReload` to `requiresReloadingBrowserTab` - `requireRestart` to `requiresRestartingPluginPlatform` - Fix tests * tests: fix tests of InputForm component * fix: response properties when saving the configuration * fix(settings): fix validation plugin settings value in the UI * fix(settings): fix validation of numbers * fix(settings): fix validation of numbers * test(settings): Add tests related to validation for the `useForm` hook and the `InputForm` component * fix(settings): fix displaying toast to run the healthcheck when saving the configuration * Added category sorting + description + docs link * Added settings sorting within their category * Fixed constant types definition * Checks if localCompare exists validation * fix(settings): fixed plugin setting description doesn't display the minimum number value when it is falsy (0) * fix(settings): fix setting type of `wazuh.monitoring.replicas` and limit the valid number for the number input * feat(settins): add plugin settings category description * fix(settings): fix a problem comparing the initial and current value for the plugin settings of the `number` type * fix(settings): fix typo in setting description * feat(settings): enhance the validation of plugin settings related to indices or index patterns taking in account the supported characters * feat(settings): add validation of setting values in the inputs * fix(tests): format tables of the tests * Fix small typo * fix(settings): fix a typo in a toast related to modify the plugin settings from UI * Changed Custom Branding documentation link * Merge centralize plugin settings PR * Delete unused imports * fix(settings): fix a problem with the useForm hook * fix(settings): refactor the settings validation function to a class and rename the file * feat(settings): add check for integer numbers and adapt the affected settings * Fix semi-colon error * changelog: add entries to changelog * Change validation error for inputs that don't allow whitespaces Co-authored-by: Federico Rodriguez <[email protected]> Co-authored-by: Álex <[email protected]> (cherry picked from commit 5c0c413)
Description
This PR:
Settings/Configuration
form:PUT /utils/configuration
useForm
hook. Validate values.InputFrom
component renders the validation errors. Generic.PUT /utils/configuration
Closes #4446
Screenshots
Input's validation, invalid settings highlight, error count display, and disabled of the save button.
Warning icon added to the invalid settings, reason displayed on mouseover.
Tests
Manual tests
Scenario: Set an invalid value for the setting in
Settings/Configuration
formWhen the user changes the input value to something invalid. This depends on each setting validation.
Then an error should appear below the input form.
And the setting should be red colored and highlighted as invalid.
And the bottom bar should display the count settings with invalid values.
And the save button should be disabled.
Scenario: Set 2 or more invalid values for the settings in
Settings/Configuration
formWhen the user changes the input value of 2 or more settings to invalid values. This depends on each setting validation.
Then an error should appear below the input form for each setting.
And the settings should be red colored and highlighted as invalid.
And the bottom bar should display the count settings with invalid values.
And the save button should be disabled.
Scenario: Set a valid value for the setting in
Settings/Configuration
formWhen the user changes the input value to a valid value. This depends on each setting validation.
Then it should not appear as a validation error below the input.
Scenario: Send invalid values to update the plugin configuration through the plugin API endpoint
When the user sends (using any rest client) a request to
PUT /utils/configuration
with one or more settings, where at least one of them has an invalid value.Then it should reply with a bad request displaying the validation error.
Automatic tests
server/routes/wazuh-utils/wazuh-utils.test.ts
public/components/common/form/hooks.test.tsx
public/components/common/form/index.test.tsx
common/plugin-settings.test.ts
Run all PR tests