-
Notifications
You must be signed in to change notification settings - Fork 698
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
Include metrics for rules and variables selected in Controls #11128
Include metrics for rules and variables selected in Controls #11128
Conversation
The controls.py module was updated to also initialize a list of rules included in each control. This make it easier to other tools analyse rules included in controls.
Now the controleval.py stats will also show the number of rules and variables included in each control, under "rules" property.
Besides the status of each Policy it is now also exporting metrics about rules and variables selected in each Policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this PR. I have generated the outputs suggested in the Review hints section and I have reviewed these outputs.
utils/controleval.py
Outdated
rules_count = sum(count_rules_and_vars_in_control(ctrl)[0] for ctrl in ctrls) | ||
vars_count = sum(count_rules_and_vars_in_control(ctrl)[1] for ctrl in ctrls) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if count_rules_and_vars_in_control
returned a namedtuple, it would allow you to avoid using the indices. Another possible approach would be to split count_rules_and_vars
to two separate functions count_rules
and count_vars
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the thoughts @jan-cerny . I tried to make it a little more readable using namedtuple in the last commit. Could you take a look, please?
The count_rules_and_vars and count_rules_and_vars_in_control got some additional lines in total but became more readable by using namedtupple instead of going to index and eliminates the need for additional list comprehensions.
Code Climate has analyzed commit c27923d and detected 2 issues on this pull request. Here's the issue category breakdown:
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 56.8% (0.0% change). View more on Code Climate. |
There was a problem hiding this 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 outputs suggested in the Review hints section and I have reviewed these outputs.
Description:
Besides the status of each Policy, now
controleval_metrics.py
is also exporting metrics about rules and variables selected in each Policy.For this, the
ssg/controls.py
was slightly incremented and the new property was used in two new functions ofcontroleval.py
. These functions are finally consumed bycontroleval_metrics.py
.Rationale:
Better tracking of rules and variables included in control files.
Review Hints:
e.g.:
utils/controleval_metrics.py prometheus -p rhel9
Then check the new metrics in the output while the former metrics are intact.
You can also check the output of
controleval.py stats
. e.g.:utils/controleval.py stats -i cis_rhel9 -p rhel9 -l l1_server
Then observe the last lines of the output. e.g.: