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

Add Script to Import DISA STIG to Policy Specific Content #11611

Merged

Conversation

Mab879
Copy link
Member

@Mab879 Mab879 commented Feb 20, 2024

Description:

This PR adds a script that takes the SRG Requirement, Fix text, check text, and Vulnerability discussion from the DISA STIG XML files and imports them to the Policy Specific Content (PSC) files.

Rationale:

Help prep for the next STIG.

Review Hints:

$ ./utils/import_disa_stig.py --product rhel9 --control stig_rhel9 shared/references/disa-stig-rhel9-v1r2-xccdf-manual.xml

Observe that under the rules used by the STIG the PSC content is updated.

@Mab879 Mab879 added Infrastructure Our content build system STIG STIG Benchmark related. labels Feb 20, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Feb 20, 2024
Copy link

openshift-ci bot commented Feb 20, 2024

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

Copy link

Start a new ephemeral environment with changes proposed in this pull request:

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Copy link

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:11611

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:11611

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:11611 make deploy-local

@Mab879 Mab879 force-pushed the import_disa_changes_to_policy branch from 5f3acdb to 069969e Compare February 21, 2024 19:04
@Mab879 Mab879 marked this pull request as ready for review February 21, 2024 22:32
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Feb 21, 2024
@jan-cerny
Copy link
Collaborator

/packit build

@jan-cerny jan-cerny self-assigned this Feb 23, 2024
@jan-cerny jan-cerny added this to the 0.1.73 milestone Feb 23, 2024
utils/import_disa_stig.py Outdated Show resolved Hide resolved
rule_dir_json = get_rule_dir_json(args.json)
srgs = ssg.build_stig.parse_srgs(stig_filename)

for stig_id, stig_rule in srgs.items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest splitting the main function to multiple smaller functions to improve code complexity.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have cleaned up the main method a bit, but moving the code the edits the file results in very ugly method signatures.

utils/import_disa_stig.py Outdated Show resolved Hide resolved
utils/srg_utils/__init__.py Outdated Show resolved Hide resolved
utils/import_disa_stig.py Outdated Show resolved Hide resolved
Copy link

codeclimate bot commented Feb 26, 2024

Code Climate has analyzed commit f50aaa1 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 33.3% (50% is the threshold).

This pull request will bring the total coverage in the repository to 58.3% (0.1% change).

View more on Code Climate.

@Mab879
Copy link
Member Author

Mab879 commented Feb 27, 2024

/packit retest-failed

1 similar comment
@jan-cerny
Copy link
Collaborator

/packit retest-failed

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

I have executed the script and it updated the policy specific content as expected.

@jan-cerny jan-cerny merged commit f51f459 into ComplianceAsCode:master Feb 28, 2024
52 of 53 checks passed
@Mab879 Mab879 deleted the import_disa_changes_to_policy branch February 28, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Our content build system STIG STIG Benchmark related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants