Commit aeb873a
[Security Solution] Adds
**Resolves: elastic/security-team#12507
(internal)
## Summary
Adds two new fields to the existing `rule_source` object in our rule
schema as described in #230856.
Also updates and adds test coverage for the new field logic.
The new fields are:
- `customized_fields`: an array of objects containing rule field names
that have been modified from the base version of the prebuilt rule.
- Defaults to empty array if prebuilt rule is not customized or if base
version did not exist during diff calculation.
- `has_base_version`: a boolean field that specifies if the base version
of a prebuilt rule was able to be fetched and used during the
customization calculation.
This PR also adds related telemetry fields as described in
#230856. This includes a
`customizations` object field which contains a slimmed down version of
`customized_fields` and has a `num_functional_fields` number field that
is created in the telemetry task pipeline by comparing the customized
fields array to a constant list of field names that we are defining as
"functional". This source of truth list can be found in the
`x-pack/solutions/security/plugins/security_solution/common/detection_engine/constants.ts`
file
### Examples
```json
{
"rule_source": {
"type": "external",
"is_customized": true,
/* New fields */
"customized_fields": [
{
"field_name": "tags",
},
{
"field_name": "query",
}
],
"has_base_version": true
}
}
```
```json
"customizations": {
"customized_fields": ["tags", "query"],
"num_functional_fields": 2,
}
```
## How to test telemetry
Link to internal staging with example data: ([internal
staging](https://analytics-staging.sde.elastic.dev/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:'2025-09-26T15:59:24.512Z',to:'2025-09-26T16:08:58.435Z'))&_a=(columns:!(),dataSource:(dataViewId:'4ca97040-d095-11ec-95a5-011050c1180f',type:dataView),filters:!(),interval:auto,query:(language:kuery,query:'customizations.num_functional_fields%20%3E%200'),sort:!(!('@timestamp',desc)),viewMode:documents)))
1. Set the prebuilt rule task type to something shorter than `1hr` in
this file:
`x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/tasks/prebuilt_rule_alerts.ts`
2. Add the following to `kibana.dev.yml`:
```
telemetry.enabled: true
telemetry.optIn: true
// (Optional for checking to see if its working)
logging:
root:
appenders: [default]
level: warn
loggers:
- name: plugins.securitySolution
level: debug
- name: plugins.ruleRegistry
- name: plugins.taskManager
```
3. Start up both Elasticsearch and kibana (Has to be done _after_
updating task interval as task objects are stored in ES)
4. Install prebuilt rules
5. Modify prebuilt rules with different field customizations and enable
those rules
6. Generate alerts that match these rules (resolver script generator,
dev tools, query modification, etc.)
7. View the alerts getting sent to the internal staging telemetry
cluster (https://analytics-staging.sde.elastic.dev) in the
`detections_alert_telemetry_elastic*` index
8. Use the new `customizations` field to filter out/in customized rule
alerts
## Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] [Rule customization
tests](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9317)
---------
Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Georgii Gorbachev <[email protected]>customized_fields and has_base_version fields to rule_source object schema (#234793)1 parent 3501634 commit aeb873a
File tree
55 files changed
+1386
-303
lines changed- oas_docs/output
- x-pack/solutions/security
- plugins/security_solution
- common/api/detection_engine
- model/rule_schema
- rule_management/import_rules
- docs
- openapi
- ess
- serverless
- testing/test_plans/detection_response/prebuilt_rules
- public/detection_engine/rule_management/components/rule_details/json_diff
- server/lib
- detection_engine
- rule_management
- logic
- actions
- bulk_actions
- detection_rules_client
- converters
- mergers
- rule_source
- export
- import
- rule_schema/model
- telemetry
- filterlists
- tasks
- test/security_solution_api_integration/test_suites/detections_response/rules_management/prebuilt_rules
- common
- import_export
- revert_prebuilt_rules
- customization_enabled/customization
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
55 files changed
+1386
-303
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70783 | 70783 | | |
70784 | 70784 | | |
70785 | 70785 | | |
| 70786 | + | |
| 70787 | + | |
| 70788 | + | |
| 70789 | + | |
| 70790 | + | |
| 70791 | + | |
| 70792 | + | |
| 70793 | + | |
| 70794 | + | |
| 70795 | + | |
| 70796 | + | |
| 70797 | + | |
| 70798 | + | |
| 70799 | + | |
70786 | 70800 | | |
70787 | 70801 | | |
70788 | 70802 | | |
70789 | 70803 | | |
| 70804 | + | |
| 70805 | + | |
| 70806 | + | |
| 70807 | + | |
70790 | 70808 | | |
70791 | 70809 | | |
70792 | 70810 | | |
| |||
70796 | 70814 | | |
70797 | 70815 | | |
70798 | 70816 | | |
| 70817 | + | |
| 70818 | + | |
70799 | 70819 | | |
70800 | 70820 | | |
70801 | 70821 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83976 | 83976 | | |
83977 | 83977 | | |
83978 | 83978 | | |
| 83979 | + | |
| 83980 | + | |
| 83981 | + | |
| 83982 | + | |
| 83983 | + | |
| 83984 | + | |
| 83985 | + | |
| 83986 | + | |
| 83987 | + | |
| 83988 | + | |
| 83989 | + | |
| 83990 | + | |
| 83991 | + | |
| 83992 | + | |
83979 | 83993 | | |
83980 | 83994 | | |
83981 | 83995 | | |
83982 | 83996 | | |
| 83997 | + | |
| 83998 | + | |
| 83999 | + | |
| 84000 | + | |
83983 | 84001 | | |
83984 | 84002 | | |
83985 | 84003 | | |
| |||
83989 | 84007 | | |
83990 | 84008 | | |
83991 | 84009 | | |
| 84010 | + | |
| 84011 | + | |
83992 | 84012 | | |
83993 | 84013 | | |
83994 | 84014 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
92 | 111 | | |
93 | 112 | | |
94 | 113 | | |
| |||
104 | 123 | | |
105 | 124 | | |
106 | 125 | | |
| 126 | + | |
| 127 | + | |
107 | 128 | | |
108 | 129 | | |
109 | 130 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
73 | 89 | | |
74 | 90 | | |
75 | 91 | | |
| |||
91 | 107 | | |
92 | 108 | | |
93 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
94 | 114 | | |
95 | 115 | | |
96 | 116 | | |
| 117 | + | |
| 118 | + | |
97 | 119 | | |
98 | 120 | | |
99 | 121 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
262 | 264 | | |
263 | 265 | | |
264 | 266 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
| 1059 | + | |
| 1060 | + | |
1059 | 1061 | | |
1060 | 1062 | | |
1061 | 1063 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6315 | 6315 | | |
6316 | 6316 | | |
6317 | 6317 | | |
| 6318 | + | |
| 6319 | + | |
| 6320 | + | |
| 6321 | + | |
| 6322 | + | |
| 6323 | + | |
| 6324 | + | |
| 6325 | + | |
| 6326 | + | |
| 6327 | + | |
| 6328 | + | |
| 6329 | + | |
| 6330 | + | |
| 6331 | + | |
| 6332 | + | |
| 6333 | + | |
| 6334 | + | |
| 6335 | + | |
| 6336 | + | |
| 6337 | + | |
6318 | 6338 | | |
6319 | 6339 | | |
6320 | 6340 | | |
6321 | 6341 | | |
6322 | 6342 | | |
6323 | 6343 | | |
| 6344 | + | |
| 6345 | + | |
| 6346 | + | |
| 6347 | + | |
6324 | 6348 | | |
6325 | 6349 | | |
6326 | 6350 | | |
| |||
6330 | 6354 | | |
6331 | 6355 | | |
6332 | 6356 | | |
| 6357 | + | |
| 6358 | + | |
6333 | 6359 | | |
6334 | 6360 | | |
6335 | 6361 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5645 | 5645 | | |
5646 | 5646 | | |
5647 | 5647 | | |
| 5648 | + | |
| 5649 | + | |
| 5650 | + | |
| 5651 | + | |
| 5652 | + | |
| 5653 | + | |
| 5654 | + | |
| 5655 | + | |
| 5656 | + | |
| 5657 | + | |
| 5658 | + | |
| 5659 | + | |
| 5660 | + | |
| 5661 | + | |
| 5662 | + | |
| 5663 | + | |
| 5664 | + | |
| 5665 | + | |
| 5666 | + | |
| 5667 | + | |
5648 | 5668 | | |
5649 | 5669 | | |
5650 | 5670 | | |
5651 | 5671 | | |
5652 | 5672 | | |
5653 | 5673 | | |
| 5674 | + | |
| 5675 | + | |
| 5676 | + | |
| 5677 | + | |
5654 | 5678 | | |
5655 | 5679 | | |
5656 | 5680 | | |
| |||
5660 | 5684 | | |
5661 | 5685 | | |
5662 | 5686 | | |
| 5687 | + | |
| 5688 | + | |
5663 | 5689 | | |
5664 | 5690 | | |
5665 | 5691 | | |
| |||
Lines changed: 33 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
| 88 | + | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
| |||
245 | 248 | | |
246 | 249 | | |
247 | 250 | | |
| 251 | + | |
| 252 | + | |
248 | 253 | | |
249 | 254 | | |
250 | 255 | | |
| |||
253 | 258 | | |
254 | 259 | | |
255 | 260 | | |
256 | | - | |
| 261 | + | |
257 | 262 | | |
258 | 263 | | |
259 | 264 | | |
| 265 | + | |
| 266 | + | |
260 | 267 | | |
261 | 268 | | |
262 | 269 | | |
| |||
272 | 279 | | |
273 | 280 | | |
274 | 281 | | |
| 282 | + | |
| 283 | + | |
275 | 284 | | |
276 | 285 | | |
277 | 286 | | |
| |||
308 | 317 | | |
309 | 318 | | |
310 | 319 | | |
| 320 | + | |
| 321 | + | |
311 | 322 | | |
312 | 323 | | |
313 | 324 | | |
| |||
324 | 335 | | |
325 | 336 | | |
326 | 337 | | |
| 338 | + | |
| 339 | + | |
327 | 340 | | |
328 | 341 | | |
329 | 342 | | |
| |||
340 | 353 | | |
341 | 354 | | |
342 | 355 | | |
| 356 | + | |
| 357 | + | |
343 | 358 | | |
344 | 359 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | 360 | | |
350 | 361 | | |
351 | 362 | | |
| |||
356 | 367 | | |
357 | 368 | | |
358 | 369 | | |
| 370 | + | |
| 371 | + | |
359 | 372 | | |
360 | 373 | | |
361 | 374 | | |
| |||
367 | 380 | | |
368 | 381 | | |
369 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
370 | 398 | | |
371 | 399 | | |
372 | 400 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
| |||
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
| 296 | + | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
| |||
0 commit comments