public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: harden tools to block rogue python modules
@ 2026-09-11 13:20 Amith Kumar
  0 siblings, 0 replies; only message in thread
From: Amith Kumar @ 2026-09-11 13:20 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 8f54ba515e28aed3bdf48b0ba5360d717f7d7a2f
            Author : Amith Kumar <apeetham@redhat.com>
            Date   : 2022-11-01T18:39:40+00:00
            Stats  : +157/-0 in 4 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/8f54ba515e28aed3bdf48b0ba5360d717f7d7a2f?branch=pr775-checkpolicy-revdeps

            Log:
            harden tools to block rogue python modules

Add test to policycoreutils/Regression suite which verifies bug 2128976
and ensures that irrelevant python scripts are not given precedence over
tools like semanage.

Signed-off-by: Amith Kumar <apeetham@redhat.com>

---
diff --git a/policycoreutils/python-module-precedence-issue/Makefile b/policycoreutils/python-module-precedence-issue/Makefile
new file mode 100644
index 0000000..a5c30d3
--- /dev/null
+++ b/policycoreutils/python-module-precedence-issue/Makefile
@@ -0,0 +1,65 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Makefile of /CoreOS/policycoreutils/Regression/python-module-precedence-issue
+#   Description: Tools like semanage must be hardened to avoid loading
+#   rogue python modules that could lead to unexpected failures.
+#   Author: Amith Kumar <apeetham@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2022 Red Hat, Inc.
+#
+#   This program is free software: you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation, either version 2 of
+#   the License, or (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be
+#   useful, but WITHOUT ANY WARRANTY; without even the implied
+#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#   PURPOSE.  See the GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+export TEST=/CoreOS/policycoreutils/Regression/python-module-precedence-issue
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+	./runtest.sh
+
+build: $(BUILT_FILES)
+	test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+	rm -f *~ $(BUILT_FILES)
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+	@echo "Owner:           Amith Kumar <apeetham@redhat.com>" > $(METADATA)
+	@echo "Name:            $(TEST)" >> $(METADATA)
+	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)
+	@echo "Path:            $(TEST_DIR)" >> $(METADATA)
+	@echo "Description:     Tools must be hardened to block unwanted python modules" >> $(METADATA)
+	@echo "Type:            Regression" >> $(METADATA)
+	@echo "TestTime:        1m" >> $(METADATA)
+	@echo "RunFor:          policycoreutils" >> $(METADATA)
+	@echo "Requires:        policycoreutils /usr/sbin/semanage" >> $(METADATA)
+	@echo "Priority:        Normal" >> $(METADATA)
+	@echo "License:         GPLv2+" >> $(METADATA)
+	@echo "Confidential:    no" >> $(METADATA)
+	@echo "Destructive:     no" >> $(METADATA)
+	@echo "Bug:             2128976" >> $(METADATA)
+	@echo "Releases:        -RHEL4 -RHELClient5 -RHELServer5 -RHEL6" >> $(METADATA)
+
+	rhts-lint $(METADATA)
+

diff --git a/policycoreutils/python-module-precedence-issue/PURPOSE b/policycoreutils/python-module-precedence-issue/PURPOSE
new file mode 100644
index 0000000..b392571
--- /dev/null
+++ b/policycoreutils/python-module-precedence-issue/PURPOSE
@@ -0,0 +1,4 @@
+PURPOSE of /CoreOS/policycoreutils/Regression/python-module-precedence-issue
+Description: Tools like semanage must be hardened to avoid loading rogue python modules that 
+             could lead to unexpected failures.
+Author: Amith Kumar <apeetham@redhat.com>

diff --git a/policycoreutils/python-module-precedence-issue/main.fmf b/policycoreutils/python-module-precedence-issue/main.fmf
new file mode 100644
index 0000000..48568bc
--- /dev/null
+++ b/policycoreutils/python-module-precedence-issue/main.fmf
@@ -0,0 +1,29 @@
+summary: Harden tools to avoid loading of unchecked python modules.
+description: Tools like semanage must be hardened to avoid loading rogue python modules that could lead to unexpected failures.
+contact: Amith Kumar <apeetham@redhat.com>
+
+component:
+  - policycoreutils
+test: ./runtest.sh
+framework: beakerlib
+recommend:
+  - policycoreutils
+  - /usr/sbin/semanage
+duration: 1m
+enabled: true
+tag:
+  - CI-Tier-1
+  - NoRHEL4
+  - NoRHEL5
+  - NoRHEL6
+  - TIPpass_Security
+  - TierCandidatesPASS
+  - f32friendly
+  - f33friendly
+  - targeted
+link:
+  - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2128976
+adjust:
+  - enabled: false
+    when: distro == rhel-4, rhel-5, rhel-6
+    continue: false

diff --git a/policycoreutils/python-module-precedence-issue/runtest.sh b/policycoreutils/python-module-precedence-issue/runtest.sh
new file mode 100755
index 0000000..7e91592
--- /dev/null
+++ b/policycoreutils/python-module-precedence-issue/runtest.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/policycoreutils/Regression/python-module-precedence-issue
+#   Description: Tools like semanage must be hardened to avoid loading
+#                rogue python modules that could lead to unexpected failures.
+#   Author: Amith Kumar <apeetham@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2022 Red Hat, Inc.
+#
+#   This program is free software: you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation, either version 2 of
+#   the License, or (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be
+#   useful, but WITHOUT ANY WARRANTY; without even the implied
+#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#   PURPOSE.  See the GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include Beaker environment
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="policycoreutils"
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlAssertRpm $PACKAGE
+        rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
+        rlRun "pushd $tmpDir"
+    rlPhaseEnd
+
+    rlPhaseStartTest "bz2128976 Tools must be hardened to not load rogue python modules"
+        # Create a custom python script in /usr/sbin
+cat > /usr/sbin/audit.py << EOF
+import sys
+print("BAD GUY!", file=sys.stderr)
+sys.exit(1)
+EOF
+        # List all boolean records
+        rlRun "semanage boolean -l > /dev/null" 0
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        # Remove irrelevant files
+        rlRun "rm /usr/sbin/audit.py"
+        rlRun "popd"
+        rlRun "rm -r $tmpDir" 0 "Removing tmp directory"
+    rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-11 13:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 13:20 [tests/selinux] pr775-checkpolicy-revdeps: harden tools to block rogue python modules Amith Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox