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 documentation of the steps that OVAL content goes through during the build #11336

Merged
merged 4 commits into from Dec 11, 2023

Conversation

Honny1
Copy link
Collaborator

@Honny1 Honny1 commented Dec 4, 2023

This PR documents the steps the OVAL content goes through during the build.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Dec 4, 2023
Copy link

openshift-ci bot commented Dec 4, 2023

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

@Honny1 Honny1 added Documentation Update in project documentation. OVAL OVAL update. Related to the systems assessments. Infrastructure Our content build system labels Dec 4, 2023
Copy link

github-actions bot commented Dec 4, 2023

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 marked this pull request as ready for review December 4, 2023 13:02
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Dec 4, 2023
Copy link
Member

@Mab879 Mab879 left a comment

Choose a reason for hiding this comment

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

Thanks for the docs addition, however I do have a couple of comments.

@@ -86,6 +86,13 @@ of occurrence:
- Generate content for derived products (such as CentOS and Scientific Linux).
- Generate HTML tables, Bash scripts, Ansible Playbooks and other secondary artifacts.

## How OVAL is build
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## How OVAL is build
## How OVAL is Built

Title case per the style guide and consider change the tense for clarity.

@@ -86,6 +86,13 @@ of occurrence:
- Generate content for derived products (such as CentOS and Scientific Linux).
- Generate HTML tables, Bash scripts, Ansible Playbooks and other secondary artifacts.

## How OVAL is build

Creating OVAL checks is done in two steps. First, all available OVAL checks are combined into a one unlinked OVAL document. The OVAL shorthands are loaded into the OVAL Document object and, in the case of template shorthand, extended using jinja macros before loading. If the shorthand is already loaded into the OVAL Document object, it is skipped. Shorthands are loaded in the order that benchmark checks are loaded first, followed by shared directory checks.
Copy link
Member

Choose a reason for hiding this comment

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

Per the style guide please have one sentence per line.

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 expect this to be more verbose and detailed.

You have recognized two major steps of the process. But, I would like to see to split them into more granular substeps.

As you describe a sequence of steps, I think a form of numbered list can be used to describe the process of processing OVALs. You can use a list with nested lists.

I have add some helpful questions below that will help you with extending the text.

@@ -86,6 +86,13 @@ of occurrence:
- Generate content for derived products (such as CentOS and Scientific Linux).
- Generate HTML tables, Bash scripts, Ansible Playbooks and other secondary artifacts.

## How OVAL is build
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
## How OVAL is build
## How OVAL is built

@@ -86,6 +86,13 @@ of occurrence:
- Generate content for derived products (such as CentOS and Scientific Linux).
- Generate HTML tables, Bash scripts, Ansible Playbooks and other secondary artifacts.

## How OVAL is build

Creating OVAL checks is done in two steps. First, all available OVAL checks are combined into a one unlinked OVAL document. The OVAL shorthands are loaded into the OVAL Document object and, in the case of template shorthand, extended using jinja macros before loading. If the shorthand is already loaded into the OVAL Document object, it is skipped. Shorthands are loaded in the order that benchmark checks are loaded first, followed by shared directory checks.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is against the style guide. There should be one sentence per line.

@@ -86,6 +86,13 @@ of occurrence:
- Generate content for derived products (such as CentOS and Scientific Linux).
- Generate HTML tables, Bash scripts, Ansible Playbooks and other secondary artifacts.

## How OVAL is build

Creating OVAL checks is done in two steps. First, all available OVAL checks are combined into a one unlinked OVAL document. The OVAL shorthands are loaded into the OVAL Document object and, in the case of template shorthand, extended using jinja macros before loading. If the shorthand is already loaded into the OVAL Document object, it is skipped. Shorthands are loaded in the order that benchmark checks are loaded first, followed by shared directory checks.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I want information about which scripts perform each of these actions.

Creating OVAL checks is done in two steps. First, all available OVAL checks are combined into a one unlinked OVAL document. The OVAL shorthands are loaded into the OVAL Document object and, in the case of template shorthand, extended using jinja macros before loading. If the shorthand is already loaded into the OVAL Document object, it is skipped. Shorthands are loaded in the order that benchmark checks are loaded first, followed by shared directory checks.

The second step is to link the generated document from the previous step with the XCCDF document.
The unlinked OVAL document is loaded into the OVAL Document object while the XML file is being loaded into the object instance. Validation of the OVAL document is performed during and after loading (for example, whether all the checks listed in the XCCDF are present in the OVAL document). After validation of the OVAL document, the IDs are converted to valid OVAL IDs. The OVAL document is then saved as an XML file. During saving, a minimal OVAL document is generated for each rule as an artifact. The last step is to link the file to the XCCDF document.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Which XML file is being loaded into the object instance?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you elaborate more on the validation step?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is the "minimal OVAL document" stored?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What does it take "to link the file to the XCCDF"? What is difference between linked and unlinked document?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Which script performs this step?

@jan-cerny jan-cerny added this to the 0.1.72 milestone Dec 4, 2023
@jan-cerny jan-cerny self-assigned this Dec 4, 2023
@Honny1
Copy link
Collaborator Author

Honny1 commented Dec 7, 2023

I fixed the style and rewrote the description of the steps the OVAL content goes through during build.

@jan-cerny
Copy link
Collaborator

/packit retest failed


### 1. Combination of OVALs

In the first step, all available and applicable for platform OVAL checks are builded into a single unlinked OVAL document stored in the `build/${PRODUCT}/oval-unlinked.xml` directory.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
In the first step, all available and applicable for platform OVAL checks are builded into a single unlinked OVAL document stored in the `build/${PRODUCT}/oval-unlinked.xml` directory.
In the first step, all available and applicable OVAL checks are built into a single unlinked OVAL document stored in the `build/${PRODUCT}/oval-unlinked.xml` directory.


In the first step, all available and applicable for platform OVAL checks are builded into a single unlinked OVAL document stored in the `build/${PRODUCT}/oval-unlinked.xml` directory.
The `oval-unlinked.xml` document is generated using the `combine_ovals.py` script.
The OVAL shortcuts are loaded into the OVAL Document object in the order that the benchmark checks are loaded first, followed by the shared directory checks.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are shortcuts? It's a new term here


Steps of loading the OVAL shorthand:

1. The OVAL Shorthand file is loaded as a string, and in the case of templated Shorthand, it is expanded using Jinja macros before loading.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't it be the opposite?

Suggested change
1. The OVAL Shorthand file is loaded as a string, and in the case of templated Shorthand, it is expanded using Jinja macros before loading.
1. The OVAL Shorthand file is loaded as a string, and in the case of not templated Shorthand, it is expanded using Jinja macros before loading.

2. The OVAL Shorthand string is processed by the OVAL Document object.
1. The OVAL Shorthand string is loaded into the OVAL Shorthand object.
2. the OVAL Shorthand object is validated
It is checked:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
It is checked:
The following properties are checked:

4. The OVAL definition referenced by the XCCDF is checked to be defined in the OVAL document.
5. Verify if `<xccdf:Value>` `type` to corresponding OVAL variable `datatype` export matching [constraint](http://csrc.nist.gov/publications/nistpubs/800-126-rev2/SP800-126r2.pdf#page=30&zoom=auto,69,313) is met.
Also correct the `type` attribute of those `<xccdf:Value>` elements where necessary in order the produced content to meet this constraint.
6. verify that the referenced CCE identifiers are correct
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
6. verify that the referenced CCE identifiers are correct
6. Verify that the referenced CCE identifiers are correct.

5. Verify if `<xccdf:Value>` `type` to corresponding OVAL variable `datatype` export matching [constraint](http://csrc.nist.gov/publications/nistpubs/800-126-rev2/SP800-126r2.pdf#page=30&zoom=auto,69,313) is met.
Also correct the `type` attribute of those `<xccdf:Value>` elements where necessary in order the produced content to meet this constraint.
6. verify that the referenced CCE identifiers are correct
7. translate the identifiers in the OVAL Document object using `IDTranslator`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
7. translate the identifiers in the OVAL Document object using `IDTranslator`.
7. Translate the identifiers in the OVAL Document object using `IDTranslator`.

6. verify that the referenced CCE identifiers are correct
7. translate the identifiers in the OVAL Document object using `IDTranslator`.
8. The OVAL Document object is stored as an XML file `build/ssg-${PRODUCT}-oval.xml`.
9. for each XCCDF rule, a minimal OVAL Documents document is generated as an artifact
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
9. for each XCCDF rule, a minimal OVAL Documents document is generated as an artifact
9. For each XCCDF rule, a minimal OVAL Documents document is generated as an artifact.

Comment on lines 169 to 170
10. The last step is to link the XCCDF document
- For each reference of OVAL check in XCCDF, a link to the check content and a check export element is added.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
10. The last step is to link the XCCDF document
- For each reference of OVAL check in XCCDF, a link to the check content and a check export element is added.
10. For each reference of OVAL check in XCCDF, a link to the `check-content` and a `check-export` element is added.

### 2. Linking OVAL Document

The second step is performed when building an XCCDF document using the `build_xccdf.py` script.
In this step, the `oval-unlinked.xml` document from the previous step is linked to the XCCDF document being built.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be great to explain that in this context the term "linking" means alignment of IDs between rules and checks.

1. The OVAL Shorthand file is loaded as a string, and in the case of templated Shorthand, it is expanded using Jinja macros before loading.
2. The OVAL Shorthand string is processed by the OVAL Document object.
1. The OVAL Shorthand string is loaded into the OVAL Shorthand object.
2. the OVAL Shorthand object is validated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
2. the OVAL Shorthand object is validated
2. The OVAL Shorthand object is validated.

@Honny1
Copy link
Collaborator Author

Honny1 commented Dec 10, 2023

@jan-cerny I've incorporated your comments.

Copy link

codeclimate bot commented Dec 10, 2023

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

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

This pull request will bring the total coverage in the repository to 58.5%.

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.

This is a well-written, understandable and concise.

@jan-cerny
Copy link
Collaborator

The testing farm problem on Fedora 39 is an infrastructure problem. This PR changes only the documentation, so I think the PR is harmless.

@jan-cerny jan-cerny merged commit f4b0412 into ComplianceAsCode:master Dec 11, 2023
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Update in project documentation. Infrastructure Our content build system OVAL OVAL update. Related to the systems assessments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants