You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[9.1] [Security Solution] Make importing prebuilt rules with missing base version tests matching the test scenario (#234735) (#235114)
# Backport
This will backport the following commits from `main` to `9.1`:
- [[Security Solution] Make importing prebuilt rules with missing base
version tests matching the test scenario
(#234735)](#234735)
<!--- Backport version: 9.6.6 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)
<!--BACKPORT [{"author":{"name":"Maxim
Palenov","email":"maxim.palenov@elastic.co"},"sourceCommit":{"committedDate":"2025-09-15T16:36:35Z","message":"[Security
Solution] Make importing prebuilt rules with missing base version tests
matching the test scenario (#234735)\n\n**Relates to:**
https://github.com/elastic/kibana/pull/223421\n\n## Summary\n\nThis PR
makes little adjustments to [Importing
Prebuilt\nRules](#223421) with
missing base\nversion test scenario implementation to make it matching
test scenario\nsteps. In particular it makes sure an installed prebuilt
rule gets\ncustomized before testing
import.","sha":"10533ebfa440c6ac91166cc1d6d33b72d7102dc9","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["test","release_note:skip","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rule
Management","Feature:Prebuilt Detection
Rules","backport:version","v9.2.0","v9.1.3","v8.19.3","v9.0.6","v8.18.7"],"title":"[Security
Solution] Make importing prebuilt rules with missing base version tests
matching the test
scenario","number":234735,"url":"https://github.com/elastic/kibana/pull/234735","mergeCommit":{"message":"[Security
Solution] Make importing prebuilt rules with missing base version tests
matching the test scenario (#234735)\n\n**Relates to:**
https://github.com/elastic/kibana/pull/223421\n\n## Summary\n\nThis PR
makes little adjustments to [Importing
Prebuilt\nRules](#223421) with
missing base\nversion test scenario implementation to make it matching
test scenario\nsteps. In particular it makes sure an installed prebuilt
rule gets\ncustomized before testing
import.","sha":"10533ebfa440c6ac91166cc1d6d33b72d7102dc9"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19","9.0","8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/234735","number":234735,"mergeCommit":{"message":"[Security
Solution] Make importing prebuilt rules with missing base version tests
matching the test scenario (#234735)\n\n**Relates to:**
https://github.com/elastic/kibana/pull/223421\n\n## Summary\n\nThis PR
makes little adjustments to [Importing
Prebuilt\nRules](#223421) with
missing base\nversion test scenario implementation to make it matching
test scenario\nsteps. In particular it makes sure an installed prebuilt
rule gets\ncustomized before testing
import.","sha":"10533ebfa440c6ac91166cc1d6d33b72d7102dc9"}},{"branch":"9.1","label":"v9.1.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
Copy file name to clipboardExpand all lines: x-pack/solutions/security/plugins/security_solution/docs/testing/test_plans/detection_response/prebuilt_rules/prebuilt_rule_import.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -555,10 +555,10 @@ If this rule is already installed, it should be updated. Its `is_customized` fie
555
555
**Automation**: 1 API integration test.
556
556
557
557
```Gherkin
558
-
Given the import payload contains a non-customized prebuilt rule
558
+
Given the import payload contains a prebuilt rule
559
559
And its rule_id matches one or more rule assets from the installed package
560
560
And its version does NOT match any of those rule assets
561
-
And this rule is already installed and marked as non-customized
561
+
And this rule is already installed and marked as <customization_state>
562
562
And the installed rule is NOT equal to the import payload
563
563
When the user imports the rule
564
564
Then the rule should be updated
@@ -568,6 +568,10 @@ And the updated rule's version should match the import payload
568
568
And the updated rule's parameters should match the import payload
#### **Scenario: Importing a prebuilt rule with a missing base version when it's already installed, is not customized, and is equal to the import payload**
572
576
573
577
If this rule is already installed, it should be updated. Its `is_customized` field should stay unchanged (`false` or `true`) if the rule from the import payload is equal to the installed rule.
Copy file name to clipboardExpand all lines: x-pack/solutions/security/test/security_solution_api_integration/test_suites/detections_response/rules_management/prebuilt_rules/common/import_export/import_with_missing_base_version.ts
it('imports a prebuilt rule with a missing base version when import payload IS NOT EQUAL to the installed and customized prebuilt rule',async()=>{
152
+
awaitinstallPrebuiltRules(es,supertest);
153
+
awaitsecuritySolutionApi
154
+
.patchRule({
155
+
body: {
156
+
rule_id: PREBUILT_RULE_ID,
157
+
name: 'Customized prebuilt rule A',
158
+
tags: ['custom-tag'],
159
+
},
160
+
})
161
+
.expect(200);
162
+
163
+
constVERSION=CURRENT_PREBUILT_RULE_VERSION-1;
164
+
constNON_CUSTOMIZED_PREBUILT_RULE_TO_IMPORT={
165
+
...PREBUILT_RULE_ASSET['security-rule'],
166
+
name: 'Some old prebuilt rule A',
167
+
description: 'Some old value',
168
+
version: VERSION,
169
+
immutable: true,
170
+
rule_source: {
171
+
type: 'external',
172
+
is_customized: false,
173
+
},
174
+
};
175
+
176
+
awaitimportRulesWithSuccess({
177
+
getService,
178
+
rules: [NON_CUSTOMIZED_PREBUILT_RULE_TO_IMPORT],
179
+
overwrite: true,
180
+
});
181
+
182
+
awaitassertImportedRule({
183
+
getService,
184
+
expectedRule: {
185
+
...NON_CUSTOMIZED_PREBUILT_RULE_TO_IMPORT,
186
+
version: VERSION,
187
+
immutable: true,
188
+
rule_source: {
189
+
type: 'external',
190
+
is_customized: true,
191
+
},
192
+
},
193
+
});
194
+
});
195
+
150
196
// The test fails most probably due to a bug. It requires further investigation.
151
197
// https://github.com/elastic/kibana/issues/223253 has been created to track it.
152
-
it.skip('imports a non-customized prebuilt rule with a missing base version when import payload is equal to the installed prebuilt rule',async()=>{
198
+
it.skip('imports a prebuilt rule with a missing base version when import payload IS EQUAL to the installed and not-customized prebuilt rule',async()=>{
it('imports a customized prebuilt rule with a missing base version when import payload and is equal to the installed customized prebuilt rule',async()=>{
232
+
it('imports a prebuilt rule with a missing base version when import payload IS EQUAL to the installed customized prebuilt rule',async()=>{
0 commit comments