Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/OVAL/probes/probe/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,8 @@ static void _add_blocked_paths(struct oscap_list *bpaths)
#else
char **paths = oscap_split(envar, ":");
for (int i = 0; paths[i]; ++i) {
if (paths[i][0] == '\0')
continue;
oscap_list_add(bpaths, strdup(paths[i]));
}
free(envar);
Expand Down
19 changes: 19 additions & 0 deletions tests/API/OVAL/skip_paths/test_skip_paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,24 @@
assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:8" and @flag="does not exist"]'
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"]'
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"]'

# Empty entries must not block any paths, just like an unset variable.
for ignore_paths in unset '' ':'; do
if [ "$ignore_paths" = unset ]; then

Check failure on line 53 in tests/API/OVAL/skip_paths/test_skip_paths.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=OpenSCAP_openscap&issues=AaH0MkwJdEzjuft7SWoR&open=AaH0MkwJdEzjuft7SWoR&pullRequest=2487
unset OSCAP_PROBE_IGNORE_PATHS
else
export OSCAP_PROBE_IGNORE_PATHS="$ignore_paths"
fi
$OSCAP oval eval --results $result "$srcdir/test_skip_paths.xml"
assert_exists 8 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@flag="complete"]'
assert_exists 2 '/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:file_item'
done

# Empty entries around real paths must not change which paths are blocked.
export OSCAP_PROBE_IGNORE_PATHS=":$root/n::$root/c:$root/b:"
$OSCAP oval eval --results $result "$srcdir/test_skip_paths.xml"
assert_exists 8 '/oval_results/results/system/definitions/definition[@result="true"]'
assert_exists 4 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@flag="complete"]'
assert_exists 4 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@flag="does not exist"]'
rm -f $result
rm -rf "$root"
Loading