diff --git a/tests/ffi/selinux/README.md b/tests/ffi/selinux/README.md new file mode 100644 index 00000000..ee38b312 --- /dev/null +++ b/tests/ffi/selinux/README.md @@ -0,0 +1,6 @@ +QM tests - Security + +QM test for default selinux mode on provided running image. + +This Test Suite includes these tests +1.Confirm that selinux enforcing mode can't be changed to Permissive. diff --git a/tests/ffi/selinux/main.fmf b/tests/ffi/selinux/main.fmf new file mode 100644 index 00000000..c73390b1 --- /dev/null +++ b/tests/ffi/selinux/main.fmf @@ -0,0 +1,5 @@ +summary: Check that inside QM command setenforce 0 must fail. +test: /bin/bash ./test.sh +duration: 10m +tag: ffi +framework: shell diff --git a/tests/ffi/selinux/test.sh b/tests/ffi/selinux/test.sh new file mode 100644 index 00000000..86eb12b5 --- /dev/null +++ b/tests/ffi/selinux/test.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# shellcheck disable=SC1091 +. ../common/prepare.sh + +#Preset with expected value the variable. +expected_value="setenforce: security_setenforce() failed: Permission denied" + +# Get setenforce 0 permission denied from qm. +setenforce_0=$(podman exec -it qm setenforce 0) + +echo "This is what qm returns $setenforce_0" + +#Check if setenforce 0 succeeds in QM container and fail the test if it does. +if [[ $setenforce_0 != *"$expected_value"* ]];then + echo "FAIL: setenforce 0: Attempt to change Selinux enforcement to 0 succeeded inside QM container." + exit 1 +fi + +echo "PASS: setenforce 0: Attempt to change Selinux enforcement to 0 denied successfully inside QM container." +exit 0