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

feat: Added a fixture for integration tests to check selinux denials #312

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
19 changes: 16 additions & 3 deletions integration-tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import pytest
import subprocess
import time
import logging

logger = logging.getLogger(__name__)
from pytest_client_tools.util import logged_run


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -58,3 +56,18 @@ def loop_until(predicate, poll_sec=5, timeout_sec=120):
time.sleep(poll_sec)
ok = predicate()
return ok


@pytest.fixture(scope="session", autouse=True)
def collect_selinux_denials():
"""This fixture helps in catching selinux denials
in the system after tests are run."""
yield
command = "ausearch -m avc -m user_avc -m selinux_err -i".split()
result = logged_run(command, capture_output=True, text=True)
if "<no matches>" not in result.stdout:
lines = result.stdout.split("\n")
for line in lines:
words = line.split()
if "denied" in words:
assert "permissive=1" in words, "SELinux AVC denials found"
Loading