Compare commits

...
Sign in to create a new pull request.

76 commits

Author SHA1 Message Date
Python Maint
cd91f1ad1b Rebuilt for Python 3.14.0rc3 bytecode 2025-09-19 15:00:53 +02:00
Vit Mojzis
0d4aedc83e tests: Convert remaining STI tests to TMT
Sanity tests were already converted.

https://fedoraproject.org/wiki/Changes/DisableSTI

Note: udica-*[0-9]/ was needed because the source directory contained 2
udica folders: udica-0.2.8, udica-0.2.8-SPECPARTS

Fixes: https://issues.redhat.com/browse/FC-1894
2025-08-27 10:05:58 +02:00
Python Maint
a698b129e8 Rebuilt for Python 3.14.0rc2 bytecode 2025-08-15 15:21:11 +02:00
Fedora Release Engineering
ca33861f5e Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild 2025-07-25 19:42:41 +00:00
Python Maint
15036e2280 Rebuilt for Python 3.14 2025-06-02 20:53:40 +02:00
Milos Malik
0280f38935 update the list of tested containers
The following error message appears when some of the containers
are tested:
 * Could not resolve host: mirrorlist.centos.org; Unknown error

Here is the list of containers which reveal the problem:
 * centos:stream8
 * centos:7

From now on, the list of tested containers does not contain them.
2025-03-07 23:13:58 +01:00
Petr Lautrbach
c97d161804 pyprojectize spec file
The old %py3_build and %py3_install macros (201x-era) as documented in [1] use
a deprecated feature of setuptools.

It is highly recommended to use the current %pyproject macros instead as
documented in [2] and [3] sooner than it becomes necessary.

[1]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_201x/
[2]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/
[3]: https://src.fedoraproject.org/rpms/pyproject-rpm-macros/blob/rawhide/f/README.md

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/RFHSXAU2D4PEN2KHZCBUGP6MEGTUOUD2/
2025-03-07 23:13:27 +01:00
Fedora Release Engineering
46f7cd3660 Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild 2025-01-19 13:36:41 +00:00
Fedora Release Engineering
a4553748a3 Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild 2024-07-20 08:08:01 +00:00
Python Maint
91734a3b33 Rebuilt for Python 3.13 2024-06-07 09:12:10 +02:00
Milos Malik
9d53f17405 ensure the udica package is installed before test run
The automated test uses the following file which is shipped in the
udica package:
 * /usr/share/udica/macros/confined_user_macros.cil

Unfortunately, the udica package was not listed in the main.fmf file
as recommended or required. The problem should be fixed now.
2024-04-25 17:26:15 +02:00
Milos Malik
2421f40c3b run the existing tests via TMT/FMF
Use the TMT/FMF instead of STI for running tests. STI does not respect
the adjust section in main.fmf files of stored tests.

Add missing main.fmf files to tests which are not TMT/FMF enabled.
2024-04-03 08:48:05 +02:00
Vit Mojzis
241fdf3a8a tests: Initialize metadata tree
Needed to run tests using fmf automation.

Move the version file introduced by
"f6cea24f4 tests/confined: Initialize metadata tree"
into the top-level directory.
2024-03-26 10:17:23 +01:00
Vit Mojzis
f6cea24f4d tests/confined: Initialize metadata tree
Needed to run the test using fmf automation.
2024-03-26 09:58:59 +01:00
Vit Mojzis
1702ce63fc Udica confined_user tests
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2024-03-04 19:02:27 +01:00
Vit Mojzis
810c5dd87d udica-0.2.8-4
- confined: make "-l" non optional
- confined: allow asynchronous I/O operations
2024-03-04 13:04:44 +01:00
Fedora Release Engineering
ddb7e251dc Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-27 06:58:54 +00:00
Vit Mojzis
a3c99dc617 udica-0.2.8-2
- Add option to generate custom policy for a confined user
2023-12-21 00:10:00 +01:00
Vit Mojzis
5e0609b1fe udica-0.2.8
New release https://github.com/containers/udica/releases/tag/v0.2.8
2023-11-29 12:36:32 +01:00
Fedora Release Engineering
b6b5088980 Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-07-22 16:59:26 +00:00
Python Maint
e5322cdeac Rebuilt for Python 3.12 2023-06-13 21:00:03 +02:00
Vit Mojzis
4a53696b71 udica-0.2.7-5
- Show diff when checking formatting
- Fix several lint findings
- Fix generating policy for Crio mounts

Fixes:
  https://github.com/containers/udica/issues/118
2023-04-20 17:25:50 +02:00
Fedora Release Engineering
9bc541dfba Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-21 05:40:44 +00:00
Petr Lautrbach
de462f29e0 Migrate License tag to SPDX
https://fedoraproject.org/wiki/Changes/SPDX_Licenses_Phase_1
2022-12-01 12:37:55 +01:00
Vit Mojzis
ad353df40c udica-0.2.7-3
- Add --devices option

Fixes:
  https://github.com/containers/udica/issues/110
2022-10-21 15:23:51 +02:00
Fedora Release Engineering
91cdda68b3 Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-07-23 11:15:52 +00:00
Vit Mojzis
879af9f4cc udica-0.2.7
New release https://github.com/containers/udica/releases/tag/v0.2.7

- Add support for containerd via "nerdctl inspect"
- Avoid duplicate rules for accessing mounts and devices

Fixes:
  https://github.com/containers/udica/issues/90
  https://github.com/containers/udica/issues/7
Related:
  https://github.com/containers/udica/issues/84
2022-06-22 14:43:27 +02:00
Python Maint
b78fa64042 Rebuilt for Python 3.11 2022-06-13 15:42:40 +02:00
Vit Mojzis
1d04ad9053 udica-0.2.6-4
- Improve label collection for mounts and devices

Fixes:
  https://github.com/containers/udica/issues/98
  https://github.com/containers/udica/issues/109
2022-05-02 15:59:53 +02:00
Vit Mojzis
d433a427be tests/Sanity: Use centos-stream 8 container
CentOS-8 is EOL.

Fixes:
  :: [ 08:38:17 ] :: [  BEGIN   ] :: Running 'podman exec test yum install nmap-ncat -y'
  CentOS Linux 8 - AppStream                       31  B/s |  38  B     00:01
  Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
2022-02-10 13:42:16 +01:00
Fedora Release Engineering
e10e896cd4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-01-22 03:24:15 +00:00
Vit Mojzis
f42dfe4da4 udica-0.2.6-2
- Make sure each section of the inspect exists before accessing

Fixes:
        https://github.com/containers/udica/issues/103
        https://github.com/containers/udica/issues/105
2021-11-11 18:15:09 +01:00
Vit Mojzis
4eba9fb544 udica-0.2.6-1
- New release https://github.com/containers/udica/releases/tag/v0.2.6
- Move policy templates to container-selinux repo
2021-09-30 09:41:26 +02:00
Vit Mojzis
7ea190fa1e tests: Require container-selinux
Policy templates where moved to container-selinux package and udica
doesn't work properly without them.

Sanity test temporarily needs git for downloading policy templates.
Those will soon be available via container-selinux.

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2021-09-30 09:41:20 +02:00
Vit Mojzis
c1190761ae udica-0.2.5-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.5
- Replace capability dictionary with str.lower()
- Enable udica to generate policies with fifo class
- Sort container inspect data before processing
- Update templates to work properly with new cil parser
2021-08-26 18:54:12 +02:00
Lukas Vrabec
41b007ecf3 Update 'tests/sanity' to include more containers
Sanity testcase generates SELinux policy just for one container
"fedora:latest". Testcase should test generating SELinux policy also for
Fedora Rawhide container, RHEL universal base image {7,8} and centos containers
2021-08-20 11:48:36 +02:00
Fedora Release Engineering
aa4e7af453 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-07-23 19:55:18 +00:00
Python Maint
cdec489222 Rebuilt for Python 3.10 2021-06-04 21:18:38 +02:00
Vit Mojzis
d4f16fdce9 Revert "Add %check section to run basic tests during rpm build process"
The check is not necessary since it's part of the CI and brings needless
dependencies.

This reverts commits fa6f003ec4 and
4dc4b32e96.
2021-03-09 20:51:07 +01:00
Fedora Release Engineering
1adfa9bfe1 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-01-27 22:33:53 +00:00
Tom Stellard
4dc4b32e96 Add BuildRequires: make
https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot
2021-01-12 01:32:30 +00:00
Lukas Vrabec
fa6f003ec4
* Sun Dec 13 2020 Lukas Vrabec <lvrabec@redhat.com> - 0.2.4-2
- Add %check section to run basic tests during rpm build process
2020-12-13 15:23:31 +01:00
Lukas Vrabec
651491f476
* Wed Nov 25 2020 Lukas Vrabec <lvrabec@redhat.com> - 0.2.4-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.4
2020-11-25 18:12:12 +01:00
Lukas Vrabec
e23d97dbf9
* Thu Aug 13 2020 Lukas Vrabec <lvrabec@redhat.com> - 0.2.3-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.3
2020-08-13 17:35:37 +02:00
Lukas Vrabec
fe5d494410
* Mon Aug 03 2020 Lukas Vrabec <lvrabec@redhat.com> - 0.2.2-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.2
2020-08-03 19:06:03 +02:00
Fedora Release Engineering
40b7e49704 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-07-29 13:10:13 +00:00
Miro Hrončok
9f4d139c0d Rebuilt for Python 3.9 2020-05-26 03:53:49 +02:00
Fedora Release Engineering
6f387b8fff - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-31 02:26:26 +00:00
Lukas Vrabec
0bfe40deeb
* Fri Oct 25 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.2.1-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.1
2019-10-25 22:15:32 +02:00
Lukas Vrabec
10b8af4057
Fix CI tests on udica
In version v0.2.0 there is new makefile also for testing part, therefore
we changed how to execute tests. This commit fixes the Fedora CI.
2019-10-02 16:59:23 +02:00
Lukas Vrabec
c6e6561646
Remove patch which is already part of new rebase 2019-09-25 10:25:50 +02:00
Lukas Vrabec
889004a547
* Wed Sep 25 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.2.0-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.0
2019-09-25 10:20:25 +02:00
Lukas Vrabec
10b87117f0
Fix sanity test suite
Fix sanity test to pass on Fedora Rawhide and Fedora 30. Changes are
related to missing 'nc' command in container for which SELinux policy is
generated.
2019-08-28 13:28:59 +02:00
Lukas Vrabec
c78730bf59
* Wed Aug 28 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.9-1
- Update tests test_basic.podman.cil, test_basic.docker.cil. Round 2
- New rebase https://github.com/containers/udica/releases/tag/v0.1.9
2019-08-28 13:19:42 +02:00
Miro Hrončok
169e204028 Rebuilt for Python 3.8 2019-08-19 11:08:38 +02:00
Fedora Release Engineering
fa1600ac43 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-07-27 02:19:45 +00:00
Lukas Vrabec
808f498283
* Thu Jul 11 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.8-1
- New rebase https://github.com/containers/udica/releases/tag/v0.1.8
2019-07-11 13:08:38 +02:00
Lukas Vrabec
4312e208b7
Update spec file to include /usr/share/udica/ansible directory with all files. 2019-06-12 14:10:23 +02:00
Lukas Vrabec
5e1c32f75c
* Wed Jun 12 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.7-1
- New rebase with upstream adding new param --ansible, to generate ansible playbook for deploying policies. https://github.com/containers/udica/releases/tag/v0.1.7
2019-06-12 13:54:49 +02:00
Lukas Vrabec
0ed8760d59
Update tests suite with downstream test
Following commit adds new donwstream beakerlib sanity test
2019-06-11 11:07:59 +02:00
Lukas Vrabec
d41c9dc7d9
* Thu May 16 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.6-1
- New rebase with upstream adding new tests
2019-05-16 19:36:00 +02:00
Jan Zarsky
5a7674a653 Remove patches 2019-05-16 15:41:17 +02:00
Lukas Vrabec
5ac5425819 Merge #4 Run tests also with real selinux and semanage modules 2019-05-15 12:44:15 +00:00
Lukas Vrabec
7206c3348a Merge #3 [WIP] Add basic sanity integration tests 2019-05-15 12:43:18 +00:00
Jan Zarsky
05d2672bde Run tests with real selinux and semanage modules
The tests are by default using mock selinux and semanage modules. Rerun
the tests with real modules.
2019-05-07 11:52:54 +02:00
Jan Zarsky
f8f4c7531f Add an option for running tests with real modules
To simplify udica testing on Fedora, add an option that allows running
the tests with real system packages (selinux and semanage).
2019-05-07 11:52:54 +02:00
Lukas Vrabec
cc9c2dc124
* Tue Apr 30 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.5-2
- Add allow rules for container_runtime_t to base_container.cil, Podman version 1.2.0 requires new allow rules.
2019-04-30 14:12:42 +02:00
Jan Zarsky
0037a4e5ec Add basic sanity integration tests
Check that udica can create policy for both podman and docker
containers. Check that generated policy can be loaded. Check that
generated policy provides required access.
2019-04-30 09:50:17 +02:00
Lukas Vrabec
94598a163f
Add basic sanity tests 2019-04-25 14:27:33 +02:00
Lukas Vrabec
4aea2395ce
* Fri Apr 19 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.5-1
- Create mock selinux and semanage module
- Update testing section in README
- Add travis file for Travis CI
- Grammar fixes in the udica.8 manpage file
- Support port ranges (Resolves: #16)
- Test port ranges
2019-04-19 20:43:16 +02:00
Lukas Vrabec
003b3a8115
* Mon Mar 11 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.4-1
- Fix minor problems reported by pylint #11
- Catch FileNotFoundError when inspecting containers #12
- Create basic tests #13
- Restore working directory #14
- udica cannot use the container ID once it is provided #10
2019-03-11 13:44:57 +01:00
Lukas Vrabec
3cee827b9e
* Mon Feb 25 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.3-4
- Update manpage with the latest known bug described in https://github.com/containers/udica/issues/8
- Add check if runtimes are installed on the system
2019-02-25 23:08:35 +01:00
Lukas Vrabec
d575e66328
* Sun Feb 17 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.3-3
- Improve capability parsing for docker containers
- Update small changes in manpage, like issue with mandatory option '-c' for docker containers
- Fix parsing Mountpoints in docker inspect JSON file
2019-02-17 22:59:23 +01:00
Fedora Release Engineering
979ba3e195 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-03 10:40:11 +00:00
Lukas Vrabec
c30c477009
* Wed Jan 23 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.3-1
- Fix capability allow rules when capabilities are specified in JSON file
- Add additional SELinux allow rules to base container template to allow container to read proc_type types.
2019-01-23 17:13:07 +01:00
Lukas Vrabec
47068c8c1e
* Fri Jan 04 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.2-0
- Fix invalid syntax output when policy is using just one template
Resolves: #6
2019-01-04 00:32:08 +01:00
27 changed files with 6090 additions and 28 deletions

1
.fmf/version Normal file
View file

@ -0,0 +1 @@
1

17
.gitignore vendored
View file

@ -1 +1,18 @@
/v0.1.1.tar.gz
/v0.1.2.tar.gz
/v0.1.3.tar.gz
/v0.1.4.tar.gz
/v0.1.5.tar.gz
/v0.1.6.tar.gz
/v0.1.7.tar.gz
/v0.1.8.tar.gz
/v0.1.9.tar.gz
/v0.2.0.tar.gz
/v0.2.1.tar.gz
/v0.2.2.tar.gz
/v0.2.3.tar.gz
/v0.2.4.tar.gz
/v0.2.5.tar.gz
/v0.2.6.tar.gz
/v0.2.7.tar.gz
/v0.2.8.tar.gz

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,170 @@
From d444e67ead27266d57184ab8bc032c5528f7e26c Mon Sep 17 00:00:00 2001
From: Vit Mojzis <vmojzis@redhat.com>
Date: Wed, 20 Dec 2023 14:33:27 +0100
Subject: [PATCH] Add tests covering confined user policy generation
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
tests/test_confined_abcdgilmns.cil | 24 ++++++++++++++++++++
tests/test_confined_cla.cil | 15 +++++++++++++
tests/test_confined_lb.cil | 12 ++++++++++
tests/test_confined_lsid.cil | 17 +++++++++++++++
tests/test_main.py | 35 +++++++++++++++++++++++++-----
5 files changed, 98 insertions(+), 5 deletions(-)
create mode 100644 tests/test_confined_abcdgilmns.cil
create mode 100644 tests/test_confined_cla.cil
create mode 100644 tests/test_confined_lb.cil
create mode 100644 tests/test_confined_lsid.cil
diff --git a/tests/test_confined_abcdgilmns.cil b/tests/test_confined_abcdgilmns.cil
new file mode 100644
index 0000000..5fd619f
--- /dev/null
+++ b/tests/test_confined_abcdgilmns.cil
@@ -0,0 +1,24 @@
+(boolean my_container_exec_content true)
+(role my_container_r)
+(type my_container_dbus_t)
+(type my_container_gkeyringd_t)
+(type my_container_ssh_agent_t)
+(type my_container_sudo_t)
+(type my_container_sudo_tmp_t)
+(type my_container_t)
+(type my_container_userhelper_t)
+(user my_container_u)
+(userrole my_container_u my_container_r)
+(userlevel my_container_u (s0))
+(userrange my_container_u ((s0 ) (s0 (c0))))
+
+(call confinedom_admin_commands_macro (my_container_t my_container_r my_container_sudo_t))
+(call confinedom_graphical_login_macro (my_container_t my_container_r my_container_dbus_t))
+(call confinedom_mozilla_usage_macro (my_container_t my_container_r))
+(call confinedom_networking_macro (my_container_t my_container_r))
+(call confinedom_security_advanced_macro (my_container_t my_container_r my_container_sudo_t my_container_userhelper_t))
+(call confinedom_security_basic_macro (my_container_t my_container_r))
+(call confinedom_sudo_macro (my_container_t my_container_r my_container_sudo_t my_container_sudo_tmp_t))
+(call confinedom_user_login_macro (my_container_t my_container_r my_container_gkeyringd_t my_container_dbus_t my_container_exec_content))
+(call confined_ssh_connect_macro (my_container_t my_container_r my_container_ssh_agent_t))
+(call confined_use_basic_commands_macro (my_container_t my_container_r))
\ No newline at end of file
diff --git a/tests/test_confined_cla.cil b/tests/test_confined_cla.cil
new file mode 100644
index 0000000..a633aaa
--- /dev/null
+++ b/tests/test_confined_cla.cil
@@ -0,0 +1,15 @@
+(boolean my_container_exec_content true)
+(role my_container_r)
+(type my_container_dbus_t)
+(type my_container_gkeyringd_t)
+(type my_container_ssh_agent_t)
+(type my_container_sudo_t)
+(type my_container_t)
+(user my_container_u)
+(userrole my_container_u my_container_r)
+(userlevel my_container_u (s0))
+(userrange my_container_u ((s0 ) (s0 (c0))))
+
+(call confinedom_admin_commands_macro (my_container_t my_container_r my_container_sudo_t))
+(call confinedom_user_login_macro (my_container_t my_container_r my_container_gkeyringd_t my_container_dbus_t my_container_exec_content))
+(call confined_ssh_connect_macro (my_container_t my_container_r my_container_ssh_agent_t))
\ No newline at end of file
diff --git a/tests/test_confined_lb.cil b/tests/test_confined_lb.cil
new file mode 100644
index 0000000..3e3c997
--- /dev/null
+++ b/tests/test_confined_lb.cil
@@ -0,0 +1,12 @@
+(boolean my_container_exec_content true)
+(role my_container_r)
+(type my_container_dbus_t)
+(type my_container_gkeyringd_t)
+(type my_container_t)
+(user my_container_u)
+(userrole my_container_u my_container_r)
+(userlevel my_container_u (s0))
+(userrange my_container_u ((s0 ) (s0 (c0))))
+
+(call confinedom_user_login_macro (my_container_t my_container_r my_container_gkeyringd_t my_container_dbus_t my_container_exec_content))
+(call confined_use_basic_commands_macro (my_container_t my_container_r))
\ No newline at end of file
diff --git a/tests/test_confined_lsid.cil b/tests/test_confined_lsid.cil
new file mode 100644
index 0000000..8719420
--- /dev/null
+++ b/tests/test_confined_lsid.cil
@@ -0,0 +1,17 @@
+(boolean my_container_exec_content true)
+(role my_container_r)
+(type my_container_dbus_t)
+(type my_container_gkeyringd_t)
+(type my_container_sudo_t)
+(type my_container_sudo_tmp_t)
+(type my_container_t)
+(type my_container_userhelper_t)
+(user my_container_u)
+(userrole my_container_u my_container_r)
+(userlevel my_container_u (s0))
+(userrange my_container_u ((s0 ) (s0 (c0))))
+
+(call confinedom_security_advanced_macro (my_container_t my_container_r my_container_sudo_t my_container_userhelper_t))
+(call confinedom_security_basic_macro (my_container_t my_container_r))
+(call confinedom_sudo_macro (my_container_t my_container_r my_container_sudo_t my_container_sudo_tmp_t))
+(call confinedom_user_login_macro (my_container_t my_container_r my_container_gkeyringd_t my_container_dbus_t my_container_exec_content))
\ No newline at end of file
diff --git a/tests/test_main.py b/tests/test_main.py
index fb6a9ab..0c73861 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -369,7 +369,26 @@ class TestBase(unittest.TestCase):
self.assert_templates(output, ["base_container"])
self.assert_policy(test_file("test_devices.podman.cil"))
- def run_udica(self, args):
+ # Confined user tests
+ def test_confined_user(self):
+ """udica confined_user <args> --level s0 --range s0:c0 my_container"""
+ for arg in ["cla", "lb", "lsid", "abcdgilmns"]:
+ output = self.run_udica(
+ [
+ "udica",
+ "confined_user",
+ "-{}".format(arg),
+ "--level",
+ "s0",
+ "--range",
+ "s0:c0",
+ "my_container",
+ ],
+ True,
+ )
+ self.assert_policy(test_file("test_confined_{}.cil".format(arg)))
+
+ def run_udica(self, args, confined=False):
with patch("sys.argv", args):
with patch("sys.stderr.write") as mock_err, patch(
"sys.stdout.write"
@@ -383,10 +402,16 @@ class TestBase(unittest.TestCase):
udica.__main__.main()
mock_err.assert_not_called()
- self.assertRegex(mock_out.output, "Policy my_container created")
- self.assertRegex(
- mock_out.output, "--security-opt label=type:my_container.process"
- )
+ if confined:
+ self.assertRegex(mock_out.output, "semodule -i my_container.cil")
+ self.assertRegex(
+ mock_out.output, "semanage login -a -s my_container_u my_container"
+ )
+ else:
+ self.assertRegex(mock_out.output, "Policy my_container created")
+ self.assertRegex(
+ mock_out.output, "--security-opt label=type:my_container.process"
+ )
return mock_out.output
--
2.43.0

View file

@ -0,0 +1,57 @@
From f411c146986fabe7375724528b2d4ba8cf78b904 Mon Sep 17 00:00:00 2001
From: Vit Mojzis <vmojzis@redhat.com>
Date: Mon, 12 Feb 2024 19:38:14 +0100
Subject: [PATCH] confined: make "-l" non optional
The confinedom_user_login_macro is needed for all custom users.
Also, allow the new user type to be accessed via remote login.
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
udica/__main__.py | 2 +-
udica/macros/confined_user_macros.cil | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/udica/__main__.py b/udica/__main__.py
index 1ba8515..801499c 100644
--- a/udica/__main__.py
+++ b/udica/__main__.py
@@ -92,7 +92,7 @@ def get_args():
"-l",
"--user_login",
action="store_true",
- default=False,
+ default=True,
dest="user_login",
help="Basic rules common to all users (tty, pty, ...)",
)
diff --git a/udica/macros/confined_user_macros.cil b/udica/macros/confined_user_macros.cil
index ddb5689..06c4c56 100644
--- a/udica/macros/confined_user_macros.cil
+++ b/udica/macros/confined_user_macros.cil
@@ -2411,7 +2411,7 @@
(typetransition utype sudo_exec_t process sudo_type)
(allow sudo_type utype (fd (use)))
(allow sudo_type utype (fifo_file (ioctl read write getattr lock append)))
- (allow sudo_type utype (process (sigchld)))
+ (allow sudo_type utype (process (getpgid sigchld)))
(allow sudo_type bin_t (dir (getattr open search)))
(allow sudo_type bin_t (dir (ioctl read getattr lock open search)))
(allow sudo_type bin_t (dir (getattr open search)))
@@ -4006,6 +4006,12 @@
)
)
)
+ ; Telnet login
+ (optional confinedom_user_login_optional_3
+ (typeattributeset cil_gen_require remote_login_t)
+ (allow remote_login_t utype (process (signal transition)))
+ (allow utype self (bpf (prog_load)))
+ )
)
(macro confined_ssh_connect_macro ((type utype) (role urole) (type ssh_agent_type))
--
2.43.0

View file

@ -0,0 +1,31 @@
From 131d228c6a91eaaeccc1d000821beeccba69d134 Mon Sep 17 00:00:00 2001
From: Vit Mojzis <vmojzis@redhat.com>
Date: Mon, 4 Mar 2024 12:59:53 +0100
Subject: [PATCH] confined: allow asynchronous I/O operations
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
udica/macros/confined_user_macros.cil | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/udica/macros/confined_user_macros.cil b/udica/macros/confined_user_macros.cil
index 06c4c56..dcb5198 100644
--- a/udica/macros/confined_user_macros.cil
+++ b/udica/macros/confined_user_macros.cil
@@ -4012,6 +4012,13 @@
(allow remote_login_t utype (process (signal transition)))
(allow utype self (bpf (prog_load)))
)
+ ; asynchronous I/O operations RHEL 10
+ (optional confinedom_user_login_optional_4
+ (typeattributeset cil_gen_require io_uring_t)
+ (allow utype self (io_uring (sqpoll)))
+ (allow utype io_uring_t (anon_inode (create)))
+ (allow utype io_uring_t (anon_inode (read write getattr map)))
+ )
)
(macro confined_ssh_connect_macro ((type utype) (role urole) (type ssh_agent_type))
--
2.43.0

View file

@ -0,0 +1,30 @@
From a9440c7de24e39084bc5f5970bd22eaf224a237f Mon Sep 17 00:00:00 2001
From: Petr Lautrbach <lautrbach@redhat.com>
Date: Fri, 11 Oct 2024 14:18:07 +0200
Subject: [PATCH] use relative paths, it's undefined behavior with absolute
Content-type: text/plain
---
setup.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/setup.py b/setup.py
index d3f20f49bdb0..7a29a6f57d8c 100644
--- a/setup.py
+++ b/setup.py
@@ -35,9 +35,9 @@ setuptools.setup(
packages=["udica"],
python_requires=">=3.4, <4",
data_files=[
- ("/usr/share/licenses/udica", ["LICENSE"]),
- ("/usr/share/udica/ansible", ["udica/ansible/deploy-module.yml"]),
- ("/usr/share/udica/macros", ["udica/macros/confined_user_macros.cil"]),
+ ("share/licenses/udica", ["LICENSE"]),
+ ("share/udica/ansible", ["udica/ansible/deploy-module.yml"]),
+ ("share/udica/macros", ["udica/macros/confined_user_macros.cil"]),
],
# scripts=["bin/udica"],
entry_points={"console_scripts": ["udica=udica.__main__:main"]},
--
2.47.0

18
plans/smoke.fmf Normal file
View file

@ -0,0 +1,18 @@
discover:
- how: shell
dist-git-source: true
tests:
- name: /smoke
test: cd $TMT_SOURCE_DIR/udica-*[0-9]/ && python3 -m unittest -v tests/test_unit.py
- name: /smoke2
test: cd $TMT_SOURCE_DIR/udica-*[0-9]/ && python3 tests/test_integration.py
prepare:
- name: install packages
how: install
package:
- udica
- python3
- container-selinux
- git-core
execute:
how: tmt

6
plans/tests.fmf Normal file
View file

@ -0,0 +1,6 @@
summary: basic udica test plan
discover:
how: fmf
execute:
how: tmt

View file

@ -1 +1 @@
SHA512 (v0.1.1.tar.gz) = abf4bdd0e9d84fd5233f1f10494c11c40ef03dcb820c545d7ef0f003bd9e72b6dc60715f56296ec59380a6d9327cf255d50edd3bd23a30e700c322d134302f2a
SHA512 (v0.2.8.tar.gz) = 513d932cad65d75b5aa753f2b0e4a99c0f5fa930740c65c20343521bc74deca13b140a69b78ab001dcd144a14254d1dda8ca8989531070e545fddbb08c1e64f0

68
tests/confined/Makefile Normal file
View file

@ -0,0 +1,68 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /pkgs.fedoraproject.org/rpms/udica/tests/confined
# Description: Test basic use cases of confined user policies generated by udica
# Authors: Milos Malik <mmalik@redhat.com>, Vit Mojzis <vmojzis@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/udica/confined
export TESTVERSION=1.0
BUILT_FILES=
SCRIPTS=a.sh b.sh d.sh i.sh l.sh n.sh s.sh
FILES=$(METADATA) test.sh Makefile $(SCRIPTS) ssh.exp telnet.exp
.PHONY: all install download clean
run: $(FILES) build
./test.sh
build: $(BUILT_FILES)
chmod a+x test.sh ssh.exp telnet.exp $(SCRIPTS)
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Vit Mojzis <vmojzis@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic use cases of confined user policies generated by udica" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 60m" >> $(METADATA)
@echo "RunFor: udica" >> $(METADATA)
@echo "Requires: udica expect" >> $(METADATA)
@echo "Requires: /usr/sbin/semanage" >> $(METADATA)
@echo "Requires: traceroute tcpdump setools-console policycoreutils-devel bind-utils" >> $(METADATA)
@echo "Requires: grep telnet telnet-server net-tools" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL4 -RHEL5 -RHEL6 -RHEL7" >> $(METADATA)
rhts-lint $(METADATA)

13
tests/confined/a.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh -x
on_err(){
echo "Error"
}
trap 'on_err' ERR
# gets stuck -- no journal entries
#sudo journalctl -n 1 --no-pager
sudo systemctl --no-pager status dbus
sudo netstat -g
sudo nslookup www.google.com
sudo sysctl net.ipv4.udp_mem

17
tests/confined/b.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh -x
on_err(){
echo "Error"
}
trap 'on_err' ERR
id -Z
date
ls ~
ps
man -f selinux
systemctl --no-pager --user status dbus | grep "D-Bus User Message Bus"
journalctl -user
# cannot rotate the orgiginal password as user
#echo -e "$1\n9$1\n9$1" | passwd
#echo -e "9$1\n$1\n$1" | passwd

12
tests/confined/d.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh -x
on_err(){
echo "Error"
}
trap 'on_err' ERR
sesearch -A -s httpd_t -t http_port_t -c tcp_socket
sudo semanage user -l
sudo semanage fcontext -lC
sudo semodule -B
sudo sepolicy network -p 44322

11
tests/confined/i.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh -x
on_err(){
echo "Error"
}
trap 'on_err' ERR
seinfo
getsebool httpd_can_connect_ftp
sesearch -A -s httpd_t -t http_port_t -c tcp_socket

2
tests/confined/l.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh -x
id -Z

34
tests/confined/main.fmf Normal file
View file

@ -0,0 +1,34 @@
summary: Concise summary describing what the test does
description: |+
Test basic functionality of sepolicy_confine tool
contact: Vit Mojzis <vmojzis@redhat.com>
component:
- policycoreutils
- udica
test: ./test.sh
framework: beakerlib
recommend:
- policycoreutils
- /usr/sbin/semanage
- expect
- net-tools
- traceroute
- tcpdump
- setools-console
- policycoreutils-devel
- bind-utils
- grep
- telnet
- telnet-server
- udica
duration: 60m
enabled: true
tag:
- NoRHEL4
- NoRHEL5
- targeted
adjust:
- enabled: false
when: distro == rhel-4, rhel-5, rhel-6, rhel-7
continue: false

15
tests/confined/n.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh -x
on_err(){
echo "Error"
}
trap 'on_err' ERR
ip address
ifconfig -s
traceroute 127.0.0.1
# this may block the test if there is no trafic !!!
sudo tcpdump -i any -c 1
netstat -g
nslookup www.google.com
ping -c 1 127.0.0.1

9
tests/confined/s.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh -x
on_err(){
echo "Error"
}
trap 'on_err' ERR
sudo id -Z
sudo passwd -S root

23
tests/confined/ssh.exp Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/expect -f
# Expect script for SSH logging as $username to $hostname using $password and executing $command.
# Usage:
# ./ssh.exp username password hostname command
set username [lrange $argv 0 0]
set password [lrange $argv 1 1]
set hostname [lrange $argv 2 2]
set command [lrange $argv 3 10]
set timeout 300
# connect to remote host and execute given command
log_user 1
spawn ssh -t $username@$hostname $command
expect {
-nocase "yes/no" { send -- "yes\r" ; exp_continue }
-nocase "password" { send -- "$password\r" }
}
#expect {
# "[sudo] password" {send -- "$password" ; exp_continue }
#}
log_user 1
# send -- "\r"
expect eof

24
tests/confined/telnet.exp Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/expect -f
# Expect script for telnet logging as $username to $hostname using $password and executing $command.
# Usage:
# ./telnet.exp username password hostname command
set username [lrange $argv 0 0]
set password [lrange $argv 1 1]
set hostname [lrange $argv 2 2]
set command [lrange $argv 3 10]
#set timeout 300
# connect to remote host and execute given command
log_user 1
spawn telnet $hostname 23
expect {
-nocase "yes/no" { send -- "yes\r" ; exp_continue }
-nocase "password" { send -- "$password\r" ; exp_continue }
-nocase "kernel" { send -- "$username\r" ; exp_continue }
-nocase "last login" { send -- "$command\r" }
}
log_user 1
send -- "\r"
sleep 1
expect eof

89
tests/confined/test.sh Executable file
View file

@ -0,0 +1,89 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="selinux-policy"
POLICY_OPTIONS=${POLICY_OPTIONS:-"lbc clbsa lbsidca lbscid lbsidc agmndislcb"}
TEST_SCRIPTS="abdilns"
#SEPOLICY_CONFINE="confined-users-policy/sepolicy_confine/sepolicy_confine"
SEPOLICY_CONFINE="udica confined_user"
rlJournalStart
rlPhaseStartSetup
rlRun "set -o pipefail"
rlRun "systemctl start telnet.socket"
if [ -d /etc/ssh/sshd_config.d ] ; then
rlRun "echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config.d/001-enable-password.conf"
rlRun "service sshd restart"
fi
rlRun "semodule -i /usr/share/udica/macros/confined_user_macros.cil"
rlRun "setsebool ssh_sysadm_login on"
# do not show "With great power comes great responsibility." prompt
# and don't ask for password when using "sudo"
echo "%users ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/confined_users_test;
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/confined_users_test;
echo 'Defaults lecture="never"' >> /etc/sudoers.d/confined_users_test;
rlPhaseEnd
#TODO try different level and range for the generated user policy
rlPhaseStartTest "real scenario -- confined users"
USER_NAME_SEED="user${RANDOM}"
USER_NAME_INDEX=1
USER_LIST=""
for OPTIONS in ${POLICY_OPTIONS} ; do
USER_NAME="${USER_NAME_SEED}$((USER_NAME_INDEX++))"
USER_LIST+=" ${USER_NAME}"
USER_SECRET="S3kr3t${RANDOM}"
SELINUX_USER="confined_${OPTIONS}"
rlLog "Testing SELinux users: ${SELINUX_USER}"
rlRun "${SEPOLICY_CONFINE} -${OPTIONS} --level s0 --range s0-s0:c0.c1023 ${SELINUX_USER}"
rlRun "semodule -i ${SELINUX_USER}.cil"
rlRun "sed -e 's|user|${SELINUX_USER}|g' /etc/selinux/targeted/contexts/users/user_u > /etc/selinux/targeted/contexts/users/${SELINUX_USER}_u"
rlRun "useradd -Z ${SELINUX_USER}_u ${USER_NAME}"
rlRun "cp *.sh /home/${USER_NAME}"
rlRun "echo ${USER_SECRET} | passwd --stdin ${USER_NAME}"
rlRun "usermod -G wheel ${USER_NAME}"
# dummy -- first telnet connection does not show results properly
rlRun "./telnet.exp ${USER_NAME} ${USER_SECRET} localhost whoami"
# run all available scripts matching given confined user options
TO_RUN=${OPTIONS//[^"$TEST_SCRIPTS"]}
for (( i=0; i<${#TO_RUN}; i++ )) ; do
rlRun -s "./telnet.exp ${USER_NAME} ${USER_SECRET} localhost /home/${USER_NAME}/${TO_RUN:$i:1}.sh ${USER_SECRET}"
echo "\n"
rlRun "grep -e 'Error' $rlRun_LOG" 1
done
# run test scripts over SSH if the new user is allowed to use it
if [[ "$OPTIONS" == *"c"* ]]; then
for (( i=0; i<${#TO_RUN}; i++ )) ; do
rlRun -s "./ssh.exp ${USER_NAME} ${USER_SECRET} localhost /home/${USER_NAME}/${TO_RUN:$i:1}.sh ${USER_SECRET}"
rlRun "grep -e 'Error' $rlRun_LOG" 1
done
fi
sleep 10
done
# remove all test users
for USER_NAME in ${USER_LIST} ; do
rlRun "userdel -rfZ ${USER_NAME}"
done
sleep 10
# remove test SELinux users
for OPTIONS in ${POLICY_OPTIONS} ; do
rlRun "rm -rf confined_${OPTIONS}.cil /etc/selinux/targeted/contexts/users/confined_${OPTIONS}_u"
rlRun "semodule -r confined_${OPTIONS}"
done
rlRun "rm -rf $rlRun_LOG"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "semodule -r confined_user_macros"
rlRun "rm -rf /etc/sudoers.d/confined_users_test"
rlRun "setsebool ssh_sysadm_login off"
if [ -d /etc/ssh/sshd_config.d ] ; then
rlRun "rm -f /etc/ssh/sshd_config.d/001-enable-password.conf"
rlRun "service sshd restart"
fi
rlPhaseEnd
rlJournalEnd

27
tests/docker/main.fmf Normal file
View file

@ -0,0 +1,27 @@
summary: Compare udica output between podman and docker
description: |+
Compare udica output between podman and docker
contact: Jan Zarsky <jzarsky@redhat.com>
component:
- udica
test: ./runtest.sh
framework: beakerlib
recommend:
- container-selinux
- /usr/bin/docker
- podman
- policycoreutils
- udica
duration: 20m
enabled: true
tag:
- NoRHEL4
- NoRHEL5
- NoRHEL6
- NoRHEL7
- targeted
adjust:
- enabled: false
when: distro == rhel-4, rhel-5, rhel-6, rhel-7
because: the udica package is not available there

65
tests/docker/runtest.sh Executable file
View file

@ -0,0 +1,65 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Description: Compare udica output between podman and docker
# Author: Jan Zarsky <jzarsky@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2019 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="udica"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm "udica"
rlAssertRpm "container-selinux"
rlAssertRpm "policycoreutils"
rlAssertRpm "podman"
rlRun "rpm -qf /usr/bin/docker"
rlRun "rlServiceStart docker"
OUTPUT_FILE=$(mktemp)
rlPhaseEnd
rlPhaseStartTest
for BACKEND in podman docker ; do
rlRun "$BACKEND run -dit --name test -v /home:/home:ro -v /var/spool:/var/spool:rw -p 21:21 fedora"
rlRun "$BACKEND ps | grep test"
CONT_ID=$($BACKEND ps | grep test | cut -d ' ' -f 1)
rlRun "udica -i $CONT_ID my_container"
rlRun "mv my_container.cil my_cont_$BACKEND.cil"
rlRun "$BACKEND stop test"
rlRun "$BACKEND rm test"
done
rlRun "sed -i '/capability/d' my_cont_podman.cil"
rlRun "diff -b -B my_cont_podman.cil my_cont_docker.cil"
rlRun "rm my_cont_podman.cil my_cont_docker.cil"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f $OUTPUT_FILE"
rlRun "rlServiceRestore docker"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

26
tests/sanity/main.fmf Normal file
View file

@ -0,0 +1,26 @@
summary: Test basic functionality of udica
description: |+
Test basic functionality of udica
contact: Jan Zarsky <jzarsky@redhat.com>
component:
- udica
test: ./runtest.sh
framework: beakerlib
recommend:
- container-selinux
- podman
- policycoreutils
- udica
duration: 20m
enabled: true
tag:
- NoRHEL4
- NoRHEL5
- NoRHEL6
- NoRHEL7
- targeted
adjust:
- enabled: false
when: distro == rhel-4, rhel-5, rhel-6, rhel-7
because: the udica package is not available there

133
tests/sanity/runtest.sh Executable file
View file

@ -0,0 +1,133 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Description: Test basic functionality of udica
# Author: Jan Zarsky <jzarsky@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2019 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="udica"
CONTAINERS="fedora:latest fedora:rawhide ubi9 ubi8 ubi7 centos:stream9"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm "udica"
rlAssertRpm "container-selinux"
rlAssertRpm "policycoreutils"
rlAssertRpm "podman"
OUTPUT_FILE=$(mktemp)
rlPhaseEnd
rlPhaseStartTest
rlRun "udica --help"
rlRun "PAGER=cat man udica"
rlPhaseEnd
for CONTAINER_NAME in ${CONTAINERS} ; do
rlPhaseStartTest "Test basic scenario for ${CONTAINER_NAME} container"
rlRun "podman run -dit --name test -v /home:/home:ro -v /var/spool:/var/spool:rw -p 21:21 ${CONTAINER_NAME}"
rlRun "podman ps | grep test"
rlRun "ps -efZ | grep bash"
rlRun "ps -efZ | grep bash | grep container_t"
rlRun "podman exec test ls /home" 1,2
rlRun "podman exec test touch /var/spool/test" 1
rlRun "podman exec test yum install nmap-ncat -y" 0
rlWatchdog "rlRun \"podman exec test nc -l 53\"" 3
CONT_ID=$(podman ps | grep test | cut -d ' ' -f 1)
rlRun "podman inspect $CONT_ID | udica my_container >$OUTPUT_FILE"
rlRun "podman stop test"
rlRun "podman rm --force test"
rlRun "cat $OUTPUT_FILE"
rlAssertExists "my_container.cil"
SEMODULE=$(cat $OUTPUT_FILE | grep "semodule -i" | cut -d '#' -f 2)
rlRun "$SEMODULE"
PODMAN_OPT=$(cat $OUTPUT_FILE | grep "security-opt" | cut -d '"' -f 2)
rlRun "podman run -dit --name test2 $PODMAN_OPT -v /home:/home:ro -v /var/spool:/var/spool:rw -p 21:21 fedora"
rlRun "podman ps | grep test2"
rlRun "ps -efZ | grep bash"
rlRun "ps -efZ | grep bash | grep my_container.process"
rlRun "podman exec test2 ls /home" 0
rlRun "podman exec test2 touch /var/spool/test" 0
rlRun "podman exec test2 yum install nmap-ncat -y" 0
rlWatchdog "rlRun \"podman exec test2 nc -l 53\" 2" 3
rlRun "podman stop test2"
rlRun "podman rm --force test2"
rlRun "semodule -r my_container base_container net_container home_container"
rlRun "rm my_container.cil"
rlPhaseEnd
done
rlPhaseStartTest "Compare different ways of obtaining policy"
rlRun "podman run -dit --name test -v /home:/home:ro -v /var/spool:/var/spool:rw -p 21:21 fedora"
rlRun "podman ps | grep test"
CONT_ID=$(podman ps | grep test | cut -d ' ' -f 1)
rlRun "podman inspect $CONT_ID | udica my_container >pipe.result"
rlRun "podman inspect $CONT_ID >container.json"
rlRun "udica -j container.json my_container >json.result"
rlRun "udica -i $CONT_ID my_container >id.result"
rlRun "diff pipe.result json.result"
rlRun "diff pipe.result id.result"
rlRun "rm -f pipe.result json.result id.result container.json"
rlRun "podman stop test"
rlRun "podman rm test"
rlPhaseEnd
rlPhaseStartTest "Test loading modules"
rlRun "podman run -dit --name test -v /home:/home:ro -v /var/spool:/var/spool:rw -p 21:21 fedora"
rlRun "podman ps | grep test"
CONT_ID=$(podman ps | grep test | cut -d ' ' -f 1)
rlRun "podman inspect $CONT_ID | udica -l my_container"
rlRun "podman stop test"
rlRun "podman rm test"
rlRun "semodule -l >$OUTPUT_FILE"
rlAssertGrep "my_container" $OUTPUT_FILE
rlAssertGrep "base_container" $OUTPUT_FILE
rlAssertGrep "net_container" $OUTPUT_FILE
rlAssertGrep "home_container" $OUTPUT_FILE
rlRun "semodule -r my_container base_container net_container home_container"
rlRun "rm my_container.cil"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f $OUTPUT_FILE"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -1,42 +1,44 @@
Summary: A tool for generating SELinux security policies for containers
Name: udica
Version: 0.1.1
Release: 2%{?dist}
Version: 0.2.8
Release: 11%{?dist}
Source0: https://github.com/containers/udica/archive/v%{version}.tar.gz
License: GPLv3+
#git format-patch -N v0.2.8 -- . ':!.cirrus.yml' ':!.github'
Patch0001: 0001-Add-option-to-generate-custom-policy-for-a-confined-.patch
Patch0002: 0002-Add-tests-covering-confined-user-policy-generation.patch
Patch0003: 0003-confined-make-l-non-optional.patch
Patch0004: 0004-confined-allow-asynchronous-I-O-operations.patch
Patch0005: 0005-use-relative-paths-it-s-undefined-behavior-with-abso.patch
License: GPL-3.0-or-later
BuildArch: noarch
Url: https://github.com/containers/udica
%if 0%{?fedora} || 0%{?rhel} > 7
BuildRequires: python3 python3-devel python3-setuptools
BuildRequires: python3 python3-devel
Requires: python3 python3-libsemanage python3-libselinux
%else
BuildRequires: python2 python2-devel python2-setuptools
Requires: python2 libsemanage-python libselinux-python
%endif
# container-selinux provides policy templates
Requires: container-selinux >= 2.168.0-2
%description
Tool for generating SELinux security profiles for containers based on
inspection of container JSON file.
%prep
%setup -q
%autosetup -p 1
%generate_buildrequires
%pyproject_buildrequires
%build
%if 0%{?fedora} || 0%{?rhel} > 7
%{__python3} setup.py build
%else
%{__python2} setup.py build
%endif
%pyproject_wheel
%install
install --directory %%{buildroot}%{_datadir}/udica/templates
%if 0%{?fedora} || 0%{?rhel} > 7
%{__python3} setup.py install --single-version-externally-managed --root=%{buildroot}
%else
%{__python2} setup.py install --single-version-externally-managed --root=%{buildroot}
%endif
%pyproject_install
install --directory %{buildroot}%{_datadir}/udica/macros
install --directory %{buildroot}%{_mandir}/man8
install -m 0644 udica/man/man8/udica.8 %{buildroot}%{_mandir}/man8/udica.8
@ -44,20 +46,187 @@ install -m 0644 udica/man/man8/udica.8 %{buildroot}%{_mandir}/man8/udica.8
%{_mandir}/man8/udica.8*
%{_bindir}/udica
%dir %{_datadir}/udica
%dir %{_datadir}/udica/templates
%{_datadir}/udica/templates/*
%if 0%{?fedora} || 0%{?rhel} > 7
%dir %{_datadir}/udica/ansible
%dir %{_datadir}/udica/macros
%{_datadir}/udica/ansible/*
%{_datadir}/udica/macros/*
%license LICENSE
%{python3_sitelib}/udica/
%{python3_sitelib}/udica-*.egg-info
%else
%{_datarootdir}/licenses/udica/LICENSE
%{python2_sitelib}/udica/
%{python2_sitelib}/udica-*.egg-info
%endif
%{python3_sitelib}/udica-*.dist-info
%changelog
* Fri Sep 19 2025 Python Maint <python-maint@redhat.com> - 0.2.8-11
- Rebuilt for Python 3.14.0rc3 bytecode
* Fri Aug 15 2025 Python Maint <python-maint@redhat.com> - 0.2.8-10
- Rebuilt for Python 3.14.0rc2 bytecode
* Fri Jul 25 2025 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.8-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Mon Jun 02 2025 Python Maint <python-maint@redhat.com> - 0.2.8-8
- Rebuilt for Python 3.14
* Sun Jan 19 2025 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.8-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Sat Jul 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.8-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
* Fri Jun 07 2024 Python Maint <python-maint@redhat.com> - 0.2.8-5
- Rebuilt for Python 3.13
* Mon Feb 12 2024 Vit Mojzis <vmojzis@redhat.com> - 0.2.8-4
- confined: make "-l" non optional
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Thu Dec 21 2023 Vit Mojzis <vmojzis@redhat.com> - 0.2.8-2
- Add option to generate custom policy for a confined user
* Wed Nov 29 2023 Vit Mojzis <vmojzis@redhat.com> - 0.2.8-1
- New release
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.7-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Tue Jun 13 2023 Python Maint <python-maint@redhat.com> - 0.2.7-6
- Rebuilt for Python 3.12
* Tue Apr 11 2023 Vit Mojzis <vmojzis@redhat.com> - 0.2.7-5
- Show diff when checking formatting
- Fix several lint findings
- Fix generating policy for Crio mounts
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Fri Oct 21 2022 Vit Mojzis <vmojzis@redhat.com> - 0.2.7-3
- Add --devices option
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Wed Jun 22 2022 Vit Mojzis <vmojzis@redhat.com> - 0.2.7-1
- Add support for containerd via "nerdctl inspect"
- Avoid duplicate rules for accessing mounts and devices
* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 0.2.6-5
- Rebuilt for Python 3.11
* Mon May 02 2022 Vit Mojzis <vmojzis@redhat.com> - 0.2.6-4
- Improve label collection for mounts and devices
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Thu Nov 11 2021 Vit Mojzis <vmojzis@redhat.com> - 0.2.6-2
- Make sure each section of the inspect exists before accessing
* Mon Sep 13 2021 Vit Mojzis <vmojzis@redhat.com> - 0.2.6-1
- New release https://github.com/containers/udica/releases/tag/v0.2.6
- Move policy templates to container-selinux repo
* Wed Aug 25 2021 Vit Mojzis <vmojzis@redhat.com> - 0.2.5-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.5
- Replace capability dictionary with str.lower()
- Enable udica to generate policies with fifo class
- Sort container inspect data before processing
- Update templates to work properly with new cil parser
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.2.4-4
- Rebuilt for Python 3.10
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Sun Dec 13 2020 Lukas Vrabec <lvrabec@redhat.com> - 0.2.4-2
- Add %check section to run basic tests during rpm build process
* Wed Nov 25 2020 Lukas Vrabec <lvrabec@redhat.com> - 0.2.4-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.4
* Thu Aug 13 2020 Lukas Vrabec <lvrabec@redhat.com> - 0.2.3-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.3
* Mon Aug 03 2020 Lukas Vrabec <lvrabec@redhat.com> - 0.2.2-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.2
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.2.1-3
- Rebuilt for Python 3.9
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Oct 25 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.2.1-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.1
* Wed Sep 25 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.2.0-1
- New rebase https://github.com/containers/udica/releases/tag/v0.2.0
* Wed Aug 28 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.9-1
- Update tests test_basic.podman.cil, test_basic.docker.cil. Round 2
- New rebase https://github.com/containers/udica/releases/tag/v0.1.9
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.1.8-3
- Rebuilt for Python 3.8
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Thu Jul 11 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.8-1
- New rebase https://github.com/containers/udica/releases/tag/v0.1.8
* Wed Jun 12 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.7-1
- New rebase with upstream adding new param --ansible, to generate ansible playbook for deploying policies. https://github.com/containers/udica/releases/tag/v0.1.7
* Thu May 16 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.6-1
- New rebase with upstream adding new tests
* Tue Apr 30 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.5-2
- Add allow rules for container_runtime_t to base_container.cil, Podman version 1.2.0 requires new allow rules.
* Fri Apr 19 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.5-1
- Create mock selinux and semanage module
- Update testing section in README
- Add travis file for Travis CI
- Grammar fixes in the udica.8 manpage file
- Support port ranges (Resolves: #16)
- Test port ranges
* Mon Mar 11 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.4-1
- Fix minor problems reported by pylint #11
- Catch FileNotFoundError when inspecting containers #12
- Create basic tests #13
- Restore working directory #14
- udica cannot use the container ID once it is provided #10
* Mon Feb 25 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.3-4
- Update manpage with the latest known bug described in https://github.com/containers/udica/issues/8
- Add check if runtimes are installed on the system
* Sun Feb 17 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.3-3
- Improve capability parsing for docker containers
- Update small changes in manpage, like issue with mandatory option '-c' for docker containers
- Fix parsing Mountpoints in docker inspect JSON file
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Wed Jan 23 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.3-1
- Fix capability allow rules when capabilities are specified in JSON file
- Add additional SELinux allow rules to base container template to allow container to read proc_type types.
* Fri Jan 04 2019 Lukas Vrabec <lvrabec@redhat.com> - 0.1.2-1
- Fix invalid syntax output when policy is using just one template
Resolves: #6
* Tue Oct 23 2018 Lukas Vrabec <lvrabec@redhat.com> - 0.1.1-2
- Fix small issues in spec file like improve description and change files section.