Skip to content

Commit 63575a8

Browse files
Jacek Kolezynskikibanamachine
andauthored
[Security Solution] Improve documentation for version and revision fields (#216074)
**Resolves: elastic/security-docs#3545 ## Summary I am fixing documentation for the version and revision fields. I used this page as the base documentation: https://docs.elastic.dev/security-solution/dev-docs/detections/rule-versions The changes: - by marking the RuleVersion as read-only I am making sure we are properly documenting that this field is not to be used in the request. It is only returned in the response. - by introducing RuleRevision type and marking it as read-only, I am doing the same for this field, saying that this field is not supposed to be used in the request. - I am not changing any code in the app, as the ticket says we shouldn't do any breaking changes and the update of the version should not cause 400 error. Basically current behavior is kept: users can still update the version to whatever value they want, including going backwards, and the changes to revision field is completely ignored. - I am adding a condensed description of these fields. I wanted to introduce an internal link between these two fields, but I couldn't make it work in Bump.sh (even though this should work, normal Markdown links) so I abandoned this idea. You can also use this [link](https://bump.sh/jkelas2/doc/kibana_wip2) where I deployed the generated bundled doc. Screenshots: <img width="664" alt="image" src="https://github.com/user-attachments/assets/34d82eb2-f7f0-4369-ad8e-2fd3c1f35447" /> <img width="660" alt="image" src="https://github.com/user-attachments/assets/dc7772af-0185-4850-816e-60be003775d6" /> --------- Co-authored-by: kibanamachine <[email protected]>
1 parent f408a51 commit 63575a8

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
@@ -53198,8 +53198,7 @@ components:
5319853198
required_fields:
5319953199
$ref: '#/components/schemas/Security_Detections_API_RequiredFieldArray'
5320053200
revision:
53201-
minimum: 0
53202-
type: integer
53201+
$ref: '#/components/schemas/Security_Detections_API_RuleRevision'
5320353202
rule_id:
5320453203
$ref: '#/components/schemas/Security_Detections_API_RuleSignatureId'
5320553204
rule_source:
@@ -53545,6 +53544,15 @@ components:
5354553544
- $ref: '#/components/schemas/Security_Detections_API_EsqlRule'
5354653545
discriminator:
5354753546
propertyName: type
53547+
Security_Detections_API_RuleRevision:
53548+
description: |
53549+
The rule's revision number.
53550+
53551+
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.
53552+
> info
53553+
> 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.
53554+
minimum: 0
53555+
type: integer
5354853556
Security_Detections_API_RuleSignatureId:
5354953557
description: Could be any string, not necessarily a UUID
5355053558
type: string
@@ -53573,7 +53581,13 @@ components:
5357353581
discriminator:
5357453582
propertyName: type
5357553583
Security_Detections_API_RuleVersion:
53576-
description: The rule's version number.
53584+
description: |
53585+
The rule's version number.
53586+
53587+
- 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).
53588+
- For custom rules it is set to `1` when the rule is created.
53589+
> info
53590+
> It is not incremented on each update. Compare this to the `revision` field.
5357753591
minimum: 1
5357853592
type: integer
5357953593
Security_Detections_API_SavedObjectResolveAliasPurpose:

oas_docs/output/kibana.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62042,8 +62042,7 @@ components:
6204262042
required_fields:
6204362043
$ref: '#/components/schemas/Security_Detections_API_RequiredFieldArray'
6204462044
revision:
62045-
minimum: 0
62046-
type: integer
62045+
$ref: '#/components/schemas/Security_Detections_API_RuleRevision'
6204762046
rule_id:
6204862047
$ref: '#/components/schemas/Security_Detections_API_RuleSignatureId'
6204962048
rule_source:
@@ -62389,6 +62388,15 @@ components:
6238962388
- $ref: '#/components/schemas/Security_Detections_API_EsqlRule'
6239062389
discriminator:
6239162390
propertyName: type
62391+
Security_Detections_API_RuleRevision:
62392+
description: |
62393+
The rule's revision number.
62394+
62395+
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.
62396+
> info
62397+
> 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.
62398+
minimum: 0
62399+
type: integer
6239262400
Security_Detections_API_RuleSignatureId:
6239362401
description: Could be any string, not necessarily a UUID
6239462402
type: string
@@ -62417,7 +62425,13 @@ components:
6241762425
discriminator:
6241862426
propertyName: type
6241962427
Security_Detections_API_RuleVersion:
62420-
description: The rule's version number.
62428+
description: |
62429+
The rule's version number.
62430+
62431+
- 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).
62432+
- For custom rules it is set to `1` when the rule is created.
62433+
> info
62434+
> It is not incremented on each update. Compare this to the `revision` field.
6242162435
minimum: 1
6242262436
type: integer
6242362437
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
@@ -5105,8 +5105,7 @@ components:
51055105
required_fields:
51065106
$ref: '#/components/schemas/RequiredFieldArray'
51075107
revision:
5108-
minimum: 0
5109-
type: integer
5108+
$ref: '#/components/schemas/RuleRevision'
51105109
rule_id:
51115110
$ref: '#/components/schemas/RuleSignatureId'
51125111
rule_source:
@@ -5495,6 +5494,25 @@ components:
54955494
- $ref: '#/components/schemas/EsqlRule'
54965495
discriminator:
54975496
propertyName: type
5497+
RuleRevision:
5498+
description: >
5499+
The rule's revision number.
5500+
5501+
5502+
It represents the version of rule's object in Kibana. It is set to `0`
5503+
when the rule is installed or created and then gets incremented on each
5504+
update.
5505+
5506+
> info
5507+
5508+
> Not all updates to any rule fields will increment the revision. Only
5509+
those fields that are considered static `rule parameters` can trigger
5510+
revision increments. For example, an update to a rule's query or index
5511+
fields will increment the rule's revision by `1`. However, changes to
5512+
dynamic or technical fields like enabled or execution_summary will not
5513+
cause revision increments.
5514+
minimum: 0
5515+
type: integer
54985516
RuleSignatureId:
54995517
description: Could be any string, not necessarily a UUID
55005518
type: string
@@ -5528,7 +5546,21 @@ components:
55285546
discriminator:
55295547
propertyName: type
55305548
RuleVersion:
5531-
description: The rule's version number.
5549+
description: >
5550+
The rule's version number.
5551+
5552+
5553+
- For prebuilt rules it represents the version of the rule's content in
5554+
the source [detection-rules](https://github.com/elastic/detection-rules)
5555+
repository (and the corresponding `security_detection_engine` Fleet
5556+
package that is used for distributing prebuilt rules).
5557+
5558+
- For custom rules it is set to `1` when the rule is created.
5559+
5560+
> info
5561+
5562+
> It is not incremented on each update. Compare this to the `revision`
5563+
field.
55325564
minimum: 1
55335565
type: integer
55345566
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
@@ -4364,8 +4364,7 @@ components:
43644364
required_fields:
43654365
$ref: '#/components/schemas/RequiredFieldArray'
43664366
revision:
4367-
minimum: 0
4368-
type: integer
4367+
$ref: '#/components/schemas/RuleRevision'
43694368
rule_id:
43704369
$ref: '#/components/schemas/RuleSignatureId'
43714370
rule_source:
@@ -4754,6 +4753,25 @@ components:
47544753
- $ref: '#/components/schemas/EsqlRule'
47554754
discriminator:
47564755
propertyName: type
4756+
RuleRevision:
4757+
description: >
4758+
The rule's revision number.
4759+
4760+
4761+
It represents the version of rule's object in Kibana. It is set to `0`
4762+
when the rule is installed or created and then gets incremented on each
4763+
update.
4764+
4765+
> info
4766+
4767+
> Not all updates to any rule fields will increment the revision. Only
4768+
those fields that are considered static `rule parameters` can trigger
4769+
revision increments. For example, an update to a rule's query or index
4770+
fields will increment the rule's revision by `1`. However, changes to
4771+
dynamic or technical fields like enabled or execution_summary will not
4772+
cause revision increments.
4773+
minimum: 0
4774+
type: integer
47574775
RuleSignatureId:
47584776
description: Could be any string, not necessarily a UUID
47594777
type: string
@@ -4787,7 +4805,21 @@ components:
47874805
discriminator:
47884806
propertyName: type
47894807
RuleVersion:
4790-
description: The rule's version number.
4808+
description: >
4809+
The rule's version number.
4810+
4811+
4812+
- For prebuilt rules it represents the version of the rule's content in
4813+
the source [detection-rules](https://github.com/elastic/detection-rules)
4814+
repository (and the corresponding `security_detection_engine` Fleet
4815+
package that is used for distributing prebuilt rules).
4816+
4817+
- For custom rules it is set to `1` when the rule is created.
4818+
4819+
> info
4820+
4821+
> It is not incremented on each update. Compare this to the `revision`
4822+
field.
47914823
minimum: 1
47924824
type: integer
47934825
SavedObjectResolveAliasPurpose:

0 commit comments

Comments
 (0)