-
Notifications
You must be signed in to change notification settings - Fork 8
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 /hardening/kickstart
tests for oscap-generated kickstarts
#239
Conversation
78fd9b0
to
cd27bd1
Compare
e44646e
to
19e7181
Compare
Added a condition to exclude RHEL-8 after a brief message with Evgeny - we probably want to support/test RHEL-9 in addition to RHEL-10. One last step is to add waivers. |
19e7181
to
a568e2a
Compare
I didn't join the
|
72a4f7a
to
3525b81
Compare
These specify the defaults and are no longer needed post-RHEL-7. Signed-off-by: Jiri Jaburek <comps@nomail.dom>
This is to avoid confusion with oscap-generated kickstarts. Signed-off-by: Jiri Jaburek <comps@nomail.dom>
Signed-off-by: Jiri Jaburek <comps@nomail.dom>
This makes it a bit more explicit as to where the kickstart comes from, making the test algorithm more obvious, without copying large chunks of code. Signed-off-by: Jiri Jaburek <comps@nomail.dom>
This adds translate_oscap_blueprint() and calls 'oscap' similarly to /hardening/kickstart, showing the base test algorithm directly in the test. Coincidentally, this also cleans up the lib.osbuild logic a lot, as we no longer have to pass 'profile' around and account for special oscap cases and blueprint paths. All oscap-specific stuff is now either in the translate function, or directly in the test. The TEMPLATE and other pieces of code were inspired by lib.virt. translate_oscap_blueprint() weirdly takes lines instead of a full block of text (the first thing it does is 'join()'), but that's intentional, to keep the API similar to lib.virt translate functions. Signed-off-by: Jiri Jaburek <comps@nomail.dom>
Signed-off-by: Jiri Jaburek <comps@nomail.dom>
Also re-organize a bit /hardening/anaconda waivers in a similar way. Signed-off-by: Jiri Jaburek <comps@nomail.dom>
3525b81
to
ec0afee
Compare
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.
kickstart
part is fine.
For image-builder
move, why not to move also rule unselect to test code? Unselect rules in contest-ds.xml
and add that modified datastream to rpmpack
. No need for oscap tailoring blueprint section. That will unify unselect part with OAA/kickstart where unselect is done directly in datastream without providing tailoring file.
This makes it more consistent with /hardening/kickstart and others. Signed-off-by: Jiri Jaburek <comps@nomail.dom>
Changed --- hardening/kickstart/test.py 2024-08-08 21:21:32.803772075 +0200
+++ hardening/image-builder/test.py 2024-08-15 13:38:57.474565165 +0200
@@ -3,3 +3 @@
-import os
-
-from lib import util, results, virt, oscap
+from lib import results, oscap, osbuild, util
@@ -9 +7 @@
-virt.Host.setup()
+osbuild.Host.setup()
@@ -11 +9 @@
-g = virt.Guest()
+g = osbuild.Guest()
@@ -18 +16 @@
-# tell the 'oscap xccdf eval --remediate' in %post to use it
+# tell the 'oscap xccdf eval --remediate' called by osbuild-composer to use it
@@ -24 +22 @@
- 'fix', '--fix-type', 'kickstart',
+ 'fix', '--fix-type', 'blueprint',
@@ -28,4 +26 @@
-ks = virt.translate_oscap_kickstart(lines, '/root/remediation-ds.xml')
-
-if os.environ.get('USE_SERVER_WITH_GUI'):
- ks.packages.append('@Server with GUI')
+blueprint = osbuild.translate_oscap_blueprint(lines, '/root/remediation-ds.xml')
@@ -33 +28 @@
-g.install(kickstart=ks, rpmpack=rpmpack)
+g.create(blueprint=blueprint, rpmpack=rpmpack)
@@ -52 +47 @@
-results.report_and_exit(logs=['report.html', 'results-arf.xml.gz'])
+results.report_and_exit(logs=['report.html', 'results-arf.xml.gz', g.osbuild_log]) |
(Probably best to go commit-by-commit - the early ones are about cleanup.)
The image-builder (osbuild) rework is mainly to unify the API with
/hardening/kickstart
. I would have done the same for/hardening/anaconda
, but (IIRC) openscap%addon
cannot readfile://
URLs or point to local files on the installed OS, it can only reliably use remote HTTP URLs.