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] One Discover - Enable Security Solution Expandable Flyout in One Discover entities #189633

Merged
merged 42 commits into from
Aug 27, 2024

Conversation

logeekal
Copy link
Contributor

@logeekal logeekal commented Jul 31, 2024

Note

This Change is only applicable to Serverless Security Solution as of now. In follow-up PRs, support will be added to ESS as well based data-sources such as index or intergrations.

Summary

Resolves #189151

This PR is foundation for the work described in #186783. This just enables expandable flyout for entity details, which is currently only used in security solution, in discover as well.

As a part of One Discover work, we need to make sure that cell rendering in Discover should behave exactly like it does in security solution.

To enable this, a new shared-browser package @kbn/security-solution-common in x-pack/packages/security-solution has been created which can used to share components between security solution and discover. Below is the usage pattern

flowchart TD
    disc-utils[@kbn/discover-utils] --> sscommon
    sscommon[@kbn/security-solution-common] --> ssplugin[security_solution]
    sscommon[@kbn/security-solution-common] --> discover[discover]
    disc-utils[@kbn/discover-utils] --> discover
Loading

Desk Testing Guide.

  1. Enable Security profile in serverless by adding below to kibana.yml
discover.experimental.enabledProfiles: ['security-root-profile']
  1. Load Some data

  2. Navigate to discover and add host.name as one of the column.

  3. Should open an expandable flyout as shown below.

discover_flyout.mp4

Code Review Guide

Most of the changes in the PR are code-organization. There are NO changes in security solution but only the changes to import statements.

You can focus regarding the changes in below packages:

  • x-pack/packages/security-solution/common
  • packages/kbn-discover-utils
  • packages/kbn-expandable-flyout

@logeekal logeekal changed the title One discover/cell renderer [Security Solution] One Discover - Enable Security Solution Expandable Flyout in One Discover entities Aug 1, 2024
@logeekal
Copy link
Contributor Author

logeekal commented Aug 1, 2024

/ci

@logeekal logeekal self-assigned this Aug 1, 2024
@logeekal logeekal added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Investigations Team v8.16.0 Project:OneDiscover Enrich Discover with contextual awareness / Merge with Logs Explorer and removed Project:OneDiscover Enrich Discover with contextual awareness / Merge with Logs Explorer labels Aug 1, 2024
@logeekal logeekal marked this pull request as ready for review August 1, 2024 12:37
@logeekal logeekal requested review from a team as code owners August 1, 2024 12:37
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

@logeekal logeekal requested a review from a team as a code owner August 7, 2024 13:15
Copy link
Contributor

@tomsonpl tomsonpl left a comment

Choose a reason for hiding this comment

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

Defend Workflows code review LGTM 👍
Thanks!

Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

GenAI team code changes LGTM

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Thanks for getting things started on the Discover Security profile! The Data Discovery changes look great, just one comment to address about making sure the profile isn't enabled by Default in Discover yet, then it'll be good to approve on my end.

One request is that when we make the switch to actually enable the Security profile by default, we should have sufficient unit and functional tests in place for the profile, but I don't see that as necessary for this PR since it's still experimental for now.

@@ -88,7 +89,7 @@ const extractProfileIds = (providers: Array<BaseProfileProvider<{}>>) =>
providers.map(({ profileId }) => profileId);

const createRootProfileProviders = (_providerServices: ProfileProviderServices) =>
[] as RootProfileProvider[];
[createSecurityRootProfileProvider(_providerServices)] as RootProfileProvider[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding createSecurityRootProfileProvider here means it will be enabled by default in Discover instead of using discover.experimental.enabledProfiles: ['security-root-profile']. I would recommend creating a separate createExperimentalRootProfileProviders function or similar to register this for now, but not adding the IDs to enabledProfileIds by default.

Copy link
Contributor Author

@logeekal logeekal Aug 23, 2024

Choose a reason for hiding this comment

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

@davismcphee , do you think it make sense, if I add isEnabled flag to profiles.

This way, experimental profiles will always have isEnabled as No and it can be overidden by discover.experimental.enabledProfiles.

Additionally, with that we do not have to maintain seperate enabledProfiles

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 have add the proposed solution here : 91a699c. See if this makes sense as it takes the responisbility of enabling profile providers outside of register_profile_services and profile providers can decide if profile should be enabled or not.

If not, i will be happy to revert.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I like this approach better! My only suggestion is rather than using an isEnabled flag that every profile needs to add, what if we go with something like an optional isExperimental flag to explicitly mark only the experimental profiles?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Works for me. Done changes here: 0739ef2.

Copy link
Contributor

Choose a reason for hiding this comment

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

Creating a security subfolder for security-specific profiles seems like a good pattern to me, and we can do similar for other solutions 👍 Do you think we should update CODEOWNERS to specify both Data Discovery and Security as owners of src/plugins/discover/public/context_awareness/profile_providers/security so both teams get pinged on PRs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added here: e7ed9df.

I have also added the code ownership of packages/kbn-unified-data-table to @elastic/security-threat-hunting-investigations so that we are aware of the changes done to the table.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thanks. And we open a lot of PRs that touch Unified Data Table, but I think it should be fine to add so you can be aware of changes and have a chance to raise concerns if they affect your usage. Unfortunately it looks like CI reverted the CODEOWNERS changes: bff6cec. I think we may need to update packages/kbn-unified-data-table/kibana.jsonc for Unified Data Table and add the override for the security subfolder below the autogenerated section of CODEOWNERS with the other Data Discovery ones.

Copy link
Contributor Author

@logeekal logeekal Aug 26, 2024

Choose a reason for hiding this comment

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

And we open a lot of PRs that touch Unified Data Table, but I think it should be fine to add so you can be aware of changes

Exactly, we are trying to add as many tests so that we are aware of the changes but it is easy to miss. And as you mentioned the speed of dev is very high, for some time we would like to be apprised for changes going in.

I think we may need to update packages/kbn-unified-data-table/kibana.jsonc for Unified Data Table and add the override for the security subfolder below the autogenerated section of CODEOWNERS with the other Data Discovery ones.

Yes, TIL about this. Done here 7ed0376

@logeekal
Copy link
Contributor Author

One request is that when we make the switch to actually enable the Security profile by default, we should have sufficient unit and functional tests in place for the profile, but I don't see that as necessary for this PR since it's still experimental for now.

@davismcphee. I 100% agree with this statement. So far I have tried to cover the current partial code with unit tests.. Functional test will come when Flyout is fully implemented.

If you think unit test are missing, feel free to point out.

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

The latest changes look good! Just a bit of minor feedback and looks like there's a few test failures to look into, but otherwise looks good on my end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thanks. And we open a lot of PRs that touch Unified Data Table, but I think it should be fine to add so you can be aware of changes and have a chance to raise concerns if they affect your usage. Unfortunately it looks like CI reverted the CODEOWNERS changes: bff6cec. I think we may need to update packages/kbn-unified-data-table/kibana.jsonc for Unified Data Table and add the override for the security subfolder below the autogenerated section of CODEOWNERS with the other Data Discovery ones.

Comment on lines 43 to 53
const enabledRootProfileProviders = rootProfileProviders.filter(
({ isEnabled = true, profileId }) => isEnabled || experimentalProfileIds.includes(profileId)
);

const enabledDataSourceProfileProviders = dataSourceProfileProviders.filter(
({ isEnabled = true, profileId }) => isEnabled || experimentalProfileIds.includes(profileId)
);

const enabledDocumentProfileProviders = documentProfileProviders.filter(
({ isEnabled = true, profileId }) => isEnabled || experimentalProfileIds.includes(profileId)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could add this filtering logic directly to registerProfileProvidersInternal instead and pass down experimentalProfileIds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done here: 0739ef2

});
const context = await rootProfileServiceMock.resolve({ solutionNavId: null });
expect(rootProfileServiceMock.getProfile(context)).toBe(rootProfileProviderMock.profile);
});

it('should not register disabled profile providers', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we move the filtering logic to registerProfileProvidersInternal, we should be able to restore an updated version of this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in the same commit as mentioned above.

[
exampleRootProfileProvider,
createSecurityRootProfileProvider(_providerServices),
] as RootProfileProvider[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
] as RootProfileProvider[];
];

Nit: I think we can drop the cast now that we have entries in the array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 . Great catch. Done in the same commit as above.

@@ -88,7 +89,7 @@ const extractProfileIds = (providers: Array<BaseProfileProvider<{}>>) =>
providers.map(({ profileId }) => profileId);

const createRootProfileProviders = (_providerServices: ProfileProviderServices) =>
[] as RootProfileProvider[];
[createSecurityRootProfileProvider(_providerServices)] as RootProfileProvider[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I like this approach better! My only suggestion is rather than using an isEnabled flag that every profile needs to add, what if we go with something like an optional isExperimental flag to explicitly mark only the experimental profiles?

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
canvas 1287 1288 +1
cloudSecurityPosture 703 704 +1
discover 985 1029 +44
esqlDataGrid 417 418 +1
eventAnnotationListing 641 642 +1
lens 1504 1505 +1
logsExplorer 617 618 +1
observability 1116 1117 +1
securitySolution 5677 5691 +14
slo 898 899 +1
unifiedDocViewer 281 282 +1
total +67

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/discover-utils 106 109 +3
@kbn/expandable-flyout 14 17 +3
@kbn/security-solution-common - 38 +38
total +44

Async chunks

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

id before after diff
discover 843.6KB 855.8KB +12.2KB
securitySolution 18.0MB 18.0MB -3.1KB
total +9.1KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/expandable-flyout 1 2 +1
@kbn/security-solution-common - 5 +5
total +6

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
discover 47.7KB 47.9KB +171.0B
Unknown metric groups

API count

id before after diff
@kbn/discover-utils 133 136 +3
@kbn/expandable-flyout 39 42 +3
@kbn/security-solution-common - 59 +59
total +65

History

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

cc @logeekal

@logeekal logeekal removed the request for review from jaredburgettelastic August 26, 2024 15:32
Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Data Discovery changes LGTM 👍 Thanks for helping improve profile registration!

@logeekal logeekal merged commit 9293bc1 into elastic:main Aug 27, 2024
42 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Investigations Team v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution] Implement Expandable Flyout in One Discover Cell Renderer Extension