diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/normalization/rule_converters.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/normalization/rule_converters.ts index b2554e4f957da..618514dfbab4a 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/normalization/rule_converters.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/normalization/rule_converters.ts @@ -390,27 +390,6 @@ export const patchTypeSpecificSnakeToCamel = ( } }; -const versionExcludedKeys = ['enabled', 'id', 'rule_id']; -const incrementVersion = (nextParams: PatchRuleRequestBody, existingRule: RuleParams) => { - // The the version from nextParams if it's provided - if (nextParams.version) { - return nextParams.version; - } - - // If the rule is immutable, keep the current version - if (existingRule.immutable) { - return existingRule.version; - } - - // For custom rules, check modified params to deicide whether version increment is needed - for (const key in nextParams) { - if (!versionExcludedKeys.includes(key)) { - return existingRule.version + 1; - } - } - return existingRule.version; -}; - // eslint-disable-next-line complexity export const convertPatchAPIToInternalSchema = ( nextParams: PatchRuleRequestBody & { @@ -456,9 +435,7 @@ export const convertPatchAPIToInternalSchema = ( references: nextParams.references ?? existingParams.references, namespace: nextParams.namespace ?? existingParams.namespace, note: nextParams.note ?? existingParams.note, - // Always use the version from the request if specified. If it isn't specified, leave immutable rules alone and - // increment the version of mutable rules by 1. - version: incrementVersion(nextParams, existingParams), + version: nextParams.version ?? existingParams.version, exceptionsList: nextParams.exceptions_list ?? existingParams.exceptionsList, ...typeSpecificParams, }, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules.ts index f38a02bdce930..1fcd785820240 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/group10/patch_rules.ts @@ -53,7 +53,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body); expect(bodyToCompare).to.eql(outputRule); @@ -86,7 +85,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleMlRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body); expect(bodyToCompare).to.eql(outputRule); @@ -106,7 +104,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutputWithoutRuleId(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedPropertiesIncludingRuleId(body); expect(bodyToCompare).to.eql(outputRule); @@ -124,13 +121,12 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.name = 'some other name'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body); expect(bodyToCompare).to.eql(outputRule); }); - it('should not change the version of a rule when it patches only enabled', async () => { + it('should not change the revision of a rule when it patches only enabled', async () => { await createRule(supertest, log, getSimpleRule('rule-1')); // patch a simple rule's enabled to false @@ -147,7 +143,7 @@ export default ({ getService }: FtrProviderContext) => { expect(bodyToCompare).to.eql(outputRule); }); - it('should change the version of a rule when it patches enabled and another property', async () => { + it('should change the revision of a rule when it patches enabled and another property', async () => { await createRule(supertest, log, getSimpleRule('rule-1')); // patch a simple rule's enabled to false and another property @@ -160,7 +156,6 @@ export default ({ getService }: FtrProviderContext) => { const outputRule = getSimpleRuleOutput(); outputRule.enabled = false; outputRule.severity = 'low'; - outputRule.version = 2; outputRule.revision = 1; const bodyToCompare = removeServerGeneratedProperties(body); @@ -188,7 +183,6 @@ export default ({ getService }: FtrProviderContext) => { outputRule.name = 'some other name'; outputRule.timeline_title = 'some title'; outputRule.timeline_id = 'some id'; - outputRule.version = 3; outputRule.revision = 2; const bodyToCompare = removeServerGeneratedProperties(body);