Skip to content

Commit 43bb99a

Browse files
authored
Merge pull request #1448 from jan-cerny/ocil_warning
Do not emit warning when a rule has only OCIL or SCE
2 parents 43a3ba0 + 48abb41 commit 43bb99a

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

src/XCCDF_POLICY/xccdf_policy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,10 @@ _xccdf_policy_rule_get_applicable_check(struct xccdf_policy *policy, struct xccd
583583
result = check;
584584
} else if (strcmp("http://oval.mitre.org/XMLSchema/oval-definitions-5", check->system) == 0) {
585585
print_oval_warning = true;
586+
} else if (strcmp("http://scap.nist.gov/schema/ocil/2", check->system) == 0) {
587+
dI("This rule requires an OCIL check. OCIL checks are not supported by OpenSCAP.");
588+
} else if (strcmp("http://open-scap.org/page/SCE", check->system) == 0) {
589+
dI("This rule requires a SCE check but the SCE plugin was disabled.");
586590
} else {
587591
print_general_warning = true;
588592
warning_check_system = check->system;

tests/API/XCCDF/unittests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_oscap_test("test_xccdf_check_negate.sh")
3232
add_oscap_test("test_xccdf_check_multi_check.sh")
3333
add_oscap_test("test_xccdf_check_multi_check2.sh")
3434
add_oscap_test("test_xccdf_check_multi_check_zero_definitions.sh")
35+
add_oscap_test("test_xccdf_check_ocil.sh")
3536
add_oscap_test("test_xccdf_check_content_ref_without_name_attr.sh")
3637
add_oscap_test("test_xccdf_check_without_content_refs.sh")
3738
add_oscap_test("test_xccdf_refine_rule.sh")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
. $builddir/tests/test_common.sh
3+
4+
set -e
5+
set -o pipefail
6+
7+
result=`mktemp`
8+
stderr=`mktemp`
9+
$OSCAP xccdf eval --results $result $srcdir/test_xccdf_check_ocil.xml 2> $stderr
10+
[ ! -s "$stderr" ]
11+
$OSCAP xccdf validate $result
12+
assert_exists 1 '//rule-result[@idref="xccdf_moc.elpmaxe.www_rule_1"]/result[text()="notchecked"]'
13+
rm $stderr
14+
rm $result
15+
16+
stderr=`mktemp`
17+
$OSCAP xccdf eval --verbose INFO $srcdir/test_xccdf_check_ocil.xml 2> $stderr
18+
grep -q "This rule requires an OCIL check. OCIL checks are not supported by OpenSCAP." $stderr
19+
rm $stderr
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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>incomplete</status>
4+
<version>1.0</version>
5+
<Rule selected="true" id="xccdf_moc.elpmaxe.www_rule_1">
6+
<title>Rule with OCIL check</title>
7+
<check system="http://scap.nist.gov/schema/ocil/2">
8+
<check-content-ref href="test_xccdf_check_ocil.ocil.xml"/>
9+
</check>
10+
</Rule>
11+
</Benchmark>

0 commit comments

Comments
 (0)