platform_system_sepolicy/tests
Thiébaud Weksteen 9a924ba875 Add checkfc mode to validate file_contexts against test data
A new mode for checkfc is introduced (-t) which takes a file_contexts
and a test data file. Each line in the test data file contains a path
and the expected type. checkfc loads the file_contexts and repeatedly
calls selabel_lookup(3) to verify that the computed type is as expected.

This mode can be used to confirm that any modification to file_contexts
or its build process is benign.

A test data file (plat_file_contexts_test) is added. This file was
manually created based on private/file_contexts. Each static path was
copied as-is. Each regular expression was expanded into a couple of
entries. For instance, /dev/adf[0-9]* generated /dev/adf, /dev/adf0 and
/dev/adf123.

libselinux keeps track of which specification is being hit when using
selabel_lookup. When calling selabel_stats(3), the file backend will
output a warning if a specification has not been used. This can be
leveraged to ensure that each rule is at least hit once. This property
will be leveraged in a follow-up change (by running the test as part of
the build process), to ensure that the plat_file_contexts_test file
remains up-to-date (that is, when an entry is added to
private/file_contexts, the build will fail unless a test is also added
to plat_file_contexts_test to exercice the specification/regular
expression).

Test: m checkfc && checkfc -t ./private/file_contexts ./tests/plat_file_contexts_test
Bug: 299839280
Change-Id: Ibf56859a16bd17e1f878ce7b0570b2aead79c7e0
2023-10-17 15:43:06 +11:00
..
include Assert types labeled in genfs_contexts have correct attributes 2018-03-23 14:34:46 -07:00
Android.bp Use heuristics to run sepolicy_tests faster 2023-09-26 16:47:45 +09:00
apex_sepolicy_tests.py APEX file_context should have valid labels 2023-09-11 13:39:09 +09:00
apex_sepolicy_tests_test.py APEX file_context should have valid labels 2023-09-11 13:39:09 +09:00
check_prop_prefix.py Check vendor_property_contexts namespaces 2021-02-17 12:41:38 +09:00
combine_maps.py sepolicy: don't construct mappings for ignored types 2020-01-08 08:53:27 -08:00
fc_sort.py Migrate tests/ to Python 3 2021-12-01 21:45:13 +00:00
fc_sort_test.py Migrate tests/ to Python 3 2021-12-01 21:45:13 +00:00
fix_policies.sh One-click fix script for isolated_app_all replacement 2023-02-03 14:55:29 +00:00
mini_parser.py Migrate tests/ to Python 3 2021-12-01 21:45:13 +00:00
plat_file_contexts_test Add checkfc mode to validate file_contexts against test data 2023-10-17 15:43:06 +11:00
policy.py Show only violating entries on sepolicy_tests 2023-10-04 16:03:12 +09:00
policy_test.py Use heuristics to run sepolicy_tests faster 2023-09-26 16:47:45 +09:00
searchpolicy.py Lexicographically sort perms in rules output of searchpolicy.py 2022-07-19 13:56:30 +00:00
sepol_wrap.cpp gracefully handle hashtab_search failures 2018-09-26 14:28:44 -07:00
sepolicy_freeze_test.py Relax freeze_test to check only compatibility 2023-09-05 03:37:18 +00:00
sepolicy_tests.py Move tests from treble_sepolicy_tests 2023-09-06 14:26:25 +09:00
treble_sepolicy_tests.py Use only public cil files for Treble compat test 2023-09-07 16:35:08 +09:00