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

[Rule Management] Move calculation of rule source outside of applyRuleUpdate #199720

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rylnd
Copy link
Contributor

@rylnd rylnd commented Nov 11, 2024

Summary

This is a small performance improvement that came out of this discussion on a previous PR. Note that the code in question is behind a feature flag (prebuiltRulesCustomizationEnabled). This issue relates to the Prebuilt Rule Import work, and its associated benchmarking effort.

Context

With the current implementation, there are instances where we call applyRuleUpdate but do not want/need it to calculate rule source (e.g. when called from importRules, which pre-calculates the rule_source for incoming rules before passing them to importRule.

Instead of adding a flag to conditionally call calculateRuleSource from within applyRuleUpdate I've opted to separate the two functions as these seem to be logically distinct actions.

The three existing calls to applyRuleUpdate have been updated to be functionally equivalent.

Effect

The effect of this PR is that we will no longer unnecessarily call fetchAssetsByVersion for each individual rule being imported, which should improve performance of rule import.

For maintainers

With the current implementation, there are instances where we call
`applyRuleUpdate` but do not want/need it to calculate rule source (e.g.
when called from `importRules`, which pre-calculates the rule_source for
incoming rules before passing them to `importRule`.

Instead of adding a flag to conditionally call `calculateRuleSource`
from within `applyRuleUpdate` I've opted to separate the two functions
as these seem to be logically distinct actions.

The three existing calls to `applyRuleUpdate` have been updated to be
functionally equivalent.

The effect of this PR is that we will no longer unnecessarily call
`fetchAssetsByVersion` for each individual rule being imported, which
should improve performance of rule import.
@rylnd rylnd self-assigned this Nov 11, 2024
@rylnd rylnd added the release_note:skip Skip the PR/issue when compiling release notes label Nov 11, 2024
@rylnd
Copy link
Contributor Author

rylnd commented Nov 11, 2024

/ci

@rylnd rylnd added Team:Detection Rule Management Security Detection Rule Management Team Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules Feature:Rule Import/Export Security Solution Rule Import & Export labels Nov 12, 2024
@rylnd rylnd marked this pull request as ready for review November 12, 2024 20:40
@rylnd rylnd requested a review from a team as a code owner November 12, 2024 20:40
@rylnd rylnd requested a review from jkelas November 12, 2024 20:40
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management)

@rylnd rylnd added the backport:skip This commit does not require backporting label Nov 12, 2024
@banderror banderror requested review from xcrzx and removed request for jkelas November 12, 2024 21:02
@banderror banderror added v9.0.0 backport:version Backport to applied version labels v8.17.0 and removed backport:skip This commit does not require backporting 8.17 candidate labels Nov 12, 2024
@banderror banderror self-requested a review November 13, 2024 14:47
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @rylnd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules Feature:Rule Import/Export Security Solution Rule Import & Export release_note:skip Skip the PR/issue when compiling release notes Team:Detection Rule Management Security Detection Rule Management Team v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants