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

[Security Solution][Investigations] - Fix column toggle #158780

Closed
wants to merge 3 commits into from

Conversation

michaelolo24
Copy link
Contributor

@michaelolo24 michaelolo24 commented May 31, 2023

Summary

Addresses #155243

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@michaelolo24 michaelolo24 added bug Fixes for quality problems that affect the customer experience release_note:fix Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Investigations Security Solution Investigations Team v8.9.0 v8.8.1 labels May 31, 2023
@michaelolo24 michaelolo24 marked this pull request as ready for review May 31, 2023 21:16
@michaelolo24 michaelolo24 requested review from a team as code owners May 31, 2023 21:16
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@michaelolo24
Copy link
Contributor Author

Still need to add tests, but thoughts on the changes here @XavierM and @logeekal ?

// get the latest columns provided by client and
if (didDefaultColumnChange) {
defaultColumnsRef.current = defaultColumns;
setColumnsPopulated(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like that this useEffect was moved below with some modification.

Actually removing this line would cause below line to not execute which enriches fields with its datatype. With new change, the ordering of fields such as timestamp breaks. See video below

const populatedColumns = populateColumns(columns, browserFields, defaultColumns);
Screen.Recording.2023-06-01.at.11.08.58.mov

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I understand the problem and it seems to be 2 pronged.

  1. Trigger Actions alert table does natively supported changing columns from the client side. So I added a work around, that we will provide a unique set of columns per ID and that is how we achieve columns difference between Event Rendered View v/s Grid View.

    • Now here, for a single ID ( i.e. gridView ) we are changing the columns for grid View from the client side (i.e. security solution ) which is causing weird issues even if I add above line : setColumnsPopulated(false)
  2. Secondly, single source of truth on the storage is maintained by Triggers action alert table. Changing security solution columns state does will not have impact because if we add a field from field browser, it will only change trigger-actions state of columns not security solution columns state. Currently, there is no sync.

Currently, only safe way seems to me is to get handle onToggleColumn function, create a context in Security Solution and then use that toggle function anywhere to add columns to the table. This is because trigger actions table wants to handle how the columns are changed in the table.

Please let me know if something does not make sense.. we can have a meeting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the write up, it does make sense. Took a second pass at it if you have some time!

@michaelolo24 michaelolo24 marked this pull request as draft June 1, 2023 13:36
const oldColumnIds = defaultColumnsRef.current.map((column) => column.id);
const addedColumnIds = difference(newColumnIds, oldColumnIds);
const removedColumnIds = difference(oldColumnIds, newColumnIds);
return addedColumnIds.concat(removedColumnIds);
Copy link
Contributor

Choose a reason for hiding this comment

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

Although, this seems a little hacky, I do not see any other good alternative without making Contexts in Security Solution. It seems to be working well for me. It will good to add cypress tests for this.

@@ -210,9 +210,10 @@ export const AlertsTableComponent: FC<DetectionEngineAlertTableProps> = ({
return undefined;
}, [isEventRenderedView]);

const dataTableStorage = getDataTablesInStorageByIds(storage, [TableId.alertsOnAlertsPage]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@logeekal this may be a much much more involved change from what I'm seeing. From what I can tell only pulling in the initial columns like this is necessary for the table to properly own control to set the columns, but haven't dug into exactly what the table is doing under the hood to manage these changes. My changes here break the tests, because the expected table updates on load aren't happening properly on the Rule details page, even though the tableId should account for the table settings for that table. Returning this to how it was previously fixes the tests, but, since localStorage updates aren't listened to, the security_solution column toggle functionality doesn't work. Also fyi @kqualters-elastic .

...I may be missing something, but wanted to drop details about what I'm seeing just in case I have to start my leave early next week

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @michaelolo24, I am not sure I fully understand but I tested it in rule details page and it seems to be working fine. I see that you have removed the hard coding of TableId.alertsOnAlertsPage , which is great. Could you please point me to exact scenarios that fail.

@kibana-ci
Copy link
Collaborator

kibana-ci commented Jun 6, 2023

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #2 / Enrichment Custom query rule Should has enrichment fields
  • [job] [logs] Security Solution Tests #2 / Enrichment Custom query rule Should has enrichment fields

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 9.4MB 9.4MB -76.0B
triggersActionsUi 1.4MB 1.4MB +140.0B
total +64.0B

History

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

@michaelolo24 michaelolo24 removed the bug Fixes for quality problems that affect the customer experience label Jun 6, 2023
@michaelolo24
Copy link
Contributor Author

Closing as this issue was completed in a separate PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:fix Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Investigations Security Solution Investigations Team v8.8.1 v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants