checkpolicy: add bad data protection tests
PATCH 1/1 checkpolicy: add bad data protection tests
Add test_checkmodule_negative.sh and .te fixtures for bad-data protection (missing/bad-path and corrupted .te inputs).
Signed-off-by Akhil Kohli <[email protected]>
--- checkpolicy/Makefile | 3 +- checkpolicy/tests/negative/bad_module_line.te | 5 + checkpolicy/tests/negative/bad_require.te | 5 + checkpolicy/tests/negative/bad_syntax.te | 8 + checkpolicy/tests/negative/dup_module.te | 6 + checkpolicy/tests/negative/good_module.te | 8 + .../tests/negative/invalid_module_version.te | 5 + checkpolicy/tests/negative/unknown_class.te | 7 + checkpolicy/tests/negative/unknown_perm.te | 8 + checkpolicy/tests/negative/unknown_type.te | 8 + .../tests/test_checkmodule_negative.sh | 178 ++++++++++++++++++ 11 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 checkpolicy/tests/negative/bad_module_line.te create mode 100644 checkpolicy/tests/negative/bad_require.te create mode 100644 checkpolicy/tests/negative/bad_syntax.te create mode 100644 checkpolicy/tests/negative/dup_module.te create mode 100644 checkpolicy/tests/negative/good_module.te create mode 100644 checkpolicy/tests/negative/invalid_module_version.te create mode 100644 checkpolicy/tests/negative/unknown_class.te create mode 100644 checkpolicy/tests/negative/unknown_perm.te create mode 100644 checkpolicy/tests/negative/unknown_type.te create mode 100755 checkpolicy/tests/test_checkmodule_negative.sh
checkpolicy/Makefile +2 -1
@@ -51,8 +51,9 @@ lex.yy.c: policy_scan.l y.tab.c $(LEX) policy_scan.l .PHONY: test -test: checkpolicy +test: checkpolicy checkmodule ./tests/test_roundtrip.sh + ./tests/test_checkmodule_negative.sh # helper target for fuzzing checkobjects: $(CHECKOBJS)
checkpolicy/tests/negative/bad_module_line.te new file +5 -0
@@ -0,0 +1,5 @@ +module bad module name 1.0 garbage; + +require { + type foo_t; +}
checkpolicy/tests/negative/bad_require.te new file +5 -0
@@ -0,0 +1,5 @@ +module bad_require 1.0; + +require { + garbage_token foo_t; +}
checkpolicy/tests/negative/bad_syntax.te new file +8 -0
@@ -0,0 +1,8 @@ +module bad_syntax 1.0; + +require { + type foo_t; + class file { read }; +} + +allow foo_t foo_t:file {
checkpolicy/tests/negative/dup_module.te new file +6 -0
@@ -0,0 +1,6 @@ +module dup_module 1.0; +module dup_module 1.0; + +require { + type foo_t; +}
checkpolicy/tests/negative/good_module.te new file +8 -0
@@ -0,0 +1,8 @@ +module good_module 1.0; + +require { + type foo_t, bar_t; + class file { read write }; +} + +allow foo_t bar_t:file read;
checkpolicy/tests/negative/invalid_module_version.te new file +5 -0
@@ -0,0 +1,5 @@ +module invalid_module_version; + +require { + type foo_t; +}
checkpolicy/tests/negative/unknown_class.te new file +7 -0
@@ -0,0 +1,7 @@ +module unknown_class 1.0; + +require { + type foo_t; +} + +allow foo_t self:not_a_class read;
checkpolicy/tests/negative/unknown_perm.te new file +8 -0
@@ -0,0 +1,8 @@ +module unknown_perm 1.0; + +require { + type foo_t, bar_t; + class file { read }; +} + +allow foo_t bar_t:file circular_ref;
checkpolicy/tests/negative/unknown_type.te new file +8 -0
@@ -0,0 +1,8 @@ +module unknown_type 1.0; + +require { + type foo_t; + class file { read }; +} + +allow foo_t undeclared_t:file read;
checkpolicy/tests/test_checkmodule_negative.sh new file +178 -0
178 lines not on this page · raw message
Signature · 1 line
2.55.0