Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CPLYTM-559 - massage cac data into oscal format #456

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions trestlebot/tasks/sync_cac_catalog_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ def _sync_catalog(
# 2. find the correct place in oscal
# 2a. find the group
group = None
# Warning: the line below is only compatible with pydantic 1
# and will need to be updated if trestle updates to pydantic 2
if Group.__fields__["id"].type_.regex.match(group_id) is None:
group_id = f"{policy.id}_{group_id}"
for g in oscal_catalog.groups:
if g.id == group_id:
group = g
Expand Down Expand Up @@ -206,9 +210,12 @@ def _sync_catalog(
found = True
break
if not found:
raise ValueError(
"Nested control path before parent control definition"
)
# insert an empty parent control
control = generate_sample_model(Control)
control.controls = []
control.id = parent_id
parent.controls.append(control)
parent = control
# 4. Find the associated oscal control to the cac control
# 4a. Map the cac control onto a new oscal control
new_control = control_cac_to_oscal(
Expand Down