-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --raw switch to xccdf generate fix module
The option would allow the user to generate fix scripts without headers and boilerplate. Currently implemented for Kickstart remediation type.
- Loading branch information
Showing
7 changed files
with
111 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
tests/API/XCCDF/unittests/test_remediation_kickstart_expected_raw.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Create partition layout scheme (required for security compliance) | ||
zerombr | ||
clearpart --all --initlabel | ||
reqpart --add-boot | ||
part pv.01 --grow --size=1 | ||
volgroup system pv.01 | ||
logvol / --name=root --vgname=system --size=2000 --grow | ||
logvol swap --name=swap --vgname=system --size=1000 | ||
logvol /var/tmp --name=vartmp --vgname=system --size=1024 | ||
|
||
# Configure boot loader options (required for security compliance) | ||
bootloader --append="quick audit=1" | ||
|
||
# Disable the kdump kernel crash dumping mechanism (required for security compliance) | ||
%addon com_redhat_kdump --disable | ||
%end | ||
|
||
# Disable and enable services in firewall (required for security compliance) | ||
firewall --remove-service=httpd --service=sshd | ||
|
||
# Disable and enable systemd services (required for security compliance) | ||
services --disabled=telnet,httpd --enabled=auditd,rsyslog,sshd | ||
|
||
# Packages selection (required for security compliance) | ||
%packages | ||
openscap-scanner | ||
scap-security-guide | ||
rsyslog | ||
openssh-server | ||
podman | ||
-usbguard | ||
%end | ||
|
||
# Perform OpenSCAP hardening (required for security compliance) | ||
%post --erroronfail | ||
oscap xccdf eval --remediate --results-arf /root/oscap_arf.xml --report /root/oscap_report.html --profile 'xccdf_org.openscap.www_profile_common' /usr/share/xml/scap/ssg/content/test_remediation_kickstart.ds.xml | ||
[ $? -eq 0 -o $? -eq 2 ] || exit 1 | ||
%end | ||
|
||
# Additional %post section (required for security compliance) | ||
%post --nochroot | ||
mkdir -p /etc/ddfds | ||
%end | ||
|
||
# Additional %post section (required for security compliance) | ||
%post --nochroot | ||
mkdir -p /etc/abcd | ||
%end | ||
|
||
# Additional %post section (required for security compliance) | ||
%post | ||
rm -rf /etc/xyz | ||
# create a new path | ||
feel /etc/xyz | ||
%end | ||
|
23 changes: 23 additions & 0 deletions
23
tests/API/XCCDF/unittests/test_remediation_kickstart_raw.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
. $builddir/tests/test_common.sh | ||
|
||
set -e -o pipefail | ||
|
||
function test_raw { | ||
kickstart=$(mktemp) | ||
stderr=$(mktemp) | ||
expected_modified=$(mktemp) | ||
|
||
sed "s;TEST_DATA_STREAM_PATH;$srcdir/test_remediation_kickstart.ds.xml;" "$srcdir/test_remediation_kickstart_expected_raw.cfg" > "$expected_modified" | ||
|
||
$OSCAP xccdf generate fix --fix-type kickstart --raw --output "$kickstart" --profile common "$srcdir/test_remediation_kickstart.ds.xml" | ||
|
||
diff -u "$expected_modified" "$kickstart" | ||
|
||
rm -rf "$kickstart" | ||
rm -rf "$stderr" | ||
rm -rf "$expected_modified" | ||
rm -rf "$kickstart_modified" | ||
} | ||
|
||
test_raw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters