Debian Codegraph @

tests/API/OVAL/skip_paths/test_skip_paths.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 . $builddir/tests/test_common.sh
4
5 set -e -o pipefail
6
7 result=$(mktemp)
8 root="/tmp/oscap_test_skip_paths"
9 mkdir -p "$root/a"
10 touch "$root/a/x"
11 cp "$srcdir/test.xml" "$root/a/"
12 mkdir -p "$root/b"
13 touch "$root/b/y"
14 cp "$srcdir/test.xml" "$root/b/"
15 mkdir -p "$root/c"
16 touch "$root/c/z"
17 cp "$srcdir/test.xml" "$root/c/"
18 # oscap probes will skip directories "$root/n", "$root/b" and "$root/c"
19 export OSCAP_PROBE_IGNORE_PATHS="$root/n:$root/c:$root/b"
20 $OSCAP oval eval --results $result "$srcdir/test_skip_paths.xml"
21 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:1" and @result="true"]'
22 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:1" and @flag="complete"]'
23 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item'
24 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item/unix-sys:filepath[text()="/tmp/oscap_test_skip_paths/a/x"]'
25 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:2" and @result="true"]'
26 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:2" and @flag="does not exist"]'
27 assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item/unix-sys:filepath[text()="/tmp/oscap_test_skip_paths/b/y"]'
28 assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item/unix-sys:filepath[text()="/tmp/oscap_test_skip_paths/c/z"]'
29 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:3" and @result="true"]'
30 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:3" and @flag="complete"]'
31 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:textfilecontent_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/a/x"]'
32 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:4" and @result="true"]'
33 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:4" and @flag="does not exist"]'
34 assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:textfilecontent_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/b/y"]'
35 assert_exists 0 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:textfilecontent_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/c/z"]'
36 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:5" and @result="true"]'
37 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:5" and @flag="complete"]'
38 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:filehash58_item/ind-sys:filepath[text()="/tmp/oscap_test_skip_paths/a/x"]'
39 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:6" and @result="true"]'
40 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:6" and @flag="does not exist"]'
41 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"]'
42 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"]'
50 rm -f $result
51 rm -rf "$root"