Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Account for missing base rule versions in is_customized calculation #213250

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

xcrzx
Copy link
Contributor

@xcrzx xcrzx commented Mar 5, 2025

Partially addresses: #210358

Summary

Editing of prebuilt rules with missing base versions

When the base version of a currently installed prebuilt rule is missing among the security-rule asset saved objects, and the user edits this rule:

  • We should mark the rule as customized, only if the new rule settings are different from the current rule settings.
    • For example, adding a new tag should mark the rule as customized. Then, if the user removes this tag, the rule should remain to be marked as customized. This matches the current behavior.
    • However, if the user saves the rule without making any changes to it, it should keep its is_customized field as is. This is different from the current behavior.

Importing of prebuilt rules with missing base versions

When the base version of a prebuilt rule that is being imported is missing among the security-rule asset saved objects, and the user imports this rule:

  • If this rule is not installed, it should be created with is_customized field set to false.
  • If this rule is already installed, it should be updated.
    • Its is_customized field should be set to true if the rule from the import payload is not equal to the installed rule.
    • Its is_customized field should be be kept unchanged (false or true) if the rule from the import payload is equal to the installed rule.

@xcrzx xcrzx self-assigned this Mar 5, 2025
@xcrzx xcrzx force-pushed the import-rule-source branch from 3d19755 to f4f7ff1 Compare March 6, 2025 14:03
@xcrzx xcrzx added v9.0.0 Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area backport:version Backport to applied version labels v8.18.0 v9.1.0 v8.19.0 release_note:skip Skip the PR/issue when compiling release notes Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team labels Mar 6, 2025
@xcrzx xcrzx marked this pull request as ready for review March 6, 2025 14:44
@xcrzx xcrzx requested a review from a team as a code owner March 6, 2025 14:44
@xcrzx xcrzx requested a review from maximpn March 6, 2025 14:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management)

@xcrzx xcrzx force-pushed the import-rule-source branch from f4f7ff1 to 24cdb9a Compare March 6, 2025 16:05
Copy link
Contributor

@maximpn maximpn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xcrzx Thanks for concise implementation 🙏

I looked through the changes and left non critical comments. Local testing confirmed the changes work as expected.

Comment on lines +182 to +183
// No base version
prebuiltRuleAssetClient.fetchAssetsByVersion.mockResolvedValueOnce([]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It feels like this line could potentially be forgotten when adding new tests. Maybe move it to beforeEach()?

ruleCustomizationStatus,
}: CalculateRuleSourceProps): Promise<RuleSource> {
if (rule.immutable) {
if (nextRule.immutable) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Inverse logic and early exit will make this function a bit simpler

if (!nextRule.immutable) {
  return {
    type: 'internal',
  };
}

...

Comment on lines 32 to 33
prebuiltRuleAssetsByRuleId,
isKnownPrebuiltRule,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It could be simplified by having only prebuiltRuleAssets: PrebuiltRuleAsset | undefined matching the rule version instead of isKnownPrebuiltRule and prebuiltRuleAssetsByRuleId .

@@ -26,31 +27,44 @@ import { convertRuleToImportToRuleResponse } from './converters/convert_rule_to_
* @returns The calculated rule_source and immutable fields for the rule
*/
export const calculateRuleSourceForImport = ({
rule,
importedRule,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It doesn't look like a has been imported when this function is invoked. A name like ruleToImport or beingImportedRule feels like resonating better.

});
});

it('calculates as non modified external type if an asset is found without a matching version and current rule present without changes', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing scenario covering that is_customized: true is preserved when imported rule matches with the current.

@@ -271,7 +271,7 @@ export default ({ getService }: FtrProviderContext): void => {
expect(importedRule).toMatchObject({
rule_id: rule.rule_id,
version: 9999,
rule_source: { type: 'external', is_customized: true },
rule_source: { type: 'external', is_customized: false },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It doesn't look like something besides version should be in that assertion.

private ruleCustomizationStatus: PrebuiltRulesCustomizationStatus;
private latestPackagesInstalled: boolean = false;
private matchingAssetsByRuleId: Record<string, PrebuiltRuleAsset> = {};
private knownRules: RuleSpecifier[] = [];
private currentRulesById: Record<string, RuleResponse> = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private currentRulesById: Record<string, RuleResponse> = {};
private currentRulesById: Record<RuleSignatureId, RuleResponse> = {};

@@ -165,11 +176,18 @@ export class RuleSourceImporter implements IRuleSourceImporter {
}, {});
}

private async fetchInstalledRulesByIds(ruleIds: string[]): Promise<Record<string, RuleResponse>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add Map to the name for clarity

Suggested change
private async fetchInstalledRulesByIds(ruleIds: string[]): Promise<Record<string, RuleResponse>> {
private async fetchInstalledRulesMapByIds(ruleIds: string[]): Promise<Record<RuleSignatureId, RuleResponse>> {

@maximpn maximpn enabled auto-merge (squash) March 6, 2025 18:01
@maximpn maximpn merged commit 87e7cd9 into elastic:main Mar 6, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.x, 9.0

https://github.com/elastic/kibana/actions/runs/13705510140

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @xcrzx

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 6, 2025
…omized calculation (elastic#213250)

**Partially addresses: elastic#210358

## Summary

### Editing of prebuilt rules with missing base versions

**When the base version** of a currently installed prebuilt rule **is missing** among the `security-rule` asset saved objects, and the user edits this rule:

- We should mark the rule as customized, only if the new rule settings are different from the current rule settings.
  - For example, adding a new tag should mark the rule as customized. Then, if the user removes this tag, the rule should remain to be marked as customized. This matches the current behavior.
  - However, if the user saves the rule without making any changes to it, it should keep its `is_customized` field as is. This is different from the current behavior.

### Importing of prebuilt rules with missing base versions

**When the base version** of a prebuilt rule that is being imported **is missing** among the `security-rule` asset saved objects, and the user imports this rule:

- If this rule is not installed, it should be created with `is_customized` field set to `false`.
- If this rule is already installed, it should be updated.
  - Its `is_customized` field should be set to `true` if the rule from the import payload is not equal to the installed rule.
  - Its `is_customized` field should be be kept unchanged (`false` or `true`) if the rule from the import payload is equal to the installed rule.

(cherry picked from commit 87e7cd9)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 6, 2025
…omized calculation (elastic#213250)

**Partially addresses: elastic#210358

## Summary

### Editing of prebuilt rules with missing base versions

**When the base version** of a currently installed prebuilt rule **is missing** among the `security-rule` asset saved objects, and the user edits this rule:

- We should mark the rule as customized, only if the new rule settings are different from the current rule settings.
  - For example, adding a new tag should mark the rule as customized. Then, if the user removes this tag, the rule should remain to be marked as customized. This matches the current behavior.
  - However, if the user saves the rule without making any changes to it, it should keep its `is_customized` field as is. This is different from the current behavior.

### Importing of prebuilt rules with missing base versions

**When the base version** of a prebuilt rule that is being imported **is missing** among the `security-rule` asset saved objects, and the user imports this rule:

- If this rule is not installed, it should be created with `is_customized` field set to `false`.
- If this rule is already installed, it should be updated.
  - Its `is_customized` field should be set to `true` if the rule from the import payload is not equal to the installed rule.
  - Its `is_customized` field should be be kept unchanged (`false` or `true`) if the rule from the import payload is equal to the installed rule.

(cherry picked from commit 87e7cd9)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.18
8.x
9.0 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.0:
- [Security Solution] Allow prebuilt rules import and export (#212509)

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 213250

Questions ?

Please refer to the Backport tool documentation

banderror pushed a commit to banderror/kibana that referenced this pull request Mar 6, 2025
…omized calculation (elastic#213250)

**Partially addresses: elastic#210358

## Summary

### Editing of prebuilt rules with missing base versions

**When the base version** of a currently installed prebuilt rule **is missing** among the `security-rule` asset saved objects, and the user edits this rule:

- We should mark the rule as customized, only if the new rule settings are different from the current rule settings.
  - For example, adding a new tag should mark the rule as customized. Then, if the user removes this tag, the rule should remain to be marked as customized. This matches the current behavior.
  - However, if the user saves the rule without making any changes to it, it should keep its `is_customized` field as is. This is different from the current behavior.

### Importing of prebuilt rules with missing base versions

**When the base version** of a prebuilt rule that is being imported **is missing** among the `security-rule` asset saved objects, and the user imports this rule:

- If this rule is not installed, it should be created with `is_customized` field set to `false`.
- If this rule is already installed, it should be updated.
  - Its `is_customized` field should be set to `true` if the rule from the import payload is not equal to the installed rule.
  - Its `is_customized` field should be be kept unchanged (`false` or `true`) if the rule from the import payload is equal to the installed rule.

(cherry picked from commit 87e7cd9)
@banderror
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

banderror pushed a commit that referenced this pull request Mar 6, 2025
…s_customized calculation (#213250) (#213462)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution] Account for missing base rule versions in
is_customized calculation
(#213250)](#213250)

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

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

<!--BACKPORT [{"author":{"name":"Dmitrii
Shevchenko","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-06T18:22:17Z","message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","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] Account for missing base rule versions in is_customized
calculation","number":213250,"url":"https://github.com/elastic/kibana/pull/213250","mergeCommit":{"message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845"}},"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/213250","number":213250,"mergeCommit":{"message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Dmitrii Shevchenko <[email protected]>
banderror pushed a commit that referenced this pull request Mar 6, 2025
…is_customized calculation (#213250) (#213460)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Security Solution] Account for missing base rule versions in
is_customized calculation
(#213250)](#213250)

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

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

<!--BACKPORT [{"author":{"name":"Dmitrii
Shevchenko","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-06T18:22:17Z","message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","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] Account for missing base rule versions in is_customized
calculation","number":213250,"url":"https://github.com/elastic/kibana/pull/213250","mergeCommit":{"message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845"}},"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/213250","number":213250,"mergeCommit":{"message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Dmitrii Shevchenko <[email protected]>
banderror added a commit that referenced this pull request Mar 6, 2025
…s_customized calculation (#213250) (#213466)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Security Solution] Account for missing base rule versions in
is_customized calculation
(#213250)](#213250)

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

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

<!--BACKPORT [{"author":{"name":"Dmitrii
Shevchenko","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-06T18:22:17Z","message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","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] Account for missing base rule versions in is_customized
calculation","number":213250,"url":"https://github.com/elastic/kibana/pull/213250","mergeCommit":{"message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845"}},"sourceBranch":"main","suggestedTargetBranches":["9.0"],"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,"url":"https://github.com/elastic/kibana/pull/213460","number":213460,"state":"OPEN"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213250","number":213250,"mergeCommit":{"message":"[Security
Solution] Account for missing base rule versions in is_customized
calculation (#213250)\n\n**Partially addresses:
https://github.com/elastic/kibana/issues/210358**\n\n## Summary\n\n###
Editing of prebuilt rules with missing base versions\n\n**When the base
version** of a currently installed prebuilt rule **is missing** among
the `security-rule` asset saved objects, and the user edits this
rule:\n\n- We should mark the rule as customized, only if the new rule
settings are different from the current rule settings.\n - For example,
adding a new tag should mark the rule as customized. Then, if the user
removes this tag, the rule should remain to be marked as customized.
This matches the current behavior.\n - However, if the user saves the
rule without making any changes to it, it should keep its
`is_customized` field as is. This is different from the current
behavior.\n\n### Importing of prebuilt rules with missing base
versions\n\n**When the base version** of a prebuilt rule that is being
imported **is missing** among the `security-rule` asset saved objects,
and the user imports this rule:\n\n- If this rule is not installed, it
should be created with `is_customized` field set to `false`.\n- If this
rule is already installed, it should be updated.\n - Its `is_customized`
field should be set to `true` if the rule from the import payload is not
equal to the installed rule.\n - Its `is_customized` field should be be
kept unchanged (`false` or `true`) if the rule from the import payload
is equal to the installed
rule.","sha":"87e7cd94d1d649596dc0f23bf4cf730704fb4845"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/213462","number":213462,"state":"OPEN"}]}]
BACKPORT-->

Co-authored-by: Dmitrii Shevchenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area release_note:skip Skip the PR/issue when compiling release notes Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.18.0 v8.19.0 v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants