-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Support validation for UI Settings #46717
Comments
Pinging @elastic/kibana-platform |
Just my 2 cents, as I opened #58437: I could also easily use a dedicated Advanced Settings API (#14873), but I used the Saved Objects API as per @joshdover comment on #14873:
As correctly said in this thread, my main concern is validation. |
validation schema can be added during uiSettings registration #59694 |
Pinging @elastic/kibana-core (Team:Core) |
An audit of all calls to register uiSettings show that very few have explicit validations on the schema. Validations are defined explicitly in the following cases:
Undeclared schema validations:
cc @joshdover |
What does it mean? I checked out the first 3 items from the list and all of them define validation schema:
We already validate definitions and overrides kibana/src/core/server/ui_settings/ui_settings_service.ts Lines 105 to 122 in 4d562e5
uiSettings before write them to the store
and when reading them from store
It seems we are good to close the issue? |
Closing as validation seems to be in place for all the ui settings I sampled. |
Proposal
The UI Settings Service should allow for individual settings to register custom validators to prevent invalid values from being read or written.
There are several ways to configure an advanced setting today:
kibana.yml
'suiSettings.overrides.<key>
config
objectWe can (and should) enforce validation on
write
for methods 1 - 4 above. Since option 5 is technically possible, even if not supported, we will also need to account for the fact that invalid settings may exist onread
, and fallback to the default setting value.Motivation
#44678 is introducing a new advanced setting to enable space-specific default routes. Previously, this setting was controlled by the
server.defaultRoute
option inkibana.yml
.Specifying this in the
yml
file ensured that only true admins had access to this configuration, and the schema validation (must start with a/
) was sufficient enough to ensure that an obvious misconfiguration wasn't possible.Now that this setting is moving to the Advanced Settings UI/UI Settings Service, is is trivial for any user with the appropriate privileges to accidentally misconfigure this setting. While the Advanced Settings UI comes with a warning that "you can break things here", we really should be providing some level of validation for each setting.
We ended up creating a "default route service" in order to encapsulate this logic, otherwise it would need to be duplicated in OSS and X-Pack. If the UI Settings service allowed for validation, this service could be removed altogether, and it would enable a better user experience by preventing the setting from being accidentally misconfigured to begin with.
Example:
.kibana
index contains:Reading and blindly trusting this value would send users to another domain completely. If the
defaultRoute
setting could register a validator, we could ensure that the route is a valid relative url before using it, without having to manually check every place we need to use this value./cc @kobelb
The text was updated successfully, but these errors were encountered: