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] Bulk editing rule custom highlighted fields #179312

Merged

Conversation

e40pud
Copy link
Contributor

@e40pud e40pud commented Mar 24, 2024

Resolves: #164301
Resolves: https://github.com/elastic/security-team/issues/8958

Summary

With these changes we introduce a new feature - Bulk custom highlighted fields update. It works similarly to bulk tags and indices update.

Here is the overview of the work that has been done:

Screen.Recording.2024-04-15.at.14.17.08.mov

Checklist

Delete any items that are not applicable to this PR.

@e40pud e40pud added release_note:enhancement Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Engine Security Solution Detection Engine Area labels Mar 24, 2024
@e40pud e40pud self-assigned this Mar 24, 2024
@e40pud
Copy link
Contributor Author

e40pud commented Mar 24, 2024

/ci

@e40pud
Copy link
Contributor Author

e40pud commented Mar 27, 2024

@elasticmachine merge upstream

@e40pud e40pud changed the title [Security Solution] Add custom highlighted fields through the bulk edit feature (#164301) [Security Solution][On Week] Add custom highlighted fields through the bulk edit feature (#164301) Apr 2, 2024
@e40pud
Copy link
Contributor Author

e40pud commented Apr 2, 2024

@elasticmachine merge upstream

@e40pud
Copy link
Contributor Author

e40pud commented Apr 2, 2024

/ci

@e40pud
Copy link
Contributor Author

e40pud commented Apr 4, 2024

@elasticmachine merge upstream

@e40pud
Copy link
Contributor Author

e40pud commented Apr 5, 2024

@elasticmachine merge upstream

@e40pud
Copy link
Contributor Author

e40pud commented Apr 8, 2024

@elasticmachine merge upstream

@e40pud
Copy link
Contributor Author

e40pud commented Apr 10, 2024

@elasticmachine merge upstream

@e40pud
Copy link
Contributor Author

e40pud commented Apr 11, 2024

@elasticmachine merge upstream

@e40pud
Copy link
Contributor Author

e40pud commented Apr 12, 2024

@elasticmachine merge upstream

@e40pud
Copy link
Contributor Author

e40pud commented Apr 15, 2024

@elasticmachine merge upstream

@e40pud e40pud requested review from a team as code owners April 25, 2024 14:14
@e40pud e40pud requested a review from dhurley14 April 25, 2024 14:14
Copy link
Contributor

@dplumlee dplumlee left a comment

Choose a reason for hiding this comment

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

Left a couple questions and one nit but overall looks good @e40pud! I pulled down and tested all the edge cases I could think of. This is the first time I've seen the feature flag stuff used so heavily for the backend code, I think it's a pretty good way to go about it albeit adding a bit of complexity to the implementation as (correct me if I'm wrong) we aren't able to enable/disable routes themselves using the flags.

@e40pud
Copy link
Contributor Author

e40pud commented Apr 29, 2024

Left a couple questions and one nit but overall looks good @e40pud! I pulled down and tested all the edge cases I could think of. This is the first time I've seen the feature flag stuff used so heavily for the backend code, I think it's a pretty good way to go about it albeit adding a bit of complexity to the implementation as (correct me if I'm wrong) we aren't able to enable/disable routes themselves using the flags.

Yes, I had to add extra complexity in order to be able to block API behind feature flag. I think we can benefit from ti in future with other features that require adding public API and needs to be hidden for some time.

const rules = fetchRulesOutcome.results.map(({ result }) => result);
const indexPatterns: string[] = [];
const dataViewIds: string[] = [];
rules.forEach((rule) => {
Copy link
Contributor

@vitaliidm vitaliidm Apr 29, 2024

Choose a reason for hiding this comment

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

@e40pud
I only checked ES|QL rules since they do not have index.

Index for this rules is extracted from rule query
Without extracting index, it will display empty highlighted fields combobox.

Another case is custom ES|QL fields. They can be created in query, but I don't think it's feasible for bulk edit(since every query needs to be performed and custom fields identified).
So, we probably just should mention in docs, custom ES|QL fields are not supported.
Which would make bulk editing rules with aggregating query not working properly. As these rule have a small number of fields available.

More details on ES|QL highlighted fields can be found here: #177746

Screenshot 2024-04-29 at 15 04 24

Copy link
Contributor

Choose a reason for hiding this comment

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

Similar behaviour also applicable to ML rules.
Index for this rule type is extracted from ML jobs, as this rule type does not have index or data view id

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 pointing out to this one! We discussed performance and limitation issues and decided to go with this solution

Copy link
Contributor

@dhurley14 dhurley14 left a comment

Choose a reason for hiding this comment

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

Overall looks great! Appreciate the updates to the tests and additional tests too. A few small nits too.

I do believe we could simplify the code and have some performance improvements if we introduce the logic for fetching and gathering the data view titles into the bulk_get_sources route, update the hook useBulkGetRulesSources to reflect the new server-side functionality, and remove the useGetAllIndexPatternsFromSources. This would also have the added benefit of reducing the number of hooks we need to maintain and test.

Comment on lines +121 to +123
const fieldOptions = indexPatterns.fields.map((field) => ({
label: field.name,
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

Seeing as we are pulling every field (runtime included) from every index pattern for every rule in the rules table, this could be a lot of fields. Not sure what the limitations are on rendering all these fields but would be neat to see where the rendering starts to slow down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will show fields from the index patterns defined in Security Solution advanced settings instead

@e40pud
Copy link
Contributor Author

e40pud commented May 2, 2024

Overall looks great! Appreciate the updates to the tests and additional tests too. A few small nits too.

I do believe we could simplify the code and have some performance improvements if we introduce the logic for fetching and gathering the data view titles into the bulk_get_sources route, update the hook useBulkGetRulesSources to reflect the new server-side functionality, and remove the useGetAllIndexPatternsFromSources. This would also have the added benefit of reducing the number of hooks we need to maintain and test.

Hey @dhurley14, we discussed potential performance issue and limitations with ES|QL and ML rules.

To avoid those issues, we decided to go with the next solution for the list of fields available in "custom highlighted fields" flyout: the dropdown will include fields from the index patterns defined in Security Solution advanced settings (more details here).

This means, I will remove the route to fetch all indices for selected rules.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 5466 5467 +1

Async chunks

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

id before after diff
securitySolution 13.7MB 13.7MB +18.1KB

Page load bundle

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

id before after diff
securitySolution 83.1KB 83.3KB +268.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 518 519 +1

Total ESLint disabled count

id before after diff
securitySolution 596 597 +1

History

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

cc @e40pud

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 enhancement New value added to drive a business result Feature:Rule Management Security Solution Detection Rule Management area release_note:feature Makes this part of the condensed release notes Team:Detection Engine Security Solution Detection Engine Area Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution] Add custom highlighted fields through the bulk edit feature
9 participants