Repository navigation
refactor(exporters): type the embedded tag, ident and metadata field mappings - #58
Merged
Merged
Conversation
…mappings embedded_xml_tags, ident_from_list and metadata_from_config mappings are now variants of the field-mapping union with the keys the engine reads at every level: components (tag, sources with field, transform and separator, or content, not both); ident_spec (system_template, value_template, attributes with name, template and namespace_prefix); metadata_spec (root_element, namespace_prefix, allow_empty, group_by, group_element with element, attributes and item_element, whose children nest to any depth). Unknown keys are refused at every level, tag, element and attribute names are XML names, and namespace_prefix is one shared non-empty type. The untyped fallback is deleted. requires_post_processing keeps its hint on every structure and metadata_spec.namespace on the metadata spec. The exports are unchanged: the 28-file comparison is byte-identical. Refs: cis-bench-fh9l.6 Signed-off-by: Aaron Lippold <lippold@gmail.com>
A component with sources: [] is written as an empty tag, as one with content: "" is; the schema no longer refuses it. Refs: cis-bench-fh9l.6 Signed-off-by: Aaron Lippold <lippold@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types the last three field-mapping structures of an XCCDF style in
StyleConfig, so every field mapping is one of seven typed variants and the untyped fallback is gone.embedded_xml_tags:components, each atagwithsources(field,transform,separator) orcontent, not both (the engine never writes content beside sources);sources: []writes the tag empty, as before.ident_from_list:source_field,transform,ident_spec(system_template,value_template,attributeswithname,template,namespace_prefix).metadata_from_config:source_field,metadata_spec(root_element,namespace_prefix,allow_empty,group_by,group_elementwithelement,attributes,item_element, whosechildrennest to any depth).Unknown keys are refused at every level with the dotted path; tag, element and attribute names are XML names;
namespace_prefixis one shared non-empty type.requires_post_processingkeeps its hint on every structure andmetadata_spec.namespaceon the metadata spec. The engine still reads the style as dicts, and the checks that need the XCCDF or Benchmark models stay in the engine for a later card.Docs:
yaml-config-reference.md(required keys per structure, a component example that showed keys no component takes removed),xccdf-mapping-design.md(schema checks and engine checks listed separately).Verification on 980549b: 2785 tests passed,
tests/scripts53, mypy, ruff, format,mkdocs build --strict; 28 XCCDF exports (9 cached benchmarks and 5 synthetic fixtures, DISA and CIS) byte-identical to the exports before this change and valid.Card: cis-bench-fh9l.6