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

[SecuritySolutions] Update CellActions to support all types used by Discover #160524

Merged
merged 10 commits into from
Jun 30, 2023

Conversation

machadoum
Copy link
Member

@machadoum machadoum commented Jun 26, 2023

Original issue: #144943

Summary

  • Update CellActions value to be Serializable.
  • Update Default Actions and SecuritySolution Actions to allowlist the supported Kibana types.
  • Add an extra check to Action's execute to ensure the field value is compatible.

How to test it?

  • Open Discover and create a saved search with many different field types
  • Go to Security Solutions dashboards
  • Create a new dashboard and import the saved search
  • Test the created dashboard inside Security Solutions

Checklist

@machadoum machadoum force-pushed the cell-actions-phase-2 branch from 396b129 to 31c4e8b Compare June 26, 2023 14:09
@machadoum machadoum self-assigned this Jun 26, 2023
@machadoum machadoum added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore v8.10.0 labels Jun 26, 2023
@machadoum machadoum force-pushed the cell-actions-phase-2 branch from 21c3f89 to 2e58c2a Compare June 27, 2023 09:19
@machadoum
Copy link
Member Author

@elasticmachine merge upstream

@machadoum machadoum force-pushed the cell-actions-phase-2 branch from 9e00969 to 7b3412a Compare June 27, 2023 12:52
@machadoum machadoum changed the title Cell actions phase 2 [SecuritySolutions] Update CellActions to support all types used by Discover Jun 27, 2023
@machadoum machadoum force-pushed the cell-actions-phase-2 branch from a34886f to 8f0c76d Compare June 27, 2023 13:04
@machadoum machadoum marked this pull request as ready for review June 27, 2023 13:07
@machadoum machadoum requested review from a team as code owners June 27, 2023 13:07
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@machadoum
Copy link
Member Author

@elasticmachine merge upstream

@machadoum machadoum added the Feature:Cell Actions Security Solution Cell Actions feature label Jun 27, 2023
@machadoum machadoum requested a review from a team as a code owner June 28, 2023 11:59
@machadoum machadoum force-pushed the cell-actions-phase-2 branch from f5f0ddf to 3b359fe Compare June 29, 2023 09:23
@machadoum
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Contributor

@semd semd left a comment

Choose a reason for hiding this comment

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

Awesome! This is not a very rewarding job, but this standarization was very necessary. It will open the cell-actions framework to support any use case.
Thanks Pablo! 👏

): value is string | number | boolean => isString(value) || isNumber(value) || isBoolean(value);

const isNonMixedTypeArray = (
value: Array<string | number | boolean>
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT:

Suggested change
value: Array<string | number | boolean>
value: SerializableArray

?

Copy link
Member Author

@machadoum machadoum Jun 30, 2023

Choose a reason for hiding this comment

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

This function only receives Array<string | number | boolean> because we call it after filtering out other values. We could use a more generic type like SerializableArray but the extra types won't be used. Also, If we receive a SerializableArray the type guard would have to be expanded to tring[] | number[] | boolean[] | null[] | undefined[] | SerializableArray | SerializableRecord[] . I am not sure if it is worth it.

Comment on lines 34 to 37
export const isValueSupportedByDefaultActions = (
value: NonNullableSerializable[]
): value is DefaultActionsSupportedValue =>
value.every(isNonNullablePrimitiveValue) && isNonMixedTypeArray(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the value.every(isNonNullablePrimitiveValue) needed? The value parameter is already NonNullableSerializable[]?

Copy link
Member Author

Choose a reason for hiding this comment

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

isNonNullablePrimitiveValue is required to drop non-primitive values like SerializableArray and SerializableRecord.
The confusion is due to the bad naming. isNonNullablePrimitiveValue checks if the value is string, number, or boolean, which are primitive and not nullable. I will inline the function to avoid naming it. 😆

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.

Great job on these changes! This is a big improvement for cell actions and makes it applicable to a much wider range of use cases 🙌

I tested locally with a custom Security dashboard including less common scenarios like no timestamp, flattened fields, and field conflicts, and everything seemed to work as expected. LGTM 👍

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 596 597 +1
securitySolution 4233 4235 +2
total +3

Async chunks

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

id before after diff
discover 530.2KB 530.4KB +277.0B
securitySolution 11.0MB 11.0MB +4.1KB
total +4.4KB

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/cell-actions 2 3 +1
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
securitySolution 413 417 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
securitySolution 492 496 +4
total +6

History

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

cc @machadoum

Copy link
Contributor

@lgestc lgestc left a comment

Choose a reason for hiding this comment

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

lgtm

@machadoum machadoum merged commit 360c4c3 into elastic:main Jun 30, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 30, 2023
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 Feature:Cell Actions Security Solution Cell Actions feature release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore Team:Threat Hunting Security Solution Threat Hunting Team v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants