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 a faster alternative for generating HTML guides #11036

Merged
merged 3 commits into from
Aug 31, 2023

Conversation

jan-cerny
Copy link
Collaborator

@jan-cerny jan-cerny commented Aug 30, 2023

The new script generate_guides.py builds HTML guides for each profile in the given SCAP source data stream and also it builds a HTML index.

The script generate_guides.py applies the XSLT template /usr/share/openscap/xsl/xccdf-guide.xsl that is shipped in the openscap RPM package. That means that this tool still depends on OpenSCAP, but doesn't call the oscap tool.

The advantage of the new solution is that the given SCAP source data stream is parsed only once, which is faster that parsing this big XML file for each profile.

Unfortunately, this new script needs the lxml library because the xml.etree doesn't provide a XSLT processing feature. Therefore, we will make the usage of the new script optional and we will fall back to the existing solution if lxml isn't installed. This way we will improve the CI and the developer laptop experience without having to break a build.

The new script `generate_guides.py` builds HTML guides for
each profile in the given SCAP source data stream and
also it builds a HTML index.

The script `generate_guides.py` applies the XSLT template
`/usr/share/openscap/xsl/xccdf-guide.xsl` that is shipped
in the `openscap` RPM package. That means that this tool
still depends on OpenSCAP, but doesn't call the `oscap` tool.

The advantage of the new solution is that the given SCAP source
data stream is parsed only once, which is faster that parsing
this big XML file for each profile.

Unfortunately, this new script needs the `lxml` library because
the `xml.etree` doesn't provide a XSLT processing feature.
Therefore, we will make the usage of the new script optional and
we will fall back to the existing solution if `lxml` isn't installed.
This way we will improve the CI and the user's machines experience
without having to break a build.
@github-actions
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

@Mab879 Mab879 self-assigned this Aug 30, 2023
@Mab879 Mab879 added the Infrastructure Our content build system label Aug 30, 2023
@Mab879 Mab879 added this to the 0.1.70 milestone Aug 30, 2023
@jan-cerny jan-cerny added the enhancement General enhancements to the project. label Aug 30, 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.

Just one comment. Let me know what you think.

f.write(index_source.encode("utf-8"))


def generate_html_guides(ds, benchmarks, oscap_version, product, output_dir):
Copy link
Member

Choose a reason for hiding this comment

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

Code Climate is flagging this method since there are 5 parameters.

If you pulled the outer loop into main you might be able to get to four.

But I'm not too concerned about this one.

The function `generate_html_guides` has more parameters than allowed.
@jan-cerny
Copy link
Collaborator Author

I have fixed Code Climate problem.

@codeclimate
Copy link

codeclimate bot commented Aug 31, 2023

Code Climate has analyzed commit 4c08686 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 53.8% (0.5% change).

View more on Code Climate.

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.

LGTM. Thanks for getting this done!

@Mab879 Mab879 merged commit e587c0b into ComplianceAsCode:master Aug 31, 2023
37 of 38 checks passed
@jan-cerny jan-cerny deleted the faster_guides branch August 31, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement General enhancements to the project. Infrastructure Our content build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants