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] Add a rule management filters internal endpoint #146826

Merged
merged 37 commits into from
Dec 20, 2022

Conversation

maximpn
Copy link
Contributor

@maximpn maximpn commented Dec 1, 2022

Addresses: #137428

Summary

Adds a new internal lightweight endpoint to fetch rules related information like the number of installed prebuilt rules, the number of custom rules and etc.

Details

This PR adds a quite simple and lightweight endpoint for fetching rules related information which is

  • the number of installed prebuilt rules
  • the number of custom rules
  • tags

UI has been updated accordingly. The result of the endpoint are mostly used in the rules table filter but not limited to.

The added endpoint doesn't implement full aggregation for fetching rule numbers so it's planned to be done in the following PR.

Comparison

The following screenshots from the browser's network tab demonstrate that the new endpoint is faster which is good since it's intended to be updated executed relatively often whenever the rules are updated.

Prebuilt rules endpoint which was used for fetching rules related information
Screenshot 2022-12-04 at 21 50 50

The new endpoint
image

Checklist

@maximpn maximpn added performance technical debt Improvement of the software architecture and operational architecture Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Feature:Rule Management Security Solution Detection Rule Management area Team:Detection Rule Management Security Detection Rule Management Team v8.7.0 labels Dec 1, 2022
@maximpn maximpn self-assigned this Dec 1, 2022
@maximpn maximpn force-pushed the add-rule-filters-endpoint branch from 7118ec5 to 9c32857 Compare December 3, 2022 22:05
@maximpn maximpn marked this pull request as ready for review December 4, 2022 21:00
@maximpn maximpn requested review from a team as code owners December 4, 2022 21:00
@maximpn maximpn requested a review from banderror December 4, 2022 21:00
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

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

@xcrzx xcrzx requested review from xcrzx and removed request for banderror December 5, 2022 08:56
@maximpn maximpn force-pushed the add-rule-filters-endpoint branch from 704a22a to 98740a4 Compare December 5, 2022 13:15
@maximpn maximpn added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting labels Dec 5, 2022
Copy link
Contributor

@xcrzx xcrzx left a comment

Choose a reason for hiding this comment

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

Awesome work, thank you, @maximpn 🙌 We're finally moving away from aggregating all rule tags in memory 🎉

I looked through the code and left some initial comments. And I'm going to check out the PR and test it locally later this week.

@maximpn maximpn force-pushed the add-rule-filters-endpoint branch from 98740a4 to 4127eb7 Compare December 5, 2022 17:54
@maximpn maximpn requested a review from xcrzx December 6, 2022 14:39
@maximpn maximpn force-pushed the add-rule-filters-endpoint branch from 9e096e8 to 4093f5c Compare December 6, 2022 19:06
Copy link
Contributor

@xcrzx xcrzx left a comment

Choose a reason for hiding this comment

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

I checked out and tested this PR locally. The new endpoint seems to be working as expected; the rules table filters reflect changes in rules properly. The new endpoint works perceivably faster.

I left some minor suggestions, but overall, the implementation looks good to me 👍

@maximpn maximpn force-pushed the add-rule-filters-endpoint branch from 9ebc153 to 4dcc047 Compare December 8, 2022 10:33
@maximpn
Copy link
Contributor Author

maximpn commented Dec 12, 2022

@elasticmachine merge upstream

@maximpn maximpn requested a review from xcrzx December 12, 2022 09:43
@maximpn maximpn force-pushed the add-rule-filters-endpoint branch from 8d4c693 to 9755803 Compare December 17, 2022 08:17
@maximpn
Copy link
Contributor Author

maximpn commented Dec 17, 2022

@elasticmachine merge upstream

@maximpn
Copy link
Contributor Author

maximpn commented Dec 18, 2022

@pmuellr I've added unit and functional tests to cover the tags limit. To be honest I think 50 tags is quite low limit since the number of tags can easily be higher. To address this and the other issues there is a task I'm working on in parallel which will allow to optimize the aggregate method to use with arbitrary aggregations.

@maximpn maximpn requested a review from pmuellr December 18, 2022 08:49
Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

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

LGTM, thx for the changes!

@maximpn
Copy link
Contributor Author

maximpn commented Dec 19, 2022

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #2 / Import rules Imports a custom rule with exceptions

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 3391 3392 +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 12.6MB 12.6MB +783.0B

Page load bundle

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

id before after diff
securitySolution 51.0KB 50.9KB -68.0B
Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 61 67 +6
osquery 109 115 +6
securitySolution 439 445 +6
total +20

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 70 76 +6
osquery 110 117 +7
securitySolution 516 522 +6
total +21

History

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

cc @maximpn

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:Rule Management Security Solution Detection Rule Management area performance release_note:skip Skip the PR/issue when compiling release notes 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. technical debt Improvement of the software architecture and operational architecture v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution] Introduce an endpoint to use for the detection rules table filters/data
6 participants