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

Reduce OCIL size #11577

Merged
merged 2 commits into from
Feb 13, 2024
Merged

Reduce OCIL size #11577

merged 2 commits into from
Feb 13, 2024

Conversation

Honny1
Copy link
Collaborator

@Honny1 Honny1 commented Feb 12, 2024

Description:

This PR reduces the size of the generated OCIL. It uses the OCIL from the selected rules in the Datastream. The difference between the Datastreams is 1 MB. It also automatically formats XCCDF and OCIL, but Python formatting is available in python3. Once support for python2 is discontinued, it will be possible to remove the XML formatting steps from the build.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Feb 12, 2024
Copy link

openshift-ci bot commented Feb 12, 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

@Honny1 Honny1 force-pushed the reduce-ocil branch 3 times, most recently from 6aa1290 to 8875821 Compare February 12, 2024 13:05
@Honny1 Honny1 marked this pull request as ready for review February 12, 2024 15:19
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Feb 12, 2024
@jan-cerny jan-cerny self-assigned this Feb 12, 2024
@jan-cerny jan-cerny added this to the 0.1.73 milestone Feb 12, 2024
@jan-cerny jan-cerny added the Infrastructure Our content build system label Feb 12, 2024
@@ -1547,7 +1549,7 @@ def export_benchmark_to_file(self, filename):
register_namespaces()
return self.benchmark.to_file(filename, self.env_yaml)

def export_ocil_to_xml(self):
def _get_enpty_ocil_xml(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

empty

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't something like create_ocil_xml_skeleton be better?

if not rule.ocil and not rule.ocil_clause:
continue
questionnaire, action, boolean_question = rule.to_ocil()
questionnaires.append(questionnaire)
test_actions.append(action)
questions.append(boolean_question)

def _get_rules_from_benchamrk(self, benchmark):
Copy link
Collaborator

Choose a reason for hiding this comment

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

benchmark

return root, questionnaires, test_actions, questions

@staticmethod
def _set_ocil_rules(rules, questionnaires, test_actions, questions):
Copy link
Collaborator

Choose a reason for hiding this comment

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

set_ocil_rules is a misleading name. Try something like add_rules_to_ocil?

@@ -1563,13 +1565,28 @@ def export_ocil_to_xml(self):
questionnaires = ET.SubElement(root, "{%s}questionnaires" % ocil_namespace)
test_actions = ET.SubElement(root, "{%s}test_actions" % ocil_namespace)
questions = ET.SubElement(root, "{%s}questions" % ocil_namespace)
for rule in self.rules.values():
return root, questionnaires, test_actions, questions
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should return just root because the other items can be easily accessed trough root.

Copy link

codeclimate bot commented Feb 12, 2024

Code Climate has analyzed commit 90de0f7 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.4% (0.0% change).

View more on Code Climate.

@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 reviewed the code. I have seen the generated OCIL file.

@jan-cerny jan-cerny merged commit cab4ffe into ComplianceAsCode:master Feb 13, 2024
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Our content build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants