Skip to content

Fix gemara yaml output - #15306

Open
ggbecker wants to merge 4 commits into
ComplianceAsCode:masterfrom
ggbecker:fix/gemara-yaml-output
Open

ggbecker wants to merge 4 commits into
ComplianceAsCode:masterfrom
ggbecker:fix/gemara-yaml-output

Conversation

@ggbecker

@ggbecker ggbecker commented Nov 5, 2026

Copy link
Copy Markdown
Member

Description:

  • Adds the missing utils/nist_sync/gemara/yaml_output.py, which was imported but never committed in nist_sync: split ControlCatalogs by NIST family #15115, breaking the nist_sync scripts on a fresh checkout.
  • Adds a pull_request gate (gate_nist_sync.yml) that runs the NIST 800-53 → Gemara scripts end to end, so a broken script is caught before merge.

Rationale:

Review Hints:

  • Review commit by commit; the first commit is the fix, the rest harden the workflows (OSCAL download, import smoke-test, cue vet path fix, the new gate).
  • The gate uses in-Python --validate (no CUE pins) and hard-fails on any [WARN]/[ERROR]/FAIL, since the export itself only warns and exits 0.

Commit 8b37e9d replaced per-script ruamel.yaml configuration with a
shared configure_yaml() helper imported from gemara.yaml_output, but the
new module was never added to git. A fresh checkout, and therefore the
export-to-gemara workflow, fails with:

    ModuleNotFoundError: No module named 'gemara.yaml_output'

Add the module so export_to_gemara.py, generate_policies_pr.py,
generate_complyctl_bundle.py and test_gemara_export.py can import it.
The workflow reads --oscal-catalog and --data-dir files that are
gitignored (utils/nist_sync/.gitignore) and produced by download_oscal.py.
The sibling cis-nist-sync workflow runs that script; this one never did,
so the export silently skipped guidance_catalog.yaml and still exited 0.

Install requests (already listed in utils/nist_sync/requirements.txt) and
run the download step. Also import every nist_sync script before the
export, so a module that was never committed fails the job with a clear
message instead of a traceback from inside export_to_gemara.py (see
ComplianceAsCode#15115, where gemara/yaml_output.py was missing).
cue rejects an absolute package path, so cue_validate runs cue with
cwd=schema_dir. The artifact path was passed through unchanged, so a
relative --output-dir (as used by the export-to-gemara workflow) was
resolved inside the schema clone and every validation failed with
"stat <schema_dir>/build/gemara/...: no such file or directory".
Resolve the path first; CUE validation then passes for the control
catalogs and the guidance catalog.
The export-to-gemara workflow only runs on push to master and on a
schedule, so a broken nist_sync script (like the missing
gemara/yaml_output.py in ComplianceAsCode#15115) is invisible until after merge.

Add a PR-triggered gate that, on changes under utils/nist_sync/ or the
NIST 800-53 control files:
  - imports every script (--help) so a missing module fails fast,
  - runs the full export with --validate and fails on any [WARN]/[ERROR]/
    FAIL marker (the export itself only warns and exits 0),
  - runs the export test suite,
  - runs generate_complyctl_bundle.py and generate_policies_pr.py.

The gate uses the in-Python structural validation rather than CUE, so it
needs no external schema/binary pins; authoritative CUE validation stays
in export-to-gemara.yml.
@ggbecker ggbecker added this to the 0.1.83 milestone Nov 5, 2026
@openshift-ci

openshift-ci Bot commented Nov 5, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Nov 5, 2026
@vojtapolasek vojtapolasek self-assigned this Nov 9, 2026
@ggbecker
ggbecker marked this pull request as ready for review November 9, 2026 14:48
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Nov 9, 2026

@Mab879 Mab879 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the yaml lint errors.

- name: Generate a complyctl bundle
run: |
python3 utils/nist_sync/generate_complyctl_bundle.py \
--product rhel9 \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there rhel9 hardcoded here?

from ruamel.yaml import YAML


# The shared ComplyTime MegaLinter configuration extends yamllint's default

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment should be moved inside the function.

@vojtapolasek vojtapolasek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the yamllint failures and see my two small comments.

This branch has not been deployed

No deployments
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.

3 participants