Skip to content

Commit a9da38f

Browse files
committed
Add example value composite type checking (elastic#966)
# Conflicts: # generated/csv/fields.csv
1 parent e6ba4c4 commit a9da38f

File tree

13 files changed

+120
-99
lines changed

13 files changed

+120
-99
lines changed

CHANGELOG.next.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Thanks, you're awesome :-) -->
3838
#### Added
3939

4040
* Introduced `--strict` flag to perform stricter schema validation when running the generator script. #937
41+
* Added check under `--strict` that ensures composite types in example fields are quoted. #966
4142

4243
#### Improvements
4344

USAGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ $ python/generator.py --strict
308308
Strict mode requires the following conditions, else the script exits on an exception:
309309

310310
* Short descriptions must be less than or equal to 120 characters.
311+
* Example values containing arrays or objects must be quoted to avoid unexpected YAML interpretation when the schema files or artifacts are relied on downstream.
311312

312313
The current artifacts generated and published in the ECS repo will always be created using strict mode. However, older ECS versions (pre `v1.5.0`) will cause
313314
an exception if attempting to generate them using `--strict`. This is due to schema validation checks introduced after that version was released.

docs/field-details.asciidoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ Note: this field should contain an array of values.
12111211

12121212

12131213

1214-
example: `['RD', 'RA']`
1214+
example: `["RD", "RA"]`
12151215

12161216
| extended
12171217

@@ -1343,7 +1343,7 @@ Note: this field should contain an array of values.
13431343

13441344

13451345

1346-
example: `['10.10.10.10', '10.10.10.11']`
1346+
example: `["10.10.10.10", "10.10.10.11"]`
13471347

13481348
| extended
13491349

@@ -4205,7 +4205,7 @@ Note: this field should contain an array of values.
42054205

42064206

42074207

4208-
example: `['/usr/bin/ssh', '-l', 'user', '10.0.0.16']`
4208+
example: `["/usr/bin/ssh", "-l", "user", "10.0.0.16"]`
42094209

42104210
| extended
42114211

@@ -4718,7 +4718,7 @@ Note: this field should contain an array of values.
47184718

47194719

47204720

4721-
example: `['Star-Lord']`
4721+
example: `["Star-Lord"]`
47224722

47234723
| extended
47244724

@@ -5624,7 +5624,7 @@ Note: this field should contain an array of values.
56245624

56255625

56265626

5627-
example: `['MII...', 'MII...']`
5627+
example: `["MII...", "MII..."]`
56285628

56295629
| extended
56305630

@@ -5757,7 +5757,7 @@ Note: this field should contain an array of values.
57575757

57585758

57595759

5760-
example: `['TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', '...']`
5760+
example: `["TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "..."]`
57615761

57625762
| extended
57635763

@@ -5838,7 +5838,7 @@ Note: this field should contain an array of values.
58385838

58395839

58405840

5841-
example: `['MII...', 'MII...']`
5841+
example: `["MII...", "MII..."]`
58425842

58435843
| extended
58445844

generated/beats/fields.ecs.yml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,7 @@
10131013
description: 'Array of 2 letter DNS header flags.
10141014
10151015
Expected values are: AA, TC, RD, RA, AD, CD, DO.'
1016-
example:
1017-
- RD
1018-
- RA
1016+
example: '["RD", "RA"]'
10191017
- name: id
10201018
level: extended
10211019
type: keyword
@@ -1096,9 +1094,7 @@
10961094
formats it can contain. Extracting all IP addresses seen in there to `dns.resolved_ip`
10971095
makes it possible to index them as IP addresses, and makes them easier to
10981096
visualize and query for.'
1099-
example:
1100-
- 10.10.10.10
1101-
- 10.10.10.11
1097+
example: '["10.10.10.10", "10.10.10.11"]'
11021098
- name: response_code
11031099
level: extended
11041100
type: keyword
@@ -3229,11 +3225,7 @@
32293225
the executable.
32303226
32313227
May be filtered to protect sensitive information.'
3232-
example:
3233-
- /usr/bin/ssh
3234-
- -l
3235-
- user
3236-
- 10.0.0.16
3228+
example: '["/usr/bin/ssh", "-l", "user", "10.0.0.16"]'
32373229
- name: args_count
32383230
level: extended
32393231
type: long
@@ -3376,11 +3368,7 @@
33763368
the executable.
33773369
33783370
May be filtered to protect sensitive information.'
3379-
example:
3380-
- /usr/bin/ssh
3381-
- -l
3382-
- user
3383-
- 10.0.0.16
3371+
example: '["/usr/bin/ssh", "-l", "user", "10.0.0.16"]'
33843372
default_field: false
33853373
- name: parent.args_count
33863374
level: extended
@@ -3884,8 +3872,7 @@
38843872
ignore_above: 1024
38853873
description: Name, organization, or pseudonym of the author or authors who created
38863874
the rule used to generate this event.
3887-
example:
3888-
- Star-Lord
3875+
example: '["Star-Lord"]'
38893876
default_field: false
38903877
- name: category
38913878
level: extended
@@ -4652,9 +4639,7 @@
46524639
description: Array of PEM-encoded certificates that make up the certificate
46534640
chain offered by the client. This is usually mutually-exclusive of `client.certificate`
46544641
since that value should be the first certificate in the chain.
4655-
example:
4656-
- MII...
4657-
- MII...
4642+
example: '["MII...", "MII..."]'
46584643
default_field: false
46594644
- name: client.hash.md5
46604645
level: extended
@@ -4735,10 +4720,8 @@
47354720
type: keyword
47364721
ignore_above: 1024
47374722
description: Array of ciphers offered by the client during the client hello.
4738-
example:
4739-
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
4740-
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
4741-
- '...'
4723+
example: '["TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
4724+
"..."]'
47424725
default_field: false
47434726
- name: client.x509.alternative_names
47444727
level: extended
@@ -4955,9 +4938,7 @@
49554938
description: Array of PEM-encoded certificates that make up the certificate
49564939
chain offered by the server. This is usually mutually-exclusive of `server.certificate`
49574940
since that value should be the first certificate in the chain.
4958-
example:
4959-
- MII...
4960-
- MII...
4941+
example: '["MII...", "MII..."]'
49614942
default_field: false
49624943
- name: server.hash.md5
49634944
level: extended

generated/ecs/ecs_flat.yml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,9 +1384,7 @@ dns.header_flags:
13841384
description: 'Array of 2 letter DNS header flags.
13851385
13861386
Expected values are: AA, TC, RD, RA, AD, CD, DO.'
1387-
example:
1388-
- RD
1389-
- RA
1387+
example: '["RD", "RA"]'
13901388
flat_name: dns.header_flags
13911389
ignore_above: 1024
13921390
level: extended
@@ -1514,9 +1512,7 @@ dns.resolved_ip:
15141512
it can contain. Extracting all IP addresses seen in there to `dns.resolved_ip`
15151513
makes it possible to index them as IP addresses, and makes them easier to visualize
15161514
and query for.'
1517-
example:
1518-
- 10.10.10.10
1519-
- 10.10.10.11
1515+
example: '["10.10.10.10", "10.10.10.11"]'
15201516
flat_name: dns.resolved_ip
15211517
level: extended
15221518
name: resolved_ip
@@ -4777,11 +4773,7 @@ process.args:
47774773
executable.
47784774
47794775
May be filtered to protect sensitive information.'
4780-
example:
4781-
- /usr/bin/ssh
4782-
- -l
4783-
- user
4784-
- 10.0.0.16
4776+
example: '["/usr/bin/ssh", "-l", "user", "10.0.0.16"]'
47854777
flat_name: process.args
47864778
ignore_above: 1024
47874779
level: extended
@@ -5007,11 +4999,7 @@ process.parent.args:
50074999
executable.
50085000
50095001
May be filtered to protect sensitive information.'
5010-
example:
5011-
- /usr/bin/ssh
5012-
- -l
5013-
- user
5014-
- 10.0.0.16
5002+
example: '["/usr/bin/ssh", "-l", "user", "10.0.0.16"]'
50155003
flat_name: process.parent.args
50165004
ignore_above: 1024
50175005
level: extended
@@ -5778,8 +5766,7 @@ rule.author:
57785766
dashed_name: rule-author
57795767
description: Name, organization, or pseudonym of the author or authors who created
57805768
the rule used to generate this event.
5781-
example:
5782-
- Star-Lord
5769+
example: '["Star-Lord"]'
57835770
flat_name: rule.author
57845771
ignore_above: 1024
57855772
level: extended
@@ -6998,9 +6985,7 @@ tls.client.certificate_chain:
69986985
description: Array of PEM-encoded certificates that make up the certificate chain
69996986
offered by the client. This is usually mutually-exclusive of `client.certificate`
70006987
since that value should be the first certificate in the chain.
7001-
example:
7002-
- MII...
7003-
- MII...
6988+
example: '["MII...", "MII..."]'
70046989
flat_name: tls.client.certificate_chain
70056990
ignore_above: 1024
70066991
level: extended
@@ -7126,10 +7111,8 @@ tls.client.subject:
71267111
tls.client.supported_ciphers:
71277112
dashed_name: tls-client-supported-ciphers
71287113
description: Array of ciphers offered by the client during the client hello.
7129-
example:
7130-
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
7131-
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
7132-
- '...'
7114+
example: '["TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
7115+
"..."]'
71337116
flat_name: tls.client.supported_ciphers
71347117
ignore_above: 1024
71357118
level: extended
@@ -7508,9 +7491,7 @@ tls.server.certificate_chain:
75087491
description: Array of PEM-encoded certificates that make up the certificate chain
75097492
offered by the server. This is usually mutually-exclusive of `server.certificate`
75107493
since that value should be the first certificate in the chain.
7511-
example:
7512-
- MII...
7513-
- MII...
7494+
example: '["MII...", "MII..."]'
75147495
flat_name: tls.server.certificate_chain
75157496
ignore_above: 1024
75167497
level: extended

generated/ecs/ecs_nested.yml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,9 +1735,7 @@ dns:
17351735
description: 'Array of 2 letter DNS header flags.
17361736
17371737
Expected values are: AA, TC, RD, RA, AD, CD, DO.'
1738-
example:
1739-
- RD
1740-
- RA
1738+
example: '["RD", "RA"]'
17411739
flat_name: dns.header_flags
17421740
ignore_above: 1024
17431741
level: extended
@@ -1866,9 +1864,7 @@ dns:
18661864
formats it can contain. Extracting all IP addresses seen in there to `dns.resolved_ip`
18671865
makes it possible to index them as IP addresses, and makes them easier to
18681866
visualize and query for.'
1869-
example:
1870-
- 10.10.10.10
1871-
- 10.10.10.11
1867+
example: '["10.10.10.10", "10.10.10.11"]'
18721868
flat_name: dns.resolved_ip
18731869
level: extended
18741870
name: resolved_ip
@@ -5824,11 +5820,7 @@ process:
58245820
the executable.
58255821
58265822
May be filtered to protect sensitive information.'
5827-
example:
5828-
- /usr/bin/ssh
5829-
- -l
5830-
- user
5831-
- 10.0.0.16
5823+
example: '["/usr/bin/ssh", "-l", "user", "10.0.0.16"]'
58325824
flat_name: process.args
58335825
ignore_above: 1024
58345826
level: extended
@@ -6054,11 +6046,7 @@ process:
60546046
the executable.
60556047
60566048
May be filtered to protect sensitive information.'
6057-
example:
6058-
- /usr/bin/ssh
6059-
- -l
6060-
- user
6061-
- 10.0.0.16
6049+
example: '["/usr/bin/ssh", "-l", "user", "10.0.0.16"]'
60626050
flat_name: process.parent.args
60636051
ignore_above: 1024
60646052
level: extended
@@ -6890,8 +6878,7 @@ rule:
68906878
dashed_name: rule-author
68916879
description: Name, organization, or pseudonym of the author or authors who created
68926880
the rule used to generate this event.
6893-
example:
6894-
- Star-Lord
6881+
example: '["Star-Lord"]'
68956882
flat_name: rule.author
68966883
ignore_above: 1024
68976884
level: extended
@@ -8193,9 +8180,7 @@ tls:
81938180
description: Array of PEM-encoded certificates that make up the certificate
81948181
chain offered by the client. This is usually mutually-exclusive of `client.certificate`
81958182
since that value should be the first certificate in the chain.
8196-
example:
8197-
- MII...
8198-
- MII...
8183+
example: '["MII...", "MII..."]'
81998184
flat_name: tls.client.certificate_chain
82008185
ignore_above: 1024
82018186
level: extended
@@ -8324,10 +8309,8 @@ tls:
83248309
tls.client.supported_ciphers:
83258310
dashed_name: tls-client-supported-ciphers
83268311
description: Array of ciphers offered by the client during the client hello.
8327-
example:
8328-
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
8329-
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
8330-
- '...'
8312+
example: '["TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
8313+
"..."]'
83318314
flat_name: tls.client.supported_ciphers
83328315
ignore_above: 1024
83338316
level: extended
@@ -8706,9 +8689,7 @@ tls:
87068689
description: Array of PEM-encoded certificates that make up the certificate
87078690
chain offered by the server. This is usually mutually-exclusive of `server.certificate`
87088691
since that value should be the first certificate in the chain.
8709-
example:
8710-
- MII...
8711-
- MII...
8692+
example: '["MII...", "MII..."]'
87128693
flat_name: tls.server.certificate_chain
87138694
ignore_above: 1024
87148695
level: extended

schemas/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ Supported keys to describe fields
125125
Defaults to the main description when absent.
126126
If the main description has multiple paragraphs, then a 'short' description
127127
with no newlines is required.
128-
- example (optional): A single value example of what can be expected in this field
128+
- example (optional): A single value example of what can be expected in this field.
129+
Example values that are composite types (array, object) should be quoted to avoid YAML interpretation
130+
in ECS-generated artifacts and other downstream projects depending on the schema.
129131
- multi\_fields (optional): Specify additional ways to index the field.
130132
- index (optional): If `False`, means field is not indexed (overrides type)
131133
- format: Field format that can be used in a Kibana index template.

schemas/dns.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
Array of 2 letter DNS header flags.
5555
5656
Expected values are: AA, TC, RD, RA, AD, CD, DO.
57-
example: [RD, RA]
57+
example: "[\"RD\", \"RA\"]"
5858
normalize:
5959
- array
6060

@@ -205,6 +205,6 @@
205205
data formats it can contain. Extracting all IP addresses seen in there to
206206
`dns.resolved_ip` makes it possible to index them as IP addresses, and
207207
makes them easier to visualize and query for.
208-
example: [10.10.10.10, 10.10.10.11]
208+
example: '["10.10.10.10", "10.10.10.11"]'
209209
normalize:
210210
- array

schemas/process.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
Array of process arguments, starting with the absolute path to the executable.
9393
9494
May be filtered to protect sensitive information.
95-
example: ["/usr/bin/ssh", "-l", "user", "10.0.0.16"]
95+
example: "[\"/usr/bin/ssh\", \"-l\", \"user\", \"10.0.0.16\"]"
9696
normalize:
9797
- array
9898

0 commit comments

Comments
 (0)