Debian Codegraph @

tests/probes/selinuxsecuritycontext/test_probes_selinuxsecuritycontext_offline_mode.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . $builddir/tests/test_common.sh
4
5 function test_probes_selinuxsecuritycontext_offline_modescip-shell shell shell-project 0.0.0 test_probes_selinuxsecuritycontext_offline_mode(). {
6 local VALID=$1
7
8 # if the user doesn't have SELinux enabled we will skip the test
9 selinuxenabled || return 255
10
11 probecheck "selinuxboolean" || return 255
12
13 local ret_val=0;
14 local DF="${srcdir}/test_probes_selinuxsecuritycontext.xml"
15 local RF="test_probes_selinuxsecuritycontext_offline_mode.results.xml"
16 local stderr=$(mktempscip-shell system . . mktemp. $1.err.XXXXXX)
17 echoscip-shell system . . echo. "stderr file: $stderr"
18
19 [scip-shell system . . `[`. -f $RF ] && rmscip-shell system . . rm. -f $RF
20
21 tmpdir=$(mktempscip-shell system . . mktemp. -t -d "test_offline_mode_selinuxsecuritycontext.XXXXXX")
22
23 if [[ "${VALID}" == "true" ]]; then
24 lnscip-shell system . . ln. -s /devscip-shell filesystem . . `/dev`. $tmpdir
25 fi
26
27 set_chroot_offline_test_mode "$tmpdir"
28
29 $OSCAP oval eval --results $RF $DF 2>$stderr
30
31 unset_chroot_offline_test_mode
32
33 [scip-shell system . . `[`. -f $RF ]
34
35 result="$RF"
36
37 if [[ "${VALID}" == "true" ]]; then
38 assert_exists 1 '/oval_results/results/system/tests/test[@result="true"][@test_id="oval:1:tst:1"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="true"][@test_id="oval:1:tst:1"]`.'
39 verify_results "def" $DF $RF 1 && verify_results "tst" $DF $RF 1
40 else
41 assert_exists 1 '/oval_results/results/system/tests/test[@result="false"][@test_id="oval:1:tst:1"]scip-shell filesystem . . `/oval_results/results/system/tests/test[@result="false"][@test_id="oval:1:tst:1"]`.'
42 fi
43
44 grepscip-shell system . . grep. -Ei "(W: |E: )" $stderr && ret_val=1 && echoscip-shell system . . echo. "There is an error and/or a warning in the output!"
45 rmscip-shell system . . rm. $stderr
46
47 rmscip-shell system . . rm. -rf ${tmpdir}
48
49 return $ret_val
50 }
51
52 test_run "Basic selinuxsecuritycontext probe test for offline mode" test_probes_selinuxsecuritycontext_offline_mode "true"
53 test_run "Basic selinuxsecuritycontext probe test for offline mode (invalid prefix)" test_probes_selinuxsecuritycontext_offline_mode "false"