Skip to content

nist_sync: export NIST 800-53 Rev 5 controls to Gemara format #14797

Draft
ggbecker wants to merge 2 commits into
ComplianceAsCode:masterfrom
ggbecker:gemara
Draft

nist_sync: export NIST 800-53 Rev 5 controls to Gemara format #14797
ggbecker wants to merge 2 commits into
ComplianceAsCode:masterfrom
ggbecker:gemara

Conversation

@ggbecker

Copy link
Copy Markdown
Member

Description:

  • Adds utils/nist_sync/export_to_gemara.py to export ComplianceAsCode NIST 800-53 Rev 5 control files (rhel8/9/10) to three Gemara artifact types per product: GuidanceCatalog (abstract NIST standard text from OSCAL), ControlCatalog (NIST controls → XCCDF rule IDs), and MappingDocument (NIST↔rule traceability). All artifacts pass CUE schema validation against Gemara 1.1.0.

  • Adds generate_complyctl_bundle.py to package the output as a complyctl-compatible OCI bundle and test_complyctl_e2e.sh to run complyctl get/generate/scan against RHEL9 content in a UBI9 container.

  • Adds .github/workflows/export-to-gemara.yml to run the export and CUE validation on CI whenever NIST control files or export tooling change.

  • Restructures NIST 800-53 control files to nest enhancements (e.g., ac-7.1) under their base control (ac-7) across rhel8/9/10, and updates the HTML viewer to display the nested hierarchy.

Rationale:

  • ComplianceAsCode's knowledge of which rules implement each NIST control is locked in an internal YAML format. Exporting it to Gemara makes it machine-readable by any Gemara-compatible tool (complyctl, compliance-operator), enabling NIST-derived profile generation, gap analysis, and control-level compliance reporting.

Review Hints:

  • Quick validation (no build needed):

    source .pyenv.sh
    PYTHONPATH=. python3 utils/nist_sync/export_to_gemara.py --products rhel8,rhel9,rhel10
    PYTHONPATH=. python3 utils/nist_sync/test_gemara_export.py
    # Expected: 87 passed, 0 failed
  • The nested control structure change affects all family YAML files under products/{rhel8,rhel9,rhel10}/controls/nist_800_53/ — review ac.yml in any product to see the before/after format.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Jun 12, 2026
@openshift-ci

openshift-ci Bot commented Jun 12, 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 needs-rebase Used by openshift-ci bot. label Jun 12, 2026
ggbecker added 2 commits June 12, 2026 14:44
Implements OPENSCAP-6801. Adds tooling to export ComplianceAsCode NIST
800-53 Rev 5 control files (rhel8/9/10) to three Gemara artifact types:

GuidanceCatalog (utils/nist_sync/gemara/guidance.py)
  Abstract NIST 800-53 standard layer built from the OSCAL catalog at
  utils/nist_sync/data/nist_800_53_rev5_catalog.json. Includes official
  control statement prose (with parameter substitution) as objectives,
  OSCAL guidance prose as rationale, and baseline applicability (low,
  moderate, high) from the three baseline JSON files.

ControlCatalog (utils/nist_sync/gemara/catalog.py)
  Per-product: maps 1,196 NIST controls to XCCDF rule IDs as assessment
  requirements. NIST families become groups; baselines become applicability-
  groups. CaC control status maps to Gemara lifecycle states.

MappingDocument (utils/nist_sync/gemara/mapping.py)
  Per-product: bidirectional traceability between NIST control IDs and
  ComplianceAsCode rule IDs with relationship type, strength, and
  confidence level derived from the CaC control status.

All three artifact types pass CUE schema validation against the Gemara
1.1.0 schema (cue vet).

Supporting files:
  gemara/status_map.py  - CaC status → Gemara state/relationship/confidence
  gemara/schema.py      - schema constants and structural validators
  export_to_gemara.py   - CLI: --products, --validate, --gemara-schema, --no-guidance
  test_gemara_export.py - 87-test suite: structure, cross-references, accuracy
  generate_complyctl_bundle.py - OCI bundle generator for complyctl testing
  test_complyctl_e2e.sh - E2E test in UBI9 container against RHEL9 data stream
  .github/workflows/export-to-gemara.yml - CI on NIST control/script changes
…ibility

Three root causes were found by reading the complytime-providers source code
and inspecting provider gRPC logs:

1. Assessment-plan id must equal requirement-id
   go-gemara v0.0.1 populates AssessmentConfiguration.RequirementID from the
   plan 'id' field, not 'requirement-id'. The 'ap-' prefix we added made the
   id (e.g. 'ap-accounts_tmout') not match any data stream rule. Fix: use the
   short CaC rule name as both id and requirement-id.

2. requirement-id must be the short CaC rule name (no XCCDF prefix)
   filterValidRules() strips 'xccdf_org.ssgproject.content_rule_' from data
   stream rule IDs before comparing. Passing full XCCDF IDs caused no match.

3. 'datastream' target variable bypasses OS auto-detection
   On UBI9, ID_LIKE=fedora causes the provider to pick ssg-fedora-ds.xml
   before ssg-rhel9-ds.xml (alphabetical filesystem walk). Setting the
   'datastream' variable in complytime.yaml targets the correct product data
   stream directly without overriding /etc/os-release.

Also updates test_complyctl_e2e.sh to reflect the correct setup: no
/etc/os-release override needed, uses 'datastream' variable and 'cis' as
the XCCDF tailoring base profile (covers all 22 NIST 800-53 moderate rules).

Verified end-to-end in a UBI9 container against ssg-rhel9-ds.xml:
  complyctl get    → bundle synced
  complyctl generate → tailoring.xml created (22 requirements)
  complyctl scan   → 3 passed, 1 failed (configure_custom_crypto_policy_cis)
  Results: arf.xml + evaluation-log written to /results/
@openshift-ci openshift-ci Bot removed the needs-rebase Used by openshift-ci bot. label Jun 12, 2026
@ggbecker ggbecker added this to the 0.1.82 milestone Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant