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

[Controls] Add Expensive Queries Fallback #155082

Merged

Conversation

ThomThomson
Copy link
Contributor

@ThomThomson ThomThomson commented Apr 17, 2023

Summary

Fixes #155078.

In main right now if you set up a user with read only access to an index controls will default to using the non-expensive queries, and some features will be missing. This is because without the monitor privilege, it is impossible to check whether expensive queries are on or off.

Because the default setting for allow_expensive_queries is true, we should default to true for cases where a security exception prevents us from checking the value of the setting.

How to test

  • Install the web logs sample data
  • Add a role that has Dashboard read permission and read permission for the logs web traffic index.
  • Log in as the user and load up the dashboard.
  • You should not see the warning and the control should work as expected

Open question

Should we change this default behaviour?

  • With this change, in the unlikely scenario that a cluster has allow_expensive_queries off, and the user cannot check the value of the setting due to a missing permission, the Controls will throw errors. This is similar to the way the table list view and solutions work - they don't even check for the value of the setting.
  • Without this change, we are requiring analysts who use the controls to have the monitor permission.

@ThomThomson ThomThomson added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Input Control Input controls visualization labels Apr 17, 2023
@ThomThomson ThomThomson marked this pull request as ready for review April 17, 2023 20:34
@ThomThomson ThomThomson requested a review from a team as a code owner April 17, 2023 20:34
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

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

Tested locally following the given instructions and everything worked as expected 🎉 Left one tiny nit but nothing worth holding up this PR.

@@ -39,6 +40,17 @@ export const setupOptionsListClusterSettingsRoute = ({ http }: CoreSetup) => {
},
});
} catch (e) {
if (e instanceof errors.ResponseError && e.body.error.type === 'security_exception') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also show a toast, notifying users that they are missing permissions? We do something like this in maps https://github.com/elastic/kibana/blob/main/x-pack/plugins/maps/public/classes/sources/es_search_source/util/load_index_settings.ts#L46 when fetching index.max_result_window, where we use a default but notify users when there is a permission problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm honestly not sure about this. Yes there is a permissions problem, which should probably bubble up - but we don't really want to tie the usage of Controls to the monitor privilege so closely. If there was a toast, it would basically tell the end-user - not the author in this case because they usually have the right permissions - that in order to use controls they need the monitor privilege on the index they use.

If there was a way to warn only the author when they were setting up the roles that would be okay with me, but I don't think we have that kind of mechanism.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe a warning on the server-side? Is that a pattern that we use?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a warning on the server-side? Is that a pattern that we use?

not sure. For maps, we wanted users to see the warning since not being able to read the value may cause problems

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'm going to merge this as is, but if it does cause that problem we're aware of - where allow_expensive_queries is off and the user doesn't have permissions to check - we can revisit this conversation and show a toast, or do some other less intrusive warning.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 432 435 +3

Total ESLint disabled count

id before after diff
securitySolution 512 515 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@ThomThomson ThomThomson merged commit 66f68d4 into elastic:main Apr 18, 2023
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 18, 2023
## Summary
If the user has no permission to check for the value of `allow_expensive_queries`, it will now default to true instead of false.

(cherry picked from commit 66f68d4)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.7

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 18, 2023
# Backport

This will backport the following commits from `main` to `8.7`:
- [[Controls] Add Expensive Queries Fallback
(#155082)](#155082)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Devon
Thomson","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-04-18T17:04:26Z","message":"[Controls]
Add Expensive Queries Fallback (#155082)\n\n## Summary\r\nIf the user
has no permission to check for the value of `allow_expensive_queries`,
it will now default to true instead of
false.","sha":"66f68d4123a333f4651662f70eb2465ade7e9081","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Input
Control","Team:Presentation","loe:days","impact:high","backport:prev-minor","v8.8.0"],"number":155082,"url":"https://github.com/elastic/kibana/pull/155082","mergeCommit":{"message":"[Controls]
Add Expensive Queries Fallback (#155082)\n\n## Summary\r\nIf the user
has no permission to check for the value of `allow_expensive_queries`,
it will now default to true instead of
false.","sha":"66f68d4123a333f4651662f70eb2465ade7e9081"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/155082","number":155082,"mergeCommit":{"message":"[Controls]
Add Expensive Queries Fallback (#155082)\n\n## Summary\r\nIf the user
has no permission to check for the value of `allow_expensive_queries`,
it will now default to true instead of
false.","sha":"66f68d4123a333f4651662f70eb2465ade7e9081"}}]}]
BACKPORT-->

Co-authored-by: Devon Thomson <[email protected]>
rylnd added a commit that referenced this pull request Apr 21, 2023
* 8.7: (93 commits)
  [8.7] [Controls] Use EUI Selectable for Field search (#151231) (#155454)
  [8.7] [Synthetics] Fix  performance breakdown link from error details page (#155393) (#155427)
  [8.7] [DOCS] Remove or move book-scoped attributes (#155210) (#155426)
  [8.7] [Synthetics] add default email recovery message (#154862) (#155418)
  [8.7] [Uptime] Add both both ip filters for view host in uptime location for host and monitor (#155382) (#155399)
  [8.7] Setup Node.js environment before instrumenting Kibana with APM. (#155063) (#155300)
  [8.7] [Discover] Address react warnings for legacy table (#154579) (#155345)
  [8.7] [Fleet] Fix logs useless rerender (#155305) (#155310)
  [8.7] [kbn-failed-test-reporter-cli] truncate report message to fix github api call failure (#155141) (#155286)
  [8.7][APM] Fleet migration support for bundled APM package (#153159)  (#155281)
  [8.7] [Enterprise Search] Fix Connector scheduling show week information correctly (#155191) (#155227)
  [8.7] [Synthetics] Fix pending count in case of location filtering (#155200) (#155225)
  [8.7] [Controls] Add Expensive Queries Fallback (#155082) (#155189)
  [8.7] [data view field editor] Runtime field code editor - move state out of controller (#155107) (#155150)
  [8.7] [FullStory] Update snippet (#153570) (#155138)
  [8.7] [Security Solution][Exceptions] - Fix exception operator logic when mapping conflict (#155071) (#155094)
  [DOCS] Adds 8.7.1 release notes (#154844)
  [8.7] Sync bundled packages with Package Storage (#155042)
  [APM] plugin description (#154811)
  Update api.asciidoc (#155021)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Input Control Input controls visualization impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.7.1 v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Controls] Allow Expensive Queries Fallback
6 participants