Skip to content

sync update to oscal content#6

Closed
huiwangredhat wants to merge 8 commits intomasterfrom
sync_update_to_oscal_content
Closed

sync update to oscal content#6
huiwangredhat wants to merge 8 commits intomasterfrom
sync_update_to_oscal_content

Conversation

@huiwangredhat
Copy link
Copy Markdown

@huiwangredhat huiwangredhat commented Apr 3, 2025

Description:

Add the workflow to sync the CAC content to OSCAL content

Rationale:

  • Fixes CPLYTM-627

Review Hints:

This CI/CD relates to several repos:
CAC content
OSCAL content
Trestlebot
Content_test_filtering
The steps of syncing CAC to OSCAL.

  • If the PR comes from OSCAL content, it will skip the following actions to avoid unnecessary loops.
  • Detect the CAC content update via content-test-filtering PR
  • If the PR has some profiles and controls updates that will impact the OSCAL content, it will run the following actions
  • Set up the trestle-bot environment, cac-content, oscal-content
  • Get the github app installation access token of oscal-content
  • Get the mapping of the control, cac profile, oscal profile for each product
  • Parse the CAC content update to the inputs of the trestle-bot sync-cac-content CLI and sync the content and push the update to OSCAL content.
  • Create PR to oscal-content

I listed my questions:
(It‘s out of date, but they are the reason to the step(Get the mapping of the control, cac profile, oscal profile for each product))

  • When the pr has a control update, how to map which --cac-profile and --oscal-profile the component-definition will use? My thought: get mapping of the control, cac profile, oscal profile via a python script(shell is a little bit tricky).
  • When the pr has a profile update, how to define the --oscal-profile the component-definition will use? (The --oscal-profile is $$policy_id_level). My thought: Sync all the profiles for the Red Hat products to the OSCAL content first. Get a map of product profile and the oscal profile mapping.
  • I created a PR to get the profiles, control files, and levels mapping. We could use this mapping to sync related component definitions.

Additional info:
Run details:

Note, all the syncs base on the inited the catalogs and profiles which are stored on the oscal-content side. The initial should be done after the stories: https://issues.redhat.com/browse/CPLYTM-702, what could tag the profiles for each product; https://issues.redhat.com/browse/CPLYTM-644 which component-definition is removing ANSSI and including CIS

{"rules": ["dconf_gnome_enable_smartcard_auth", "dconf_gnome_disable_ctrlaltdel_reboot"], "product": "rhel8", "bash": "True", "ansible": "True"} {"profiles": ["anssi_bp28_enhanced", "anssi_bp28_high", "default", "hipaa"], "product": "rhel10"} {"profiles": ["default", "hipaa", "ospp", "cui"], "product": "rhel9"} {"profiles": ["stig-v1r1"], "product": "ocp4"} {"controls": ["anssi.yml", "section-1.yml", "SRG-OS-000080-GPOS-00048.yml"]}

@marcusburghardt
Copy link
Copy Markdown

When the pr has a control update, how to map which --cac-profile and --oscal-profile the component-definition will use? My thought: get mapping of the control, cac profile, oscal profile via a python script(shell is a little bit tricky).

I agree that using a Python script could be simpler. In CaC multiple profiles can use the same control file, so the approach would be to resolve the profiles to determine which of them are impacted by the control file change. The profile ID on both sides should be the equivalent, so once knowing which profiles in CaC are impacted, it should not be a problem to locate the equivalent profiles in OSCAL.

When the pr has a profile update, how to define the --oscal-profile the component-definition will use? (The --oscal-profile is $$policy_id_level). My thought: Sync all the profiles for the Red Hat products to the OSCAL content first. Get a map of product profile and the oscal profile mapping.

I think it is a good approach.

Copy link
Copy Markdown

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

@huiwangredhat , I know it is still in draft, but already provided some initial comments.

on:
pull_request:
types:
- closed
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just to confirm, this is only for testing, right? The final version should execute the test whenever a PR is opened.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The final version should execute the test when a PR is merged with the master. That means the updates are in master, which will trigger the accurate detection of the updates. Then sync the CAC updates to OSCAL content. Due to this PR is still in test stage, I'd like to update it with workflow_dispatch and comment the lines of the current trigger condition.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I see. I wonder if it would not be valid to have preliminary tests (without actually syncing) when a PR is opened. That way, the author and reviewers have time to check and fix any possible issue in an earlier stage. Then when the PR is merged, synchronization issues would be less expected. But this is something that we can definitely discuss later and easily change if necessary. No worries for now. : )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@marcusburghardt, I think using PR incremental updates to sync OSCAL content is expected, but there seem to be some issues.
Problem with the Current Filter:
The filter currently checks all updates based on one PR, rather than just the incremental changes per push. This can cause synchronization chaos.
Example Scenario:
A first push in a CAC PR modifies control-file-A.
This triggers a sync PR to update OSCAL content with related changes.
Later, the CAC PR reverts the change to control-file-A.
The component-test-filter detects no changes, so no OSCAL sync occurs.
If the CAC PR is merged into master without changes to control-file-A, but the OSCAL PR still includes updates for it, the result is inconsistent.

I tried to use the latest commit and the parent commit to detect the incremental updates of CAC content, but the author of the CAC PR may push multiple commits at once. This method fails to capture all changes for each push.

Do you have any idea? Or it's acceptable to use the pr closed as the trigger condition I mentioned above?

Comment thread .github/workflows/sync_updates_to_oscal_content.yml Outdated
Comment thread .github/workflows/sync_updates_to_oscal_content.yml Outdated
Comment thread .github/workflows/sync_updates_to_oscal_content.yml Outdated
@huiwangredhat
Copy link
Copy Markdown
Author

@marcusburghardt Thanks for your feedback and suggestions. I will update this PR according to your comments tomorrow. BTW, today I created a PR in trestlebot to get the mapping of profile, the available control file, and the levels. I am going to update the component definitions according to the mapping I got from the PR.

@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch 4 times, most recently from 75e1fd4 to bd71a21 Compare April 11, 2025 09:34
@huiwangredhat huiwangredhat marked this pull request as ready for review April 11, 2025 10:02
@jpower432 jpower432 requested a review from d10n April 14, 2025 13:20
@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch 3 times, most recently from ca11007 to 82722e5 Compare April 15, 2025 10:47
Signed-off-by: Sophia Wang <huiwang@redhat.com>
@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch 2 times, most recently from 1dd3f0c to da5b763 Compare April 15, 2025 11:57
@huiwangredhat huiwangredhat requested review from AlexXuan233 and hbraswelrh and removed request for hbraswelrh April 16, 2025 12:30
@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch 12 times, most recently from 24b2612 to fa1d9b8 Compare April 17, 2025 10:29
@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch 5 times, most recently from 2a55a7b to 4313365 Compare April 21, 2025 01:45
@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch 3 times, most recently from 1943f02 to b0be30c Compare April 21, 2025 10:31
Signed-off-by: Sophia Wang <huiwang@redhat.com>
@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch from b0be30c to a38fce9 Compare April 21, 2025 10:57
@d10n
Copy link
Copy Markdown

d10n commented Apr 23, 2025

A general comment, in workflows, the gh command is available and might be able to clean up some of the setup and header boilerplate: https://cli.github.com/manual/gh_pr

@jflowers jflowers requested a review from hbraswelrh April 23, 2025 13:01
@huiwangredhat
Copy link
Copy Markdown
Author

A general comment, in workflows, the gh command is available and might be able to clean up some of the setup and header boilerplate: https://cli.github.com/manual/gh_pr

@d10n Thanks for your feedback. I replaced curl with gh except for getting the token part that can't work in gh.

@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch 2 times, most recently from b020481 to 76462bd Compare April 24, 2025 11:22
Signed-off-by: Sophia Wang <huiwang@redhat.com>
@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch from 76462bd to 14db139 Compare April 24, 2025 11:23
Comment thread .github/workflows/sync_updates_to_oscal_content.yml Dismissed
Comment thread .github/workflows/sync_updates_to_oscal_content.yml Dismissed
Signed-off-by: Sophia Wang <huiwang@redhat.com>
@huiwangredhat huiwangredhat force-pushed the sync_update_to_oscal_content branch from d1dbfa5 to 0d02c25 Compare May 6, 2025 11:58
@hbraswelrh
Copy link
Copy Markdown

@huiwangredhat I have tested the syncing updates to oscal-content with:

  1. PR#20 in oscal-content which triggered the auto-generated PR Auto-generated PR from OSCAL content 20 #16
  2. PR #17 in oscal-content which triggered the auto-generated PR Auto-generated PR from OSCAL content 17 #13

The functionality does not change original CaC/content, but opens the PRs based on those changes identified in the oscal-content repo. I also tested using the content_test_filtering repo.

Copy link
Copy Markdown

@hbraswelrh hbraswelrh left a comment

Choose a reason for hiding this comment

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

@huiwangredhat I tested this PR by including the .github/workflows/sync_updates_to_oscal_content.yml and deleting a rule in cis_rhel8.yml.

I created a new branch (test/hannah-oscal-629) and copied the workflow file from the sync_update_to_oscal_content branch. PR #19 detected the cac-content updates and opened PR #22 in oscal-content.

Therefore, this PR works as expected.

@huiwangredhat
Copy link
Copy Markdown
Author

Close this PR and will sync the workflow after the merge of ComplianceAsCode#13512

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.

5 participants