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
[Security Solution] Persistent rules table state #145111
Conversation
46606d8
to
3200603
Compare
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
cd6b631
to
eaf2380
Compare
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.
I've briefly looked through the implementation and left some initial comments. I think my biggest concern currently is about the usage of local storage. Therefore, I propose discussing alternatives before proceeding with the implementation.
x-pack/plugins/security_solution/public/common/hooks/use_url_state.ts
Outdated
Show resolved
Hide resolved
...n_engine/rule_management_ui/components/rules_table/rules_table_filters/rule_search_field.tsx
Outdated
Show resolved
Hide resolved
...tion_engine/rule_management_ui/components/rules_table/rules_table/rules_table_saved_state.ts
Outdated
Show resolved
Hide resolved
...ne/rule_management_ui/components/rules_table/rules_table/use_sync_rules_table_saved_state.ts
Outdated
Show resolved
Hide resolved
...tion_engine/rule_management_ui/components/rules_table/rules_table/rules_table_saved_state.ts
Outdated
Show resolved
Hide resolved
fd0af5c
to
1c6cf42
Compare
88b09a5
to
1094c24
Compare
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @maximpn |
**Addresses:** elastic#140263 ## Summary It implements rules table state persistence. Reopening or reloading of the page loads the same state as well as navigation from another page inside or outside the security plugin. https://user-images.githubusercontent.com/3775283/201983621-e57e8c64-d5fb-4111-92df-ebe912dada38.mov ## Details The changes persist the rules table state in the url and the session storage to be able to recover after navigation from another page. The following parameters are persisted - search term, tags and elastic vs custom filters - sorting field and sorting direction - page number **(only in the url)** and page size Page number is only persisted in the url. Avoiding persistence a page number in the session storage make the UX more predictable that users upon returning to the page expect the first page to be selected. Selection state is not persisted since it can lead to URL overflow problem. According to the different resources for example [this one](https://www.geeksforgeeks.org/maximum-length-of-a-url-in-different-browsers/) the maximum length should not exceed 2KB though Chrome supports URLs up to 2MB. Besides that this PR adds - unit tests which coved edge cases - basic Cypress tests What is not done and will be addressed in the next PRs - persistence of the selected tab as a path segment in the url - comprehensive Cypress tests covering edge cases - getting rid of the back button `< Rules` on the rule details page ## Edge cases Since parameters in the URL and the session storage can be modified by users it can lead to unexpected results or security risks. What have been tested and covered so far: - arbitrary modification of the serialized state which leads to deserialization error (default parameters are used in this case and the state is rewritten with the default parameters) - filter parameters modification (doesn't cause errors) - page number modification (isn't not handled in a special way, `EuiBasicTable` display either first of the last page if the value exceeds the limits) - page size (`EuiBasicTable` loads more records which isn't limited and can cause a performance issue, it **has been addressed** through validation) - sorting parameters modification (`EuiBasicTable` ignores wrong values) The observation result is that `EuiBasicTable` gracefully handles the wrong values . ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
…147218) Addresses: #140263 This PR was inspired by #146649 and while working on persistent rules table state #145111. ## Summary It includes improvements for url search parameters manipulation functionality. In particular `useGetInitialUrlParamValue` and `useReplaceUrlParams` hooks. The main idea is to isolate the encoding layer ([rison](https://github.com/Nanonid/rison)) as an implementation detail so `useGetInitialUrlParamValue` and `useReplaceUrlParams` consumers can just provide types they wish and the hooks serialize/desirealize the data into appropriate format under the hood. On top of that after `@kbn/rison` was added in #146649 it's possible to use this package directly to encode and decode parameters whenever necessary. The improvements include - store unserialized url parameters state in the redux store - encode and decode data by using functions from `@kbn/rison` directly - let `useReplaceUrlParams` accept an updater object ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Addresses: #140263
Summary
It implements rules table state persistence. Reopening or reloading of the page loads the same state as well as navigation from another page inside or outside the security plugin.
Screen.Recording.2022-11-15.at.18.13.17.mov
Details
The changes persist the rules table state in the url and the session storage to be able to recover after navigation from another page. The following parameters are persisted
Page number is only persisted in the url. Avoiding persistence a page number in the session storage make the UX more predictable that users upon returning to the page expect the first page to be selected.
Selection state is not persisted since it can lead to URL overflow problem. According to the different resources for example this one the maximum length should not exceed 2KB though Chrome supports URLs up to 2MB.
Besides that this PR adds
What is not done and will be addressed in the next PRs
< Rules
on the rule details pageEdge cases
Since parameters in the URL and the session storage can be modified by users it can lead to unexpected results or security risks.
What have been tested and covered so far:
EuiBasicTable
display either first of the last page if the value exceeds the limits)EuiBasicTable
loads more records which isn't limited and can cause a performance issue, it has been addressed through validation)EuiBasicTable
ignores wrong values)The observation result is that
EuiBasicTable
gracefully handles the wrong values .Checklist