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

Tool for identifying the most used components #11730

Merged
merged 7 commits into from
Mar 20, 2024

Conversation

Honny1
Copy link
Collaborator

@Honny1 Honny1 commented Mar 19, 2024

Description:

This PR adds a subcommand profile_tool.py that generates a list of components with the number of occurrences of the component's rules in the profiles that are generated in different formats.

Rationale:

The benefit of having this information quickly accessible is to have a more precise idea of components importance so we can work more proactively and avoid issues, for example, when releasing policies for a brand new product.

Historically we have discovered relevant component changes. SSH, Rsyslog, PAM and authselect are good examples. Getting awareness of these components changes too late may cause considerable efforts since we had to adapt rules to the changes in a very short period of time.

Review Hints:

To generate a list of the most used components in the whole project:

    $ ./build-scripts/profile_tool.py most-used-components

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

openshift-ci bot commented Mar 19, 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

github-actions bot commented Mar 19, 2024

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

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

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

if PYTHON_2:
raise Exception("This feature is not supported for python2.")

for product in get_available_products():
Copy link
Collaborator

Choose a reason for hiding this comment

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

At this moment, we use "components" only for Fedora, RHEL 7, RHEL 8, RHEL 9 and RHEL 10 products. It doesn't make sense to include into stats any other products or any controls used in the products that don't use components.

One of consequences of this behavior is that we have without_component: 12125 which involves all rules that aren't part of linux_os benchmark.

If a product is using the "components" feature it sets the components_root key in its product.yml.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. I have improved the product selection to those with components_root.

def command_most_used_components(args):
components = {}

_process_all_products_from_controls(components)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it doesn't make sense to combine results from all products to a single number. Currently from the output we can see that the selinux component is used 1660 times. But this number is the count of rules multiplied by their occurence in profiles multiplied by their occurence in products.

I think that a product ID should be a parameter of this script and the results should be produced for the given product.

Copy link
Collaborator Author

@Honny1 Honny1 Mar 20, 2024

Choose a reason for hiding this comment

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

Limitation on product will be done by #11733 .

Copy link

codeclimate bot commented Mar 20, 2024

Code Climate has analyzed commit 585a0e7 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.3% (0.0% change).

View more on Code Climate.

@Honny1 Honny1 marked this pull request as ready for review March 20, 2024 15:13
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Mar 20, 2024
@Honny1 Honny1 requested a review from jan-cerny March 20, 2024 15:13
@Honny1 Honny1 added the enhancement General enhancements to the project. label Mar 20, 2024
@Mab879 Mab879 merged commit 585a0e7 into ComplianceAsCode:master Mar 20, 2024
44 checks passed
@Mab879 Mab879 added the Infrastructure Our content build system label May 16, 2024
@Mab879 Mab879 added this to the 0.1.73 milestone May 16, 2024
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.

3 participants