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

Show most used rules of component #12001

Merged

Conversation

Honny1
Copy link
Collaborator

@Honny1 Honny1 commented May 16, 2024

Description:

This PR adds the --used-rules flag to the most-used-components command of the profile_tool.py file, which adds a list of used component's rules with the number of profiles where the rule is used.

Review Hints:

To get a list of the most used components with used rules for product RHEL9 you can run this command:

./build-scripts/profile_tool.py most-used-components --products rhel9 --used-rules

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

openshift-ci bot commented May 16, 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 May 16, 2024

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

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

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

@Honny1 Honny1 force-pushed the show-most-used-rules-of-component branch from 86c2a03 to 1631c8f Compare May 16, 2024 12:08
@Honny1 Honny1 added the enhancement General enhancements to the project. label May 16, 2024
@jan-cerny
Copy link
Collaborator

I wonder how the counts are computed.

If I run your tool I for example see that accounts_password_pam_minlen is used 15 times, but when I run this command I get 17:

grep -r '\<accounts_password_pam_minlen\>' build/rhel9/profiles/ | wc -l

"--used-rules",
default=False,
action="store_true",
help="Show used rules of component.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need a better help text:

For every component, show usage of each rule in profiles in the given product.

@jan-cerny jan-cerny self-assigned this May 17, 2024
@Honny1 Honny1 force-pushed the show-most-used-rules-of-component branch from 18c4e0b to 3abbcd6 Compare May 17, 2024 15:01
@Honny1 Honny1 requested a review from jan-cerny May 17, 2024 15:34
@jan-cerny
Copy link
Collaborator

Now the output of the scripts seems to correspond to the results that we can get by searching in resolved profiles.

I'm thinking now that we should remove the "default" profile from the statistics. The "default" profile is a trash bin for rules that aren't present in any real profile but need to be kept in the data streams for backward compatibility reason. But, for the purpose of giving us a knowledge about usage of components in security profiles, the "default" profile is totally uninteresting. Do you agree?

@Honny1 Honny1 force-pushed the show-most-used-rules-of-component branch from 8915b86 to 95be94a Compare May 22, 2024 14:55
Copy link

codeclimate bot commented May 22, 2024

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

View more on Code Climate.

@Honny1
Copy link
Collaborator Author

Honny1 commented May 23, 2024

/packit rebuild-failed

@Honny1 Honny1 marked this pull request as ready for review May 23, 2024 12:14
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label May 23, 2024
@Honny1
Copy link
Collaborator Author

Honny1 commented May 23, 2024

@jan-cerny I removed the default profile.

@jan-cerny
Copy link
Collaborator

/packit build

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 generated the output for RHEL 8 content, I have checked the output and I have checked some random rules if the reported number is the same as count of occurrences in the built profiles (build/rhel8/profiles). The results were OK.

@jan-cerny jan-cerny merged commit 1994cfb into ComplianceAsCode:master May 27, 2024
112 of 113 checks passed
@Mab879 Mab879 added this to the 0.1.74 milestone Aug 8, 2024
@Mab879 Mab879 added the Infrastructure Our content build system label Aug 8, 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