Skip to content

refactor(exporters): type the embedded tag, ident and metadata field mappings - #58

Merged
aaronlippold merged 2 commits into
nextfrom
refactor/fh9l6-typed-xml-mappings
Nov 19, 2026
Merged

aaronlippold merged 2 commits into
nextfrom
refactor/fh9l6-typed-xml-mappings

Conversation

@aaronlippold

Copy link
Copy Markdown
Member

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 a tag with sources (field, transform, separator) or content, 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, attributes with name, template, namespace_prefix).
  • metadata_from_config: source_field, metadata_spec (root_element, namespace_prefix, allow_empty, group_by, group_element with element, attributes, item_element, whose children nest to any depth).

Unknown keys are refused at every level with the dotted path; tag, element and attribute names are XML names; namespace_prefix is one shared non-empty type. requires_post_processing keeps its hint on every structure and metadata_spec.namespace on 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/scripts 53, 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

…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>
@aaronlippold
aaronlippold merged commit a92b12c into next Nov 19, 2026
7 checks passed
@aaronlippold
aaronlippold deleted the refactor/fh9l6-typed-xml-mappings branch November 19, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant