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

**Resolves: https://github.com/elastic/kibana/issues/214171**

## Summary

This PR fixes an issue with "references" field in -AB situations. When
the base version is missing we try to merge current and target arrays
which leads to old and potentially broken URLs from the current version
ending up in the result.

Now the behaviour is changed to always force merged version to be equal
to target (which always has correct URLs).
This commit is contained in:
Nikita Indik 2025-03-12 18:41:32 +01:00 committed by GitHub
parent 3803afdbb4
commit 07012811b2
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