Repository navigation
docs: publish the style file JSON Schema at docs build - #60
Merged
Merged
Conversation
A docs hook, scripts/mkdocs_style_schema.py, generates schemas/style.json
(JSON Schema Draft 2020-12) from StyleConfig in on_files as a generated
file, as the benchmark schema is published; no copy is committed. The
YAML config reference links it and shows how to point an editor at it
(yaml-language-server comment or yaml.schemas); the how-to for a new
style mentions it in its first step.
The shipped styles write rule_defaults.weight as text ("10.0"), which
StyleConfig accepted through lax float but its JSON Schema refused. The
model now declares weight as a number or decimal text, with one error
for neither, so the published schema accepts what the loader accepts.
Refs: cis-bench-fh9l.7
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.
Publishes the JSON Schema of a style file at docs build, generated from
StyleConfig, so a style author's editor can check a style file against the same schema cis-bench loads it with.scripts/mkdocs_style_schema.pyaddsschemas/style.json(JSON Schema Draft 2020-12, with the$schemakeyword) inon_filesas a generated file, the way the benchmark schema is published; nothing is committed. Wired inmkdocs.yml.yaml-config-reference.mdlinks it and shows the two ways to point an editor at it (a# yaml-language-server: $schema=...comment, oryaml.schemas); the how-to for a new style mentions it in step 1. The schema covers one file's keys and values; the checks that need the XCCDF and Benchmark models run when cis-bench loads the style.rule_defaults.weightas text ("10.0"), whichStyleConfigaccepted but its generated schema refused. The model now declares weight as a number or decimal text, with one error for neither, so the published schema accepts what the loader accepts. A boolean weight and text that is no decimal ("nan"," 10 ") are now refused; no style writes them.Verification: 2831 tests passed,
tests/scripts53, mypy, ruff, format,mkdocs build --strict; 28 XCCDF exports byte-identical to the exports before this change and valid.Card: cis-bench-fh9l.7