Commit graph

48 commits

Author SHA1 Message Date
Amith Kumar
9e8c0e2107 file-contexts: Add test for bug1822100
Add an semanage case to file-contexts test suite which verifies bug
1822100. The fix checks for the broken pipe error generated by the
'semanage fcontext -l | egrep ..' command.

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2021-04-07 14:46:07 +00:00
Petr Lautrbach
f1d94dfd61 policycoreutils/setfiles: Add path to main.fmf 2021-02-05 15:43:57 +01:00
Petr Lautrbach
e48b62767b policycoreutils/setfiles: Make the relabel test robust
- use directory which is not usually mounted as tmpfs
- use own spec_file
- use -F option
- check context of all directories and files inside chroot
2021-02-05 15:28:21 +01:00
Petr Lautrbach
33abfe035c policycoreutils/setfiles: Basic sanity test for setfiles 2021-02-04 18:18:44 +01:00
Ondrej Mosnacek
596ec7fafe Make all relevancy expressions use comparison operators
Rather than enumerating RHEL versions, use comparison against
"known-good" version to make the expressions easier to read and
understand.

Also convert users of '~<' to '<', as '~<' compares only minor versions
within the same major.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2020-12-15 12:38:32 +01:00
Milos Malik
15f6d6c612 update test relevancy based on packages availability
Relevancy changes are made based on recommendations from:
  tmt test lint --fix

Some packages are available for Fedoras only and are not available
for RHELs at all.
Some packages are available for latest RHEL major versions only.
2020-12-15 11:53:28 +01:00
Milos Malik
1572bc3434 skip some checks if /sys/fs/selinux cannot be unmounted
Some checks in the automated tests require an unmounted SELinux
file-system. This way is used to pretend that SELinux is disabled.
Sometimes the file-system cannot be unmounted because of

  umount: /sys/fs/selinux: target is busy.

To work around this issue, umount with --lazy option will be used.
If umount --lazy still complains, the problematic checks will be
skipped, because it still make sense to run the other parts of the
automated tests.
2020-12-08 08:18:30 +00:00
Milos Malik
6b50be9a83 add the selinux-autorelabel service test to upstream
The selinux-autorelabel service is available in various Fedoras
and RHELs, so it makes sense to run the TC in upstream testing.

There are no changes in the TC functionality, only moving the
downstream TC to the upstream repo.
2020-09-11 13:56:37 +00:00
Amith Kumar
56a35b10fd sepolicy : Add fix for bug 1854639
The testcase verifies HTML page generated by "sepolicy manpage"
and ensures links to generated man page exists.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1854639

Signed-off-by: Amith Kumar <apeetham@redhat.com>
2020-08-12 15:12:35 +00:00
Richard Filo
cba138dc22 policycoreutils/org-selinux-dbus-interfaces: Add missing requirements
Fedora CI fails because dbus-tools package is required.

fixes: https://src.fedoraproject.org/tests/selinux/issue/66
2020-05-19 11:03:45 +02:00
Petr Lautrbach
fff775a47b sctp_test: sctp module is in kernel-modules in Fedora 2020-05-13 11:06:00 +00:00
Petr Lautrbach
2489409dc5 sctp_test: Add Makefile to automatically resolve dependencies
FMF is not able to resolve test dependencies yet so we need to ship Makefile
with Requires metadata. STR uses this to satisfy test dependencies.
2020-05-13 11:06:00 +00:00
Petr Lautrbach
933ad30a55 org.selinux dbus interface is shipped by policycoreutils-dbus
In past it was policycoreutils-gui so check whether at least one of them is
installed.

Resolves: https://src.fedoraproject.org/tests/selinux/issue/39
2020-01-24 11:11:20 +01:00
Petr Lautrbach
f98e16dc94 setsebool: enable PATH records while running
This test expects it's enabled
2020-01-10 10:03:31 +01:00
Petr Lautrbach
0f3d000076 load_policy: enable PATH records while running
This test expects it's enabled
2020-01-10 09:05:17 +01:00
Petr Lautrbach
920603d120 load_policy: start the audit daemon if it is not running 2020-01-09 13:29:16 +01:00
Petr Lautrbach
46009984e5 Add Makefile to policycoreutils tests
They are important as source of Requirements for tests. The original idea that
requirements should be part of tests.yml currently doesn't scale through
different projects with different tests.yml
2019-12-16 12:55:47 +01:00
Petr Lautrbach
85ca1add8f policycoreutils: Do the D-bus interfaces/methods of /org/selinux/object work?
Tested interfaces:
     "org.selinux.semodule_list"
     "org.selinux.customized"
     "org.selinux.setenforce"
     "org.selinux.relabel_on_boot"
     "org.selinux.restorecon"
     "org.selinux.semanage"
     "org.selinux.change_default_policy"
     "org.selinux.change_default_mode"

Original author: Milos Malik <mmalik@redhat.com>
2019-12-05 08:08:05 +00:00
Vit Mojzis
56d49125a4 policycoreutils: Add test for restorecond "blob data"
This test creates mislabeled files and runs restorecond repeatedly to test
for an issue caused by overwriting program variable with memory address.
The issue caused restorecond to write status messages (that appeared
as "blob data" because of \r character) to journal.

Since the memory address mentioned above is effectively random data,
this test may result in SUCESS even if the issue being tested is present!
2019-11-27 13:01:04 +01:00
Vit Mojzis
34b485bf01 policycoreutils/sctp_test: Fix a few minor issues
- userapp_t didn't have permission to write into temporary file which
caused failure of the test even when sctp_test worked properly
- Fix context of sctp_test during clean-up
- Add listing of the new portcons to check they have been properly added

Fixes: https://src.fedoraproject.org/tests/selinux/issue/21
2019-11-15 07:57:02 +01:00
Petr Lautrbach
ccc69b4d5a Run on policycoreutils/sctp_test on libsemanage component
libsemanage had to be changed together with policycoreutils in order to
implement support for 'sctp' and 'dccp' in `semanage port`. It's probably a good
idea to cover libsemanage by this test as well.
2019-11-11 08:14:24 +01:00
Vit Mojzis
4c00d6a136 policycoreutils: Add test for SCTP support in semanage
This test simulates a use case where a user wants to confine a
client-server application communicating over SCTP protocol.

A custom policy module is used to introduce a new port type, domain type
for the application and an executable file type for the application
executable as well as a minimal set of allow rules for sctp_test to work
properly.
"semanage port" is then used to define SCTP contexts for ports 1025 and
1026.
Lastly sctp_test is executed in client-server configuration.
2019-11-07 16:12:14 +01:00
Petr Lautrbach
2e70fcdec8 policycoreutils/semanage-login: test range of added login
When a new login mapping is added, default range should be same as the range of
used SELinux user.

Covers: https://bugzilla.redhat.com/show_bug.cgi?id=1312283
2019-09-03 17:47:03 +02:00
Petr Lautrbach
fc79404ee1
policycoreutils/fixfiles-F-B-N: Test fixfiles [-F] [-B] onboot 2019-07-01 22:08:38 +02:00
Petr Lautrbach
9d4050e61e semanage-port-add-delete-problems: Check for MAC_POLICY_LOAD after semanage
We need to check whether a new policy is loaded after 'semanage port -a ...'.
The best way to do it is to check whether kernel reported MAC_POLICY_LOAD.

The original check was error prone.

Fixes:
[   PASS   ] :: Command 'ausearch -m user_avc -ts 03/13/2019 08:10:47 > /tmp/tmp.3RAR6INhvL' (Expected 0,1, got 0)
[  BEGIN   ] :: Running 'cat /tmp/tmp.3RAR6INhvL'
----
time->Wed Mar 13 08:10:53 2019
type=USER_AVC msg=audit(1552479053.819:1407): pid=698 uid=81 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  received policyload notice (seqno=65)  exe="/usr/bin/dbus-daemon" sauid=81 hostname=? addr=? terminal=?'
[   FAIL   ] :: number of lines in /tmp/tmp.3RAR6INhvL should be 0 (Assert: expected 0, got 3)
2019-03-13 16:33:04 +01:00
Vit Mojzis
e956be1603 Sanity/load_policy: fix typo in test macro 2019-03-13 15:28:47 +01:00
Vit Mojzis
beb6ea9a50 load_policy: accommodate changes in policy load audit message 2019-03-13 15:28:33 +01:00
Petr Lautrbach
028e473158 Apply "generic" and "fedora" tags
Tests tagged as "generic" is supposed to be used on a generic system like Fedora
or Red Hat Enterprise Linux, while tests with "fedora" tag is for Fedora only.

Usage:
List only "generic" tests:
     $ fmf show --filter "tier: 1 | component: policycoreutils & tags: generic"

List all "generic" and "fedora" tests:
     $ fmf show --filter "tier: 1 | component: policycoreutils & tags: generic, fedora"
2019-03-13 11:23:00 +01:00
Petr Lautrbach
ce5b8047e1 linux-system-roles: Skip the reboot test
Given that tests are run on localhost, we can't reboot during the test. Lets
skip tests_all_transitions.yml.
2019-03-12 16:05:58 +01:00
Petr Lautrbach
4387f8c287 linux-system-roles use "tests" as a test keyword
Since commit a456db2c59e43b331184ceda5a1bd5d51ddd2d2d ("Move tests to /tests
directory and rename to new naming scheme") linux-system-roles selinux tests use
tests/ directory and renamed test playbooks to tests_*.yml.

Fixes:
[   FAIL   ] :: Command 'cd selinux/test' (Expected 0, got 1)
2019-03-12 15:48:21 +01:00
Petr Lautrbach
8c7670c1e6 policycoreutils/modules: Use filesystem_type instead of fs_t
Sometime, /tmp can be tmpfs_t so we need to allow test_t to be associated to all
filesystem types.

Fixes:
:: [ 08:16:37 ] :: [  BEGIN   ] :: Running 'chcon -t test_t test_file'
chcon: failed to change context of 'test_file' to ‘unconfined_u:object_r:test_t:s0’: Permission denied
:: [ 08:16:37 ] :: [   FAIL   ] :: Command 'chcon -t test_t test_file' (Expected 0, got 1)

type=AVC msg=audit(1552392203.833:2467): avc:  denied  { associate } for  pid=571 comm="chcon" name="test_file" dev="tmpfs" ino=77668 scontext=unconfined_u:object_r:test_t:s0 tcontext=system_u:object_r:tmpfs_t:s0 tclass=filesystem permissive=0
2019-03-12 13:37:06 +01:00
Petr Lautrbach
355f548993 semanage-permissive-d-problems: argparse standard error status code is 2
https://docs.python.org/3/library/argparse.html#exiting-methods
2018-12-05 11:56:15 +01:00
Jan Zarsky
b32a2f8c0f enable policycoreutils/restorecon
Enable policycoreutils/restorecon and mark it as tier 1 test.
2018-10-15 13:43:52 +02:00
Jan Zarsky
99e17a3bd1 check if mcstrans is present before stopping it
Check if the mcstrans or mcstransd binaries are present. This prevents
unnecessary warnings.
2018-10-15 10:49:41 +02:00
Jan Zarsky
4d8e2de3cd fix hidden failure in check_contexts
check_contexts was checking contexts in a loop and there was no warning
when there were no files to check (because of invalid parameter). Fix
this by counting the files to be checked.

Fix also one invalid call to check_contexts.
2018-10-15 10:46:49 +02:00
Petr Lautrbach
b41ff2e4c1 Fix path meta data
Commit 769880f7 added path meta data into .fmf files. As path's didn't have /
at the beginning test were not created correctly.

Fixes:
fatal: [fedora29]: FAILED! => {
    "msg": [
        "Tests failed: True",
        "Tests msg: FAIL selinuxselinux-policy/policy-rpm-macros",
        "FAIL selinuxcheckpolicy/checkpolicy",
        "FAIL selinuxlibsepol/sepol_check_context",
        "FAIL selinuxlibsemanage/verify-options-in-semanage-conf",
...

$ cat artifacts/FAIL_selinuxcheckpolicy-checkpolicy.log
FAIL test selinuxcheckpolicy/checkpolicy does not appear to be a file or directory
2018-10-14 21:52:42 +02:00
Petr Lautrbach
66a56a3e9b Revert "Fix path meta data"
This reverts commit 4cf575fc0b.

Some of paths were not correctly updated

Fixes:
        "FAIL selinux/olicycoreutils/booleans",
2018-10-14 21:48:49 +02:00
Petr Lautrbach
4cf575fc0b Fix path meta data
Commit 769880f7 added path meta data into .fmf files. As path's didn't have /
at the beginning test were not created correctly.

Fixes:
fatal: [fedora29]: FAILED! => {
    "msg": [
        "Tests failed: True",
        "Tests msg: FAIL selinuxselinux-policy/policy-rpm-macros",
        "FAIL selinuxcheckpolicy/checkpolicy",
        "FAIL selinuxlibsepol/sepol_check_context",
        "FAIL selinuxlibsemanage/verify-options-in-semanage-conf",
...

$ cat artifacts/FAIL_selinuxcheckpolicy-checkpolicy.log
FAIL test selinuxcheckpolicy/checkpolicy does not appear to be a file or directory
2018-10-14 21:31:10 +02:00
Petr Šplíchal
769880f739 Define path metadata for each test
Adding attribute "path" to each test according to the CI metadata
specification [1]. This also resolves problem with autodetecting
empty directories [2] which will be fixed in the next fmf release.

[1] https://fedoraproject.org/wiki/CI/Metadata#Path
[2] https://github.com/psss/fmf/pull/48
2018-10-11 10:45:08 +02:00
Petr Šplíchal
074ef8ad34 Choose better tier 1 test for policycoreutils
Disabled policycoreutils/restorecon as it is broken.
Selected other test for tier 1 testing.
2018-10-01 14:54:59 +02:00
Petr Šplíchal
40894f79d3 Update tier metadata to the latest specification
There is now a dedicated field to store the tier info:
https://fedoraproject.org/wiki/CI/Metadata#Tier
Also added some missing component data.
2018-09-20 17:08:10 +02:00
Petr Lautrbach
a93de8135b policycoreutils/modules: Use temporary directory instead of hardcoded "test" 2018-08-03 10:26:15 +02:00
Jan Zarsky
78a1b24f6e test file contexts
The test adds custom file contexts, runs restorecon and checks file
contexts. The chcon command is also tested.
2018-08-01 08:25:56 +02:00
Jan Zarsky
b8b6880b0d test sestatus, avcstat, getenforce
Test that output of sestatus matches information in /sys/fs/selinux.
Test that avcstat works. Test getenforce.

Warning: this tests runs setenforce.
2018-07-31 22:52:50 +02:00
Jan Zarsky
26ce71b3c8 test switching booleans
The test defines its own booleans and tests setting it on and off using
setsebool and semanage boolean.
2018-07-31 21:42:40 +02:00
Jan Zarsky
604c930344 test basic module functionality
The test compiles a TE module, loads it via semodule, and checks that
the rules are enforced. The same is done with a CIL module. Module
overriding using priorities and module disabling is also tested.

This test requires policycoreutils and selinux-policy-devel packages.
2018-07-31 21:22:12 +02:00
Petr Šplíchal
3b2fd40114 Add initial test metadata using the FMF format
This adds an initial set of test metadata using the Flexible Metadata
Format for experimenting. This should allow us to more easily execute
relevant test coverage for all selinux-related components. Example:

    fmf --key test --filter 'tags:Tier1'
    fmf --key test --filter 'component:libselinux'
    fmf --key test --filter 'component:libselinux | tags:Tier1'

See https://github.com/psss/fmf for more details about the FMF format.
2018-02-19 15:05:29 +01:00
Petr Lautrbach
f97a294e75 Add tests from https://src.fedoraproject.org/rpms/policycoreutils/blob/master/f/tests 2018-02-14 13:41:13 +01:00