[8.18] [Security Solution] Force upgrading to target version for "Reference URLs" when base version is missing (#214161) (#214252)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Security Solution] Force upgrading to target version for "Reference
URLs" when base version is missing
(#214161)](https://github.com/elastic/kibana/pull/214161)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nikita
Indik","email":"nikita.indik@elastic.co"},"sourceCommit":{"committedDate":"2025-03-12T17:41:32Z","message":"[Security
Solution] Force upgrading to target version for \"Reference URLs\" when
base version is missing (#214161)\n\n**Resolves:
https://github.com/elastic/kibana/issues/214171**\n\n## Summary\n\nThis
PR fixes an issue with \"references\" field in -AB situations. When\nthe
base version is missing we try to merge current and target arrays\nwhich
leads to old and potentially broken URLs from the current
version\nending up in the result.\n\nNow the behaviour is changed to
always force merged version to be equal\nto target (which always has
correct
URLs).","sha":"07012811b29b487a3b4a664469c7a198355e44bf","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","impact:medium","v9.0.0","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rule
Management","Feature:Prebuilt Detection
Rules","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Security
Solution] Force upgrading to target version for \"Reference URLs\" when
base version is
missing","number":214161,"url":"https://github.com/elastic/kibana/pull/214161","mergeCommit":{"message":"[Security
Solution] Force upgrading to target version for \"Reference URLs\" when
base version is missing (#214161)\n\n**Resolves:
https://github.com/elastic/kibana/issues/214171**\n\n## Summary\n\nThis
PR fixes an issue with \"references\" field in -AB situations. When\nthe
base version is missing we try to merge current and target arrays\nwhich
leads to old and potentially broken URLs from the current
version\nending up in the result.\n\nNow the behaviour is changed to
always force merged version to be equal\nto target (which always has
correct
URLs).","sha":"07012811b29b487a3b4a664469c7a198355e44bf"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214161","number":214161,"mergeCommit":{"message":"[Security
Solution] Force upgrading to target version for \"Reference URLs\" when
base version is missing (#214161)\n\n**Resolves:
https://github.com/elastic/kibana/issues/214171**\n\n## Summary\n\nThis
PR fixes an issue with \"references\" field in -AB situations. When\nthe
base version is missing we try to merge current and target arrays\nwhich
leads to old and potentially broken URLs from the current
version\nending up in the result.\n\nNow the behaviour is changed to
always force merged version to be equal\nto target (which always has
correct
URLs).","sha":"07012811b29b487a3b4a664469c7a198355e44bf"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Nikita Indik <nikita.indik@elastic.co>
This commit is contained in:
Kibana Machine 2025-03-13 06:45:28 +11:00 committed by GitHub
parent 6dfee97c64
commit aed3dfbcaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -227,7 +227,7 @@ const commonFieldsDiffAlgorithms: FieldsDiffAlgorithmsFor<DiffableCommonFields>
risk_score: numberDiffAlgorithm,
risk_score_mapping: simpleDiffAlgorithm,
references: createScalarArrayDiffAlgorithm({
missingBaseVersionStrategy: ScalarArrayDiffMissingBaseVersionStrategy.Merge,
missingBaseVersionStrategy: ScalarArrayDiffMissingBaseVersionStrategy.UseTarget,
}),
false_positives: simpleDiffAlgorithm,
threat: simpleDiffAlgorithm,

View file

@ -297,11 +297,11 @@ export function referencesField({ getService }: FtrProviderContext): void {
ruleUpgradeAssets,
diffableRuleFieldName: 'references',
expectedDiffOutcome: ThreeWayDiffOutcome.MissingBaseCanUpdate,
isMergableField: true,
isMergableField: false,
expectedFieldDiffValues: {
current: ['http://url-3'],
target: ['http://url-1', 'http://url-2'],
merged: ['http://url-3', 'http://url-1', 'http://url-2'],
merged: ['http://url-1', 'http://url-2'],
},
},
getService