Skip to content

Commit

Permalink
Fix bug with subsets and reusable fields (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallmain authored Apr 7, 2020
1 parent f4d5491 commit 3343b7f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Thanks, you're awesome :-) -->

#### Bugfixes

* Subsets are created after duplicating reusable fields now so subsets can
be applied to each reused instance independently. #753
* Quoted the example for `labels` to avoid YAML interpreting it, and having
slightly different results in different situations. #782
* Fix incorrect listing of where field sets are nested in asciidoc,
Expand Down
2 changes: 0 additions & 2 deletions generated/ecs/ecs_flat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5106,7 +5106,6 @@ pe.architecture:
name: architecture
normalize: []
order: 6
original_fieldset: pe
short: CPU architecture target for the file.
type: keyword
pe.company:
Expand Down Expand Up @@ -5159,7 +5158,6 @@ pe.imphash:
name: imphash
normalize: []
order: 5
original_fieldset: pe
short: A hash of the imports in a PE file.
type: keyword
pe.original_file_name:
Expand Down
2 changes: 2 additions & 0 deletions scripts/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def main():
intermediate_custom = schema_reader.load_schemas(include_glob)
schema_reader.merge_schema_fields(intermediate_fields, intermediate_custom)

schema_reader.assemble_reusables(intermediate_fields)

if args.subset:
subset = {}
for arg in args.subset:
Expand Down
5 changes: 2 additions & 3 deletions scripts/schema_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@ def assemble_reusables(fields_nested):
# fields array replaced with a fields dictionary.
for schema_name in fields_nested:
schema = fields_nested[schema_name]

duplicate_reusable_fieldsets(schema, fields_nested)

cleanup_fields_recursive(fields_nested, "")


def flatten_fields(fields, key_prefix):
flat_fields = {}
Expand Down Expand Up @@ -270,8 +271,6 @@ def load_schemas(files=ecs_files()):


def generate_nested_flat(fields_intermediate):
assemble_reusables(fields_intermediate)
cleanup_fields_recursive(fields_intermediate, "")
for field_name, field in fields_intermediate.items():
nestings = find_nestings(field['fields'], field_name + ".")
nestings.sort()
Expand Down
5 changes: 3 additions & 2 deletions scripts/tests/test_ecs_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

from scripts import schema_reader


(nested, flat) = schema_reader.generate_nested_flat(schema_reader.load_schemas())
schemas = schema_reader.load_schemas()
schema_reader.assemble_reusables(schemas)
(nested, flat) = schema_reader.generate_nested_flat(schemas)


class TestEcsSpec(unittest.TestCase):
Expand Down

0 comments on commit 3343b7f

Please sign in to comment.