[9.1] [Security Solution] Two-way prebuilt rule diff (#233045)#234707
Merged
kibanamachine merged 1 commit intoelastic:9.1from Sep 11, 2025
Merged
[9.1] [Security Solution] Two-way prebuilt rule diff (#233045)#234707kibanamachine merged 1 commit intoelastic:9.1from
kibanamachine merged 1 commit intoelastic:9.1from
Conversation
**Partially addresses:** elastic/security-team#12507 (internal) ## Summary Adds a 2-way diff comparison algorithm to the codebase and shifts the existing diff code to a "three-way" naming scheme. In order for the telemetry work described in elastic#230856 to occur, we need to refactor our diff calculation method to return rule schema fields instead of the `DiffableRule` schema that we currently return. This required a lot of exploratory work to determine the best method in which to accomplish this refactor, as the core function, `calculateRuleDiffFields`, is used as a core piece of logic in all our prebuilt rule customization related endpoints, and most of our UI components are reliant on this `DiffableRule` based return structure. I settled on an approach that adds a separate 2-way diff function that never converts the rule into the diffable rule structure, allowing us to directly compare the rule objects and return exact rule schema fields. This also involved refactoring the normalization process we did in `convertToDiffable` and extracting out the comparison functions we used in the diff algorithms, so that both diff algorithms would be returning identical "is_customized" calculations given a set of `RuleResponse` objects. This PR adds a comprehensive set of tests that verify the synchronization of these two diff algorithms for ease of maintainability and to greatly lessen the possibility of divergence. This PR also swaps out the `is_customized` rule source calculation with the new 2-way diff calculation, all tests are running (and passing) with this new diff calculation. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] [FTR tests run](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9301) - [x] [Cypress tests run](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9302) --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit b08abf7)
5 tasks
Contributor
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Saved Objects .kibana field count
cc @dplumlee |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto9.1:Questions ?
Please refer to the Backport tool documentation