-
Notifications
You must be signed in to change notification settings - Fork 383
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
8 changed files
with
163 additions
and
59 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
# %partitions | ||
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 | ||
# %logvols | ||
logvol /var/tmp --name=vartmp --vgname=system --size=1024 | ||
# %end | ||
|
||
bootloader --append="quick audit=1" | ||
|
||
%addon com_redhat_kdump --disable | ||
%end | ||
|
||
firewall --remove-service=httpd --service=sshd | ||
|
||
services --disabled=telnet,httpd --enabled=auditd,rsyslog,sshd | ||
|
||
%packages | ||
openscap-scanner | ||
scap-security-guide | ||
rsyslog | ||
openssh-server | ||
podman | ||
-usbguard | ||
%end | ||
|
||
%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 | ||
|
||
%post --nochroot | ||
mkdir -p /etc/ddfds | ||
%end | ||
|
||
%post --nochroot | ||
mkdir -p /etc/abcd | ||
%end | ||
|
||
%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