Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test QM selinux permissions #494

Merged
merged 2 commits into from
Jul 25, 2024
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
6 changes: 6 additions & 0 deletions tests/ffi/selinux/README.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions tests/ffi/selinux/main.fmf
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions tests/ffi/selinux/test.sh
Original file line number Diff line number Diff line change
@@ -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)
nsednev marked this conversation as resolved.
Show resolved Hide resolved

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