-
Notifications
You must be signed in to change notification settings - Fork 383
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 refine-rule tailoring ability to autotailor #1877
Conversation
utils/autotailor
Outdated
change = ET.SubElement(profile, "xccdf-1.2:set-value") | ||
change.set("idref", self._full_var_id(varname)) | ||
change.text = str(value) | ||
self._add_rule_select_operations(container_element)(profile) |
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 doesn't look right
[jcerny@thinkpad openscap{pr/1877}]$ utils/autotailor /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml standard
Traceback (most recent call last):
File "/home/jcerny/work/git/openscap/utils/autotailor", line 205, in <module>
t.to_xml(args.output)
File "/home/jcerny/work/git/openscap/utils/autotailor", line 120, in to_xml
self._add_rule_select_operations(container_element)(profile)
NameError: name 'container_element' is not defined
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 feel like we should start adding unit tests for the autotailor tool.
Instead of repeating the smae string all over the place, let's have a single constant defined and then used.
If the `--new-profile-id` isn't provided by the user, we will create the ID of the customized profile ID by appending the `_customized` suffix to the base profile ID. This change makes the behavior according to the help text of the `--new-profile-id` option: > If left out, the new ID will be obtained by appending '_customized' > to the tailored profile ID.
and fix the failed asserts
We will move the condition that determines the ID of the customized profile into the `Tailoring` class. This move helps encapsulate code and also allows easier unit testing of this feature which we immediately use to write a unit test in this commit as well :)
This patch adds two new command line options `--rule-role` and `--rule-severity` that will allow users to refine rule role and rule seveirty in their customized profile. Using these options will generate `refine-rule` elements within the output tailoring file. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2058168
This patch moves the logic for assigning the XCCDF Values for outer space inside the Tailoring class by defining a method.
Explicitly setting namespaces of elements is the recommended way of using namespaces. It helps prevent namespace errors. Also, it simplifies unit testing of code that works with XML elements.
The new name of the variable better describes its actual contents.
This commit adds an integration test for autotailor. The goal of the test is to verify if the tailoring produced by autotailor can be loaded and consumed by oscap and if the generated tailoring leads to the intended behavior of the profile evaluation.
The result will be that the autotailor unit tests will be executed during the CTest which is run in our CI.
21df149
to
48c013b
Compare
Hello @matejak! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2023-10-03 13:14:53 UTC |
This PR has been replaced by #2039 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2058168