Skip to content

Commit a751550

Browse files
kibanamachineJacek Kolezynski
andauthored
[8.x] [Security Solution] Improve documentation for version and revision fields (#216074) (#216531)
# Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution] Improve documentation for `version` and `revision` fields (#216074)](#216074) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Jacek Kolezynski","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-31T18:06:13Z","message":"[Security Solution] Improve documentation for `version` and `revision` fields (#216074)\n\n**Resolves: https://github.com/elastic/security-docs/issues/3545**\n\n## Summary\n\nI am fixing documentation for the version and revision fields.\nI used this page as the base documentation:\nhttps://docs.elastic.dev/security-solution/dev-docs/detections/rule-versions\n\nThe changes:\n- by marking the RuleVersion as read-only I am making sure we are\nproperly documenting that this field is not to be used in the request.\nIt is only returned in the response.\n- by introducing RuleRevision type and marking it as read-only, I am\ndoing the same for this field, saying that this field is not supposed to\nbe used in the request.\n- I am not changing any code in the app, as the ticket says we shouldn't\ndo any breaking changes and the update of the version should not cause\n400 error. Basically current behavior is kept: users can still update\nthe version to whatever value they want, including going backwards, and\nthe changes to revision field is completely ignored.\n- I am adding a condensed description of these fields.\n\nI wanted to introduce an internal link between these two fields, but I\ncouldn't make it work in Bump.sh (even though this should work, normal\nMarkdown links) so I abandoned this idea.\n\nYou can also use this [link](https://bump.sh/jkelas2/doc/kibana_wip2)\nwhere I deployed the generated bundled doc.\n\nScreenshots:\n\n<img width=\"664\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/34d82eb2-f7f0-4369-ad8e-2fd3c1f35447\"\n/>\n\n<img width=\"660\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/dc7772af-0185-4850-816e-60be003775d6\"\n/>\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"63575a8320a7e021df79727ad66ed4cf01dd1e5f","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Detections and Resp","Team: SecuritySolution","Feature:Rule Management","APIDocs","Team:Detection Rule Management","Feature:Prebuilt Detection Rules","backport:version","9.1 candidate","v9.1.0","v8.19.0"],"title":"[Security Solution] Improve documentation for `version` and `revision` fields","number":216074,"url":"https://github.com/elastic/kibana/pull/216074","mergeCommit":{"message":"[Security Solution] Improve documentation for `version` and `revision` fields (#216074)\n\n**Resolves: https://github.com/elastic/security-docs/issues/3545**\n\n## Summary\n\nI am fixing documentation for the version and revision fields.\nI used this page as the base documentation:\nhttps://docs.elastic.dev/security-solution/dev-docs/detections/rule-versions\n\nThe changes:\n- by marking the RuleVersion as read-only I am making sure we are\nproperly documenting that this field is not to be used in the request.\nIt is only returned in the response.\n- by introducing RuleRevision type and marking it as read-only, I am\ndoing the same for this field, saying that this field is not supposed to\nbe used in the request.\n- I am not changing any code in the app, as the ticket says we shouldn't\ndo any breaking changes and the update of the version should not cause\n400 error. Basically current behavior is kept: users can still update\nthe version to whatever value they want, including going backwards, and\nthe changes to revision field is completely ignored.\n- I am adding a condensed description of these fields.\n\nI wanted to introduce an internal link between these two fields, but I\ncouldn't make it work in Bump.sh (even though this should work, normal\nMarkdown links) so I abandoned this idea.\n\nYou can also use this [link](https://bump.sh/jkelas2/doc/kibana_wip2)\nwhere I deployed the generated bundled doc.\n\nScreenshots:\n\n<img width=\"664\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/34d82eb2-f7f0-4369-ad8e-2fd3c1f35447\"\n/>\n\n<img width=\"660\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/dc7772af-0185-4850-816e-60be003775d6\"\n/>\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"63575a8320a7e021df79727ad66ed4cf01dd1e5f"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216074","number":216074,"mergeCommit":{"message":"[Security Solution] Improve documentation for `version` and `revision` fields (#216074)\n\n**Resolves: https://github.com/elastic/security-docs/issues/3545**\n\n## Summary\n\nI am fixing documentation for the version and revision fields.\nI used this page as the base documentation:\nhttps://docs.elastic.dev/security-solution/dev-docs/detections/rule-versions\n\nThe changes:\n- by marking the RuleVersion as read-only I am making sure we are\nproperly documenting that this field is not to be used in the request.\nIt is only returned in the response.\n- by introducing RuleRevision type and marking it as read-only, I am\ndoing the same for this field, saying that this field is not supposed to\nbe used in the request.\n- I am not changing any code in the app, as the ticket says we shouldn't\ndo any breaking changes and the update of the version should not cause\n400 error. Basically current behavior is kept: users can still update\nthe version to whatever value they want, including going backwards, and\nthe changes to revision field is completely ignored.\n- I am adding a condensed description of these fields.\n\nI wanted to introduce an internal link between these two fields, but I\ncouldn't make it work in Bump.sh (even though this should work, normal\nMarkdown links) so I abandoned this idea.\n\nYou can also use this [link](https://bump.sh/jkelas2/doc/kibana_wip2)\nwhere I deployed the generated bundled doc.\n\nScreenshots:\n\n<img width=\"664\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/34d82eb2-f7f0-4369-ad8e-2fd3c1f35447\"\n/>\n\n<img width=\"660\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/dc7772af-0185-4850-816e-60be003775d6\"\n/>\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"63575a8320a7e021df79727ad66ed4cf01dd1e5f"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Jacek Kolezynski <[email protected]>
1 parent 79cc21e commit a751550

File tree

8 files changed

+143
-18
lines changed

8 files changed

+143
-18
lines changed

oas_docs/output/kibana.serverless.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50145,8 +50145,7 @@ components:
5014550145
required_fields:
5014650146
$ref: '#/components/schemas/Security_Detections_API_RequiredFieldArray'
5014750147
revision:
50148-
minimum: 0
50149-
type: integer
50148+
$ref: '#/components/schemas/Security_Detections_API_RuleRevision'
5015050149
rule_id:
5015150150
$ref: '#/components/schemas/Security_Detections_API_RuleSignatureId'
5015250151
rule_source:
@@ -50492,6 +50491,15 @@ components:
5049250491
- $ref: '#/components/schemas/Security_Detections_API_EsqlRule'
5049350492
discriminator:
5049450493
propertyName: type
50494+
Security_Detections_API_RuleRevision:
50495+
description: |
50496+
The rule's revision number.
50497+
50498+
It represents the version of rule's object in Kibana. It is set to `0` when the rule is installed or created and then gets incremented on each update.
50499+
> info
50500+
> Not all updates to any rule fields will increment the revision. Only those fields that are considered static `rule parameters` can trigger revision increments. For example, an update to a rule's query or index fields will increment the rule's revision by `1`. However, changes to dynamic or technical fields like enabled or execution_summary will not cause revision increments.
50501+
minimum: 0
50502+
type: integer
5049550503
Security_Detections_API_RuleSignatureId:
5049650504
description: Could be any string, not necessarily a UUID
5049750505
type: string
@@ -50520,7 +50528,13 @@ components:
5052050528
discriminator:
5052150529
propertyName: type
5052250530
Security_Detections_API_RuleVersion:
50523-
description: The rule's version number.
50531+
description: |
50532+
The rule's version number.
50533+
50534+
- For prebuilt rules it represents the version of the rule's content in the source [detection-rules](https://github.com/elastic/detection-rules) repository (and the corresponding `security_detection_engine` Fleet package that is used for distributing prebuilt rules).
50535+
- For custom rules it is set to `1` when the rule is created.
50536+
> info
50537+
> It is not incremented on each update. Compare this to the `revision` field.
5052450538
minimum: 1
5052550539
type: integer
5052650540
Security_Detections_API_SavedObjectResolveAliasPurpose:

oas_docs/output/kibana.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35675,8 +35675,7 @@ components:
3567535675
required_fields:
3567635676
$ref: '#/components/schemas/Security_Detections_API_RequiredFieldArray'
3567735677
revision:
35678-
minimum: 0
35679-
type: integer
35678+
$ref: '#/components/schemas/Security_Detections_API_RuleRevision'
3568035679
rule_id:
3568135680
$ref: '#/components/schemas/Security_Detections_API_RuleSignatureId'
3568235681
rule_source:
@@ -36022,6 +36021,15 @@ components:
3602236021
- $ref: '#/components/schemas/Security_Detections_API_EsqlRule'
3602336022
discriminator:
3602436023
propertyName: type
36024+
Security_Detections_API_RuleRevision:
36025+
description: |
36026+
The rule's revision number.
36027+
36028+
It represents the version of rule's object in Kibana. It is set to `0` when the rule is installed or created and then gets incremented on each update.
36029+
> info
36030+
> Not all updates to any rule fields will increment the revision. Only those fields that are considered static `rule parameters` can trigger revision increments. For example, an update to a rule's query or index fields will increment the rule's revision by `1`. However, changes to dynamic or technical fields like enabled or execution_summary will not cause revision increments.
36031+
minimum: 0
36032+
type: integer
3602536033
Security_Detections_API_RuleSignatureId:
3602636034
description: Could be any string, not necessarily a UUID
3602736035
type: string
@@ -36050,7 +36058,13 @@ components:
3605036058
discriminator:
3605136059
propertyName: type
3605236060
Security_Detections_API_RuleVersion:
36053-
description: The rule's version number.
36061+
description: |
36062+
The rule's version number.
36063+
36064+
- For prebuilt rules it represents the version of the rule's content in the source [detection-rules](https://github.com/elastic/detection-rules) repository (and the corresponding `security_detection_engine` Fleet package that is used for distributing prebuilt rules).
36065+
- For custom rules it is set to `1` when the rule is created.
36066+
> info
36067+
> It is not incremented on each update. Compare this to the `revision` field.
3605436068
minimum: 1
3605536069
type: integer
3605636070
Security_Detections_API_SavedObjectResolveAliasPurpose:

x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,28 @@ export type RuleDescription = z.infer<typeof RuleDescription>;
3535
export const RuleDescription = z.string().min(1);
3636

3737
/**
38-
* The rule's version number.
39-
*/
38+
* The rule's version number.
39+
40+
- For prebuilt rules it represents the version of the rule's content in the source [detection-rules](https://github.com/elastic/detection-rules) repository (and the corresponding `security_detection_engine` Fleet package that is used for distributing prebuilt rules).
41+
- For custom rules it is set to `1` when the rule is created.
42+
> info
43+
> It is not incremented on each update. Compare this to the `revision` field.
44+
45+
*/
4046
export type RuleVersion = z.infer<typeof RuleVersion>;
4147
export const RuleVersion = z.number().int().min(1);
4248

49+
/**
50+
* The rule's revision number.
51+
52+
It represents the version of rule's object in Kibana. It is set to `0` when the rule is installed or created and then gets incremented on each update.
53+
> info
54+
> Not all updates to any rule fields will increment the revision. Only those fields that are considered static `rule parameters` can trigger revision increments. For example, an update to a rule's query or index fields will increment the rule's revision by `1`. However, changes to dynamic or technical fields like enabled or execution_summary will not cause revision increments.
55+
56+
*/
57+
export type RuleRevision = z.infer<typeof RuleRevision>;
58+
export const RuleRevision = z.number().int().min(0);
59+
4360
export type QueryLanguage = z.infer<typeof QueryLanguage>;
4461
export const QueryLanguage = z.enum(['kuery', 'lucene', 'eql', 'esql']);
4562
export type QueryLanguageEnum = typeof QueryLanguage.enum;

x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/model/rule_schema/common_attributes.schema.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,23 @@ components:
2424
RuleVersion:
2525
type: integer
2626
minimum: 1
27-
description: The rule's version number.
27+
description: |
28+
The rule's version number.
29+
30+
- For prebuilt rules it represents the version of the rule's content in the source [detection-rules](https://github.com/elastic/detection-rules) repository (and the corresponding `security_detection_engine` Fleet package that is used for distributing prebuilt rules).
31+
- For custom rules it is set to `1` when the rule is created.
32+
> info
33+
> It is not incremented on each update. Compare this to the `revision` field.
34+
35+
RuleRevision:
36+
type: integer
37+
minimum: 0
38+
description: |
39+
The rule's revision number.
40+
41+
It represents the version of rule's object in Kibana. It is set to `0` when the rule is installed or created and then gets incremented on each update.
42+
> info
43+
> Not all updates to any rule fields will increment the revision. Only those fields that are considered static `rule parameters` can trigger revision increments. For example, an update to a rule's query or index fields will increment the rule's revision by `1`. However, changes to dynamic or technical fields like enabled or execution_summary will not cause revision increments.
2844
2945
QueryLanguage:
3046
type: string

x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_schemas.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import {
5959
RuleSignatureId,
6060
IsRuleImmutable,
6161
RuleSource,
62+
RuleRevision,
6263
RequiredFieldArray,
6364
RuleQuery,
6465
IndexPatternArray,
@@ -166,7 +167,7 @@ export const ResponseFields = z.object({
166167
updated_by: z.string(),
167168
created_at: z.string().datetime(),
168169
created_by: z.string(),
169-
revision: z.number().int().min(0),
170+
revision: RuleRevision,
170171
required_fields: RequiredFieldArray,
171172
execution_summary: RuleExecutionSummary.optional(),
172173
});

x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/model/rule_schema/rule_schemas.schema.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ components:
193193
created_by:
194194
type: string
195195
revision:
196-
type: integer
197-
minimum: 0
196+
$ref: './common_attributes.schema.yaml#/components/schemas/RuleRevision'
198197
# NOTE: For now, Required Fields are
199198
# supported for prebuilt rules only. We don't want to allow users to edit these 3
200199
# fields via the API. If we added them to baseParams.defaultable, they would

x-pack/solutions/security/plugins/security_solution/docs/openapi/ess/security_solution_detections_api_2023_10_31.bundled.schema.yaml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5115,8 +5115,7 @@ components:
51155115
required_fields:
51165116
$ref: '#/components/schemas/RequiredFieldArray'
51175117
revision:
5118-
minimum: 0
5119-
type: integer
5118+
$ref: '#/components/schemas/RuleRevision'
51205119
rule_id:
51215120
$ref: '#/components/schemas/RuleSignatureId'
51225121
rule_source:
@@ -5505,6 +5504,25 @@ components:
55055504
- $ref: '#/components/schemas/EsqlRule'
55065505
discriminator:
55075506
propertyName: type
5507+
RuleRevision:
5508+
description: >
5509+
The rule's revision number.
5510+
5511+
5512+
It represents the version of rule's object in Kibana. It is set to `0`
5513+
when the rule is installed or created and then gets incremented on each
5514+
update.
5515+
5516+
> info
5517+
5518+
> Not all updates to any rule fields will increment the revision. Only
5519+
those fields that are considered static `rule parameters` can trigger
5520+
revision increments. For example, an update to a rule's query or index
5521+
fields will increment the rule's revision by `1`. However, changes to
5522+
dynamic or technical fields like enabled or execution_summary will not
5523+
cause revision increments.
5524+
minimum: 0
5525+
type: integer
55085526
RuleSignatureId:
55095527
description: 'Could be any string, not necessarily a UUID'
55105528
type: string
@@ -5538,7 +5556,21 @@ components:
55385556
discriminator:
55395557
propertyName: type
55405558
RuleVersion:
5541-
description: The rule's version number.
5559+
description: >
5560+
The rule's version number.
5561+
5562+
5563+
- For prebuilt rules it represents the version of the rule's content in
5564+
the source [detection-rules](https://github.com/elastic/detection-rules)
5565+
repository (and the corresponding `security_detection_engine` Fleet
5566+
package that is used for distributing prebuilt rules).
5567+
5568+
- For custom rules it is set to `1` when the rule is created.
5569+
5570+
> info
5571+
5572+
> It is not incremented on each update. Compare this to the `revision`
5573+
field.
55425574
minimum: 1
55435575
type: integer
55445576
SavedObjectResolveAliasPurpose:

x-pack/solutions/security/plugins/security_solution/docs/openapi/serverless/security_solution_detections_api_2023_10_31.bundled.schema.yaml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4109,8 +4109,7 @@ components:
41094109
required_fields:
41104110
$ref: '#/components/schemas/RequiredFieldArray'
41114111
revision:
4112-
minimum: 0
4113-
type: integer
4112+
$ref: '#/components/schemas/RuleRevision'
41144113
rule_id:
41154114
$ref: '#/components/schemas/RuleSignatureId'
41164115
rule_source:
@@ -4499,6 +4498,25 @@ components:
44994498
- $ref: '#/components/schemas/EsqlRule'
45004499
discriminator:
45014500
propertyName: type
4501+
RuleRevision:
4502+
description: >
4503+
The rule's revision number.
4504+
4505+
4506+
It represents the version of rule's object in Kibana. It is set to `0`
4507+
when the rule is installed or created and then gets incremented on each
4508+
update.
4509+
4510+
> info
4511+
4512+
> Not all updates to any rule fields will increment the revision. Only
4513+
those fields that are considered static `rule parameters` can trigger
4514+
revision increments. For example, an update to a rule's query or index
4515+
fields will increment the rule's revision by `1`. However, changes to
4516+
dynamic or technical fields like enabled or execution_summary will not
4517+
cause revision increments.
4518+
minimum: 0
4519+
type: integer
45024520
RuleSignatureId:
45034521
description: 'Could be any string, not necessarily a UUID'
45044522
type: string
@@ -4532,7 +4550,21 @@ components:
45324550
discriminator:
45334551
propertyName: type
45344552
RuleVersion:
4535-
description: The rule's version number.
4553+
description: >
4554+
The rule's version number.
4555+
4556+
4557+
- For prebuilt rules it represents the version of the rule's content in
4558+
the source [detection-rules](https://github.com/elastic/detection-rules)
4559+
repository (and the corresponding `security_detection_engine` Fleet
4560+
package that is used for distributing prebuilt rules).
4561+
4562+
- For custom rules it is set to `1` when the rule is created.
4563+
4564+
> info
4565+
4566+
> It is not incremented on each update. Compare this to the `revision`
4567+
field.
45364568
minimum: 1
45374569
type: integer
45384570
SavedObjectResolveAliasPurpose:

0 commit comments

Comments
 (0)