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

utils/gen_rendered_policies_index.py: read compiled control files #11667

Merged

Conversation

vojtapolasek
Copy link
Collaborator

Description:

  • include the "policy" key in compiled control files
  • the script for generating of HTML index for rendered policies now reads compiled control files

Rationale:

Control files in the "controls" directory can contain Jinja macros. If a script wants to parse our content with Jinja macros, it requires non-trivial steps to get this working.
The script gen_rendered_policies_index.py is very simple and it reads literarily one key (policy) from the control file. Therefore, it does not care about Jinja at all.
Therefore, it is now reading compiled contro files in the build//controls directory.

This problem was discovered in this PR which added Jinja statements into ANSSI file: #11663

Review Hints:

I think you can review the Github action which builds the web content and compare it with the one present at https://complianceascode.github.io/content-pages/

Or you can do following steps for master and the PR and compare results:

  1. cd build
  2. rm -r *
  3. cmake ../
  4. make -j8
  5. make -j8 render-policies
  6. cd ..
  7. source .pyenv.sh
  8. ./utils/gen_rendered_policies_index.py /tmp/sites
  9. inspect /tmp/sites directory

…riginal ones

Original files are not needed. They can contain Jinja and reading Jinja properly would make this script complicated while not bringing any real value. The script needs to read only one key from the file which is not going to be enclosed in Jinja macros in foreseeable future.
@vojtapolasek vojtapolasek added the Infrastructure Our content build system label Mar 8, 2024
@vojtapolasek vojtapolasek added this to the 0.1.73 milestone Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 2024

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 Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 2024

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:11667
This image was built from commit: d7918d2

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:11667

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

Copy link

codeclimate bot commented Mar 8, 2024

Code Climate has analyzed commit d7918d2 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 59.8% (0.0% 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.

I think this is fine for now.

This script could use some UX improvements in a the future, I will file an issue.

@Mab879 Mab879 merged commit 945e80a into ComplianceAsCode:master Mar 8, 2024
44 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.

2 participants