[Security Solution] Extend the /upgrade/_review endpoint contract and functionality#187770
[Security Solution] Extend the /upgrade/_review endpoint contract and functionality#187770jpdjere merged 38 commits intoelastic:mainfrom
/upgrade/_review endpoint contract and functionality#187770Conversation
|
/ci |
2 similar comments
|
/ci |
|
/ci |
b83a88c to
7654ea7
Compare
|
/ci |
|
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
|
Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management) |
There was a problem hiding this comment.
Should this be something like NO_CONFLICT? I guess NO makes sense in the conflict: no assignment but it does look a bit weird standalone
There was a problem hiding this comment.
Updated the enum for clarity
|
@banderror @nikitaindik @dplumlee Thanks for the review. I've addressed your feedback, and included in the changes of this PR the handling of scenarios with a missing base version, with the "compromise" solution we had decided here. Please take a look when you can. |
nikitaindik
left a comment
There was a problem hiding this comment.
Thanks for the updates to PR @jpdjere! I have only reviewed changes related to MissingVersion - they look good to me!
There was a problem hiding this comment.
The new changes look great to me @jpdjere, thanks for incorporating all this into the existing diff work! I do like the idea you mentioned here, not sure if there's a reason we didn't incorporate this before other than not really having any special logic needs for those cases with the initial implementation
| expect(result).toEqual( | ||
| expect.objectContaining({ | ||
| has_base_version: false, | ||
| base_version: undefined, |
| case ThreeWayDiffOutcome.StockValueNoUpdate: // Scenarios AAA and -AA | ||
| case ThreeWayDiffOutcome.CustomizedValueNoUpdate: // Scenario ABA | ||
| case ThreeWayDiffOutcome.CustomizedValueSameUpdate: // Scenario ABB |
There was a problem hiding this comment.
Nice idea to put these scenarios in here, I think I'll incorporate this into some other diff files as well
There was a problem hiding this comment.
@dplumlee I ended up removing these, since now each scenario has its own ThreeWayDiffOutcome and there's no case like // Scenarios AAA and -AA anymore.
...mon/api/detection_engine/prebuilt_rules/model/diff/three_way_diff/three_way_merge_outcome.ts
Show resolved
Hide resolved
|
@banderror Reintroduced @dplumlee While introducing/modifying the integration tests for scenarios For example, the assertion in the case of the const reviewResponse = await reviewPrebuiltRulesToUpgrade(supertest);
expect(reviewResponse.rules[0].diff.fields).toEqual({
version: {
current_version: 1,
target_version: 2,
merged_version: 2,
diff_outcome: ThreeWayDiffOutcome.StockValueCanUpdate,
merge_outcome: ThreeWayMergeOutcome.Target,
has_conflict: false,
has_update: true,
},
});which in my opinion creates cognitive dissonance because the reader of the test is expecting to see So I went ahead and simplified all integration tests, now doing assertions only on the field that should/shouldn't be part of the So now the focus of each test is exclusively on the field that corresponds to the algorithm type. |
| } | ||
|
|
||
| const addedCurrent = difference(dedupedCurrentVersion, dedupedBaseVersion); | ||
| const addedCurrent = difference(dedupedCurrentVersion, dedupedBaseVersion as TValue[]); |
There was a problem hiding this comment.
We always try to avoid as casting in production code, can we try to rewrite this algorithm in a type-safe way?
| const removedCurrent = difference(dedupedBaseVersion, dedupedCurrentVersion); | ||
|
|
||
| const addedTarget = difference(dedupedTargetVersion, dedupedBaseVersion); | ||
| const addedTarget = difference(dedupedTargetVersion, dedupedBaseVersion as TValue[]); |
| const mergedVersion = merge(currentVersion, baseVersion, targetVersion, { | ||
| // TS does not realize that in ABC scenario, baseVersion cannot be missing | ||
| // Missing baseVersion scenarios were handled as -AA and -AB. | ||
| const mergedVersion = merge(currentVersion, baseVersion as string, targetVersion, { |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: cc @jpdjere |
Resolves: #180153
Resolves: #188277
Summary
Extend the POST /upgrade/_review API endpoint's contract and functionality
Changes
has_conflictproperty within each rule field'sThreeWayDifffrombooleantoenumwith possible values:NONE: no conflicts in three way diffSOLVABLE: conflict detected but was successfully resolved by our algorithmsNON_SOLVABLE: conflict detected and could not be resolved by our algorithms.Adds
has_base_versionboolean field within each field diff calculation. Has values:The possible values for
has_conflictfor each concrete diff algorithm are:NO,NON_SOLVABLENO,SOLVABLE,NON_SOLVABLENO,NON_SOLVABLENO,SOLVABLEAdds new logic to handle [Security Solution] Updates diff outcome logic to return
CustomizedValueCanUpdateon scenario-AB#186435 (comment)For maintainers