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

Introduce ability to generate kickstarts #2136

Merged
merged 53 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b47e1c4
Introduce new fix type kickstart
jan-cerny Jul 4, 2024
9d37973
Add a generic header for Kickstarts
jan-cerny Jul 8, 2024
e9e0067
Add a simple data stream with a Kickstart remediation
jan-cerny Jul 8, 2024
3a0601b
Use a special function to generate kickstarts
jan-cerny Jul 8, 2024
c8b2418
Generate post section with oscap running
jan-cerny Jul 8, 2024
e114913
Add a method to triage different kickstart fixes
jan-cerny Jul 8, 2024
aa92f56
Add multiple rules to the example data stream
jan-cerny Jul 9, 2024
87cd691
Triage lines to Kickstart sections
jan-cerny Jul 9, 2024
c62a905
Add a simple test for Kickstart fix
jan-cerny Jul 9, 2024
da9a41e
Disable result oriented fixes for the kickstart fix type
jan-cerny Jul 9, 2024
e366cbc
Document generating kickstarts in user manual
jan-cerny Jul 9, 2024
7907dd8
Add a common kickstart header
jan-cerny Jul 9, 2024
0d223e7
Make sure openscap and scap-security-guide are installed
jan-cerny Jul 9, 2024
eaf2cac
Add a comment
jan-cerny Jul 10, 2024
bf6f111
Show a correct input file name
jan-cerny Jul 10, 2024
e31d82f
Extract function _generate_kickstart_services
jan-cerny Jul 10, 2024
90a90bf
Extract function _generate_kickstart_packages
jan-cerny Jul 10, 2024
95c8728
Extract function _generate_kickstart_post
jan-cerny Jul 10, 2024
ab946f6
Improve the file name of oscap command
jan-cerny Jul 10, 2024
b212b7c
Add ability to define logical partitions
jan-cerny Jul 12, 2024
a39161c
Improve hardcoded items
jan-cerny Jul 16, 2024
3ca05fe
Improve and reduce the hardcoded text
jan-cerny Jul 18, 2024
bf2cfd9
Improve the logvol command format and parsing
jan-cerny Jul 18, 2024
796cf32
Extend test test_remediation_kickstart.sh
jan-cerny Jul 18, 2024
ea73415
Add boot loader options
jan-cerny Jul 18, 2024
ec8da8d
Change partitioning defaults
jan-cerny Jul 19, 2024
3730e55
Update expected line in the unit test
jan-cerny Jul 19, 2024
77ee27b
Handle more unexpected situations
jan-cerny Jul 19, 2024
954cdf0
Extend tests to cover error situations
jan-cerny Jul 19, 2024
f7d0e4a
Replace custom fiction by oscap_strrm
jan-cerny Jul 22, 2024
96abfeb
Generate results and reports from the remediation in post phase
jan-cerny Jul 22, 2024
5e7a16f
Introduce function xccdf_session_get_user_tailoring_file
jan-cerny Jul 23, 2024
d1203d5
Introduce function oscap_source_to_fd
jan-cerny Jul 23, 2024
e8513a5
Introduce function oscap_xml_save_fd
jan-cerny Jul 23, 2024
8d0e338
Support using tailoring to generate kickstarts
jan-cerny Jul 23, 2024
fb3fb8a
Add a simple test generating kickstart with tailoring
jan-cerny Jul 23, 2024
f39cff4
Add a reboot command
jan-cerny Jul 23, 2024
48b1043
Do not create /root/openscap_data directory
jan-cerny Jul 24, 2024
fe831b8
Fail if remediation fails
jan-cerny Jul 25, 2024
f4a35f7
Add default values for fully automated installation
jan-cerny Jul 25, 2024
563cf6b
Add a default partition layout
jan-cerny Jul 25, 2024
3c2e679
Add an empty line to the user manual
jan-cerny Jul 25, 2024
509460b
Use autopart in the default partition option
jan-cerny Jul 25, 2024
0e8a0f5
Add exit 1
jan-cerny Jul 25, 2024
fd16278
Improve the bootloader command
jan-cerny Jul 26, 2024
24ade05
Introduce function oscap_concat
jan-cerny Jul 26, 2024
fcf313a
Add ability to specify post sections
jan-cerny Jul 26, 2024
f37d15f
Add support for %pre section
jan-cerny Jul 26, 2024
b90aa34
Fail if there is an unfinished section in the remediation
jan-cerny Jul 26, 2024
b6970de
Improve User manual
jan-cerny Jul 29, 2024
5cd77b3
Solve situation when --profile isn't provided
jan-cerny Jul 29, 2024
1765199
Add ability to disable kdump
jan-cerny Jul 29, 2024
523f842
Fix rule title
jan-cerny Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docs/manual/manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,44 @@ For example, to generate a blueprint remediation for RHEL 8 OSPP profile, run:
$ oscap xccdf generate fix --profile ospp --fix-type blueprint /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml > blueprint.toml
----

=== Generating RHEL Kickstarts

OpenSCAP can generate RHEL kickstarts which can be used for unattended installation of RHEL, Fedora and similar systems.
Information about RHEL kickstarts and their syntax can be found at https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/performing_an_advanced_rhel_9_installation/kickstart_references[Kickstart references].

To generate a kickstart, use `oscap xccdf generate fix` command with the `--fix-type kickstart` option.

The kickstart will be generated from kickstart snippets in XCCDF rules in the input SCAP content.
The kickstart snippets need to be stored in `<fix>` elements with `system` attribute set to `urn:xccdf:fix:script:kickstart`.

When processing the kickstart snippets comming from the XCCDF Rules, each line is processed separately.
The following rules are applied on each line:

* lines starting with `#` are ignored
* empty lines are ignored
* lines starting with a supported command are processed
* lines starting with something else than a supported command are dropped
* excess whitespace are trimmed

Supported commands:
* `package install package_name` - adds `package_name` to `%packages` section in the kickstart
* `package remove package_name` - adds `-package_name` to `%packages` section in the kickstart
* `service enable service_name` - adds `service_name` to list in the `--enabled=` option in the `services` command in commands section in the kickstart
* `service disable service_name` - adds `service_name` to list in the `--disabled=` option in the `services` command in commands section in the kickstart
* `post command` - adds `command` to the `%post`` section the kickstart

For example, to generate a kickstart for RHEL 9 STIG profile, run:

----
$ oscap xccdf generate fix --profile stig --fix-type kickstart /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml > rhel9-kickstart-stig.cfg
----

The generated kickstart file needs to be reviewed and customized for the intended deployment.

NOTE: The `kickstart` fix type shouldn't be confused with `anaconda` fix type.
The `anaconda` fix type is used by the OSCAP Anaconda Addon and shouldn't be used directly by users.
Users should use the `kickstart` fix type.

== Details on SCAP conformance

=== Check Engines
Expand Down Expand Up @@ -2095,3 +2133,10 @@ You can find the ID of the customized profile with `oscap info <your_tailoring_f
Yes, it's possible, you can download the file on other computer that is connected to the internet and then copy the file to the system where you run `oscap`.
Instead of the `--fetch-remote-resources` option you will use the `--local-files` option.
For more information, please refer to section <<_using_external_or_remote_resources,Using external or remote resources>>.

*I have generated a kickstart but the generated file isn't a valid kickstart.*

You are using a wrong `--fix-type` option.
To generate a kickstart, use the `--fix-type kickstart` option.
Do not use `--fix-type anaconda`.
For more information, please refer to section <<_generating_rhel_kickstarts,Generating RHEL Kickstarts>>.
3 changes: 2 additions & 1 deletion src/XCCDF_POLICY/public/xccdf_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,11 @@ OSCAP_API bool xccdf_policy_resolve(struct xccdf_policy * policy);
* @param result XCCDF TestResult. This may be omitted to generate the prescription
* based solely on the XCCDF Policy (xccdf:Profile).
* @param sys Consider only those fixes that have @system attribute equal to sys
* @param input_file_name file name of the input SCAP file
* @param output_fd write prescription to this file descriptor
* @returns zero on success, non-zero indicate partial (incomplete) output.
*/
OSCAP_API int xccdf_policy_generate_fix(struct xccdf_policy *policy, struct xccdf_result *result, const char *sys, int output_fd);
OSCAP_API int xccdf_policy_generate_fix(struct xccdf_policy *policy, struct xccdf_result *result, const char *sys, const char *input_file_name, int output_fd);

/**
* xccdf_policy_model_get_files and xccdf_item_get_files each return oscap_file_entries instead of raw strings
Expand Down
Loading
Loading