Linux Integrity Measurement development
 help / color / mirror / Atom feed
* [RFC PATCH 1/3] Update validate() to support multiple violations
@ 2025-02-20 16:00 Mimi Zohar
  2025-02-20 16:00 ` [RFC PATCH 2/3] ima: additional open-writer violation tests Mimi Zohar
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Mimi Zohar @ 2025-02-20 16:00 UTC (permalink / raw)
  To: linux-integrity, ltp; +Cc: Mimi Zohar, Stefan Berger, Petr Vorel

Add support for the number of expected violations.  Include the
expected number of violations in the output.

Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 .../security/integrity/ima/tests/ima_violations.sh     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh
index 37d8d473c..7f0382fb8 100755
--- a/testcases/kernel/security/integrity/ima/tests/ima_violations.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_violations.sh
@@ -71,20 +71,26 @@ validate()
 	local num_violations="$1"
 	local count="$2"
 	local search="$3"
+	local expected_violations=$4
 	local max_attempt=3
 	local count2 i num_violations_new
 
+	[ -z $expected_violations ] && expected_violations=1
+
 	for i in $(seq 1 $max_attempt); do
 		read num_violations_new < $IMA_VIOLATIONS
 		count2="$(get_count $search)"
-		if [ $(($num_violations_new - $num_violations)) -gt 0 ]; then
+		if [ $(($num_violations_new - $num_violations)) -eq $expected_violations ]; then
 			if [ $count2 -gt $count ]; then
-				tst_res TPASS "$search violation added"
+				tst_res TPASS "$expected_violations $search violation(s) added"
 				return
 			else
 				tst_res TINFO "$search not found in $LOG ($i/$max_attempt attempt)..."
 				tst_sleep 1s
 			fi
+		elif [ $(($num_violations_new - $num_violations)) -gt 0 ]; then
+			tst_res $IMA_FAIL "$search too many violations added"
+			return
 		else
 			tst_res $IMA_FAIL "$search violation not added"
 			return
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-02-25  7:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 16:00 [RFC PATCH 1/3] Update validate() to support multiple violations Mimi Zohar
2025-02-20 16:00 ` [RFC PATCH 2/3] ima: additional open-writer violation tests Mimi Zohar
2025-02-20 19:02   ` Petr Vorel
2025-02-20 16:00 ` [RFC PATCH 3/3] ima: additional ToMToU " Mimi Zohar
2025-02-20 18:16   ` Petr Vorel
2025-02-20 18:46     ` Petr Vorel
2025-02-20 21:15       ` Mimi Zohar
2025-02-20 18:59     ` Mimi Zohar
2025-02-20 19:13       ` Petr Vorel
2025-02-20 20:22         ` Mimi Zohar
2025-02-20 21:18           ` Mimi Zohar
2025-02-20 21:43             ` Petr Vorel
2025-02-21  2:07               ` Mimi Zohar
2025-02-21  8:16                 ` Petr Vorel
2025-02-24 18:48                   ` Mimi Zohar
2025-02-25  7:45                     ` Petr Vorel
2025-02-20 18:50 ` [RFC PATCH 1/3] Update validate() to support multiple violations Petr Vorel

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