Skip to content

Commit 02c7831

Browse files
authored
Merge pull request #1441 from evgenyz/test_offline_remediations
Add test that ensures there is no remediation attempt in the "offline" mode
2 parents 936a806 + 1191724 commit 02c7831

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

tests/API/XCCDF/unittests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ add_oscap_test("test_xccdf_transformation.sh")
6969
add_oscap_test("test_single_rule.sh")
7070
add_oscap_test("test_single_rule_stigw.sh")
7171
add_oscap_test("test_remediation_simple.sh")
72+
add_oscap_test("test_remediation_offline.sh")
7273
add_oscap_test("test_remediation_metadata.sh")
7374
add_oscap_test("test_remediation_bad_fix.sh")
7475
add_oscap_test("test_remediation_subs_plain_text.sh")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
. $builddir/tests/test_common.sh
3+
4+
set -e -o pipefail
5+
6+
name=$(basename $0 .sh)
7+
result=$(mktemp -t ${name}.res.XXXXXX)
8+
stderr=$(mktemp -t ${name}.err.XXXXXX)
9+
stdout=$(mktemp -t ${name}.out.XXXXXX)
10+
root=$(mktemp -d -t ${name}.root.XXXXXX)
11+
12+
set_chroot_offline_test_mode "$root"
13+
14+
$OSCAP xccdf eval --remediate --results $result $srcdir/${name}.xccdf.xml 2> $stderr 1> $stdout || echo "Scanner returned non-zero code (OK)"
15+
rm $result
16+
17+
grep "remediation in offline mode: not implemented" $stderr > /dev/null
18+
19+
rm -rf $stderr $stdout $root
20+
21+
unset_chroot_offline_test_mode
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Benchmark xmlns="http://checklists.nist.gov/xccdf/1.2" id="xccdf_moc.elpmaxe.www_benchmark_test">
3+
<status>accepted</status>
4+
<version>1.0</version>
5+
<Rule selected="true" id="xccdf_moc.elpmaxe.www_rule_1">
6+
<title>Ensure that file exists and it is not executable</title>
7+
<fix system="urn:xccdf:fix:script:sh">
8+
touch test_file
9+
chmod a-x test_file
10+
</fix>
11+
<check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
12+
<check-content-ref href="test_remediation_simple.oval.xml" name="oval:moc.elpmaxe.www:def:1"/>
13+
</check>
14+
</Rule>
15+
</Benchmark>

0 commit comments

Comments
 (0)