Skip to content

Commit c316bc4

Browse files
committed
Extend test_skip_paths
Extend test_skip_paths to test the "skip selected paths" feature also in the xmlfilecontent probe.
1 parent a033aef commit c316bc4

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

tests/API/OVAL/skip_paths/test.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<parent>
2+
<child>text</child>
3+
</parent>

tests/API/OVAL/skip_paths/test_skip_paths.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ result=$(mktemp)
88
root="/tmp/oscap_test_skip_paths"
99
mkdir -p "$root/a"
1010
touch "$root/a/x"
11+
cp "$srcdir/test.xml" "$root/a/"
1112
mkdir -p "$root/b"
1213
touch "$root/b/y"
14+
cp "$srcdir/test.xml" "$root/b/"
1315
mkdir -p "$root/c"
1416
touch "$root/c/z"
17+
cp "$srcdir/test.xml" "$root/c/"
1518
# oscap probes will skip directories "b" and "c"
1619
export OSCAP_PROBE_IGNORE_PATHS="$root/b:$root/c"
1720
$OSCAP oval eval --results $result "$srcdir/test_skip_paths.xml"
@@ -37,5 +40,12 @@ assert_exists 1 '/oval_results/results/system/definitions/definition[@definition
3740
assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:6" and @flag="does not exist"]'
3841
assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:filehash58_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/b/y"]'
3942
assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:filehash58_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/c/z"]'
43+
assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:7" and @result="true"]'
44+
assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:7" and @flag="complete"]'
45+
assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:xmlfilecontent_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/a/test.xml"]'
46+
assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:8" and @result="true"]'
47+
assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:8" and @flag="does not exist"]'
48+
assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:xmlfilecontent_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/b/test.xml"]'
49+
assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:xmlfilecontent_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/c/test.xml"]'
4050
rm -f $result
4151
rm -rf "$root"

tests/API/OVAL/skip_paths/test_skip_paths.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
<criterion test_ref="oval:x:tst:6"/>
4242
</criteria>
4343
</definition>
44+
<definition class="compliance" version="1" id="oval:x:def:7">
45+
<metadata><title/><description/></metadata>
46+
<criteria operator="AND">
47+
<criterion test_ref="oval:x:tst:7"/>
48+
</criteria>
49+
</definition>
50+
<definition class="compliance" version="1" id="oval:x:def:8">
51+
<metadata><title/><description/></metadata>
52+
<criteria operator="AND">
53+
<criterion test_ref="oval:x:tst:8"/>
54+
</criteria>
55+
</definition>
4456
</definitions>
4557
<tests>
4658
<file_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" check_existence="at_least_one_exists" version="1" id="oval:x:tst:1" check="all" comment="read file from directory 'a' - should be read">
@@ -61,6 +73,12 @@
6173
<filehash58_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" check_existence="none_exist" version="1" id="oval:x:tst:6" check="all" comment="read file from directory 'b' - should be skip">
6274
<object object_ref="oval:x:obj:6"/>
6375
</filehash58_test>
76+
<xmlfilecontent_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" check_existence="at_least_one_exists" version="1" id="oval:x:tst:7" check="all" comment="read file from directory 'a' - should be read">
77+
<object object_ref="oval:x:obj:7"/>
78+
</xmlfilecontent_test>
79+
<xmlfilecontent_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" check_existence="none_exist" version="1" id="oval:x:tst:8" check="all" comment="read file from directory 'b' - should be skip">
80+
<object object_ref="oval:x:obj:8"/>
81+
</xmlfilecontent_test>
6482
</tests>
6583
<objects>
6684
<file_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" version="1" id="oval:x:obj:1">
@@ -87,5 +105,13 @@
87105
<filepath>/tmp/oscap_test_skip_paths/b/y</filepath>
88106
<hash_type>SHA-512</hash_type>
89107
</filehash58_object>
108+
<xmlfilecontent_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" version="1" id="oval:x:obj:7">
109+
<filepath>/tmp/oscap_test_skip_paths/a/test.xml</filepath>
110+
<xpath>/parent</xpath>
111+
</xmlfilecontent_object>
112+
<xmlfilecontent_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" version="1" id="oval:x:obj:8">
113+
<filepath>/tmp/oscap_test_skip_paths/b/test.xml</filepath>
114+
<xpath>/parent</xpath>
115+
</xmlfilecontent_object>
90116
</objects>
91117
</oval_definitions>

0 commit comments

Comments
 (0)