summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Kuster <akuster808@gmail.com>2023-05-01 11:21:15 -0400
committerArmin Kuster <akuster808@gmail.com>2023-05-06 07:54:09 -0400
commitb3c7a20e1b265870c11c0113bdc65fcaa9852556 (patch)
tree1f24f585077d2ad1bac6fd8b547a7ed8d0687772
parent9de807705b27b05bbf84e9f16502fe6cdaa8928f (diff)
downloadmeta-security-b3c7a20e1b265870c11c0113bdc65fcaa9852556.tar.gz
oeqa: fix hash test to match new changes
Signed-off-by: Armin Kuster <akuster808@gmail.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-integrity/lib/oeqa/runtime/cases/ima.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/meta-integrity/lib/oeqa/runtime/cases/ima.py b/meta-integrity/lib/oeqa/runtime/cases/ima.py
index 0c8617a..6b361ca 100644
--- a/meta-integrity/lib/oeqa/runtime/cases/ima.py
+++ b/meta-integrity/lib/oeqa/runtime/cases/ima.py
@@ -58,21 +58,19 @@ class IMACheck(OERuntimeTestCase):
58 @OETestDepends(['ima.IMACheck.test_ima_enabled']) 58 @OETestDepends(['ima.IMACheck.test_ima_enabled'])
59 def test_ima_hash(self): 59 def test_ima_hash(self):
60 ''' Test if IMA stores correct file hash ''' 60 ''' Test if IMA stores correct file hash '''
61 filename = "/etc/filetest" 61 filename = "/etc/ld.so.cache"
62 ima_measure_file = "/sys/kernel/security/ima/ascii_runtime_measurements" 62 ima_measure_file = "/sys/kernel/security/ima/ascii_runtime_measurements"
63 status, output = self.target.run("echo test > %s" % filename)
64 self.assertEqual(status, 0, "Cannot create file %s on target" % filename)
65 63
66 # wait for the IMA system to update the entry 64 # wait for the IMA system to update the entry
67 maximum_tries = 30 65 maximum_tries = 3
68 tries = 0 66 tries = 0
69 status, output = self.target.run("sha1sum %s" %filename) 67 status, output = self.target.run("sha256sum %s" %filename)
70 sleep(2) 68 sleep(2)
71 current_hash = output.split()[0] 69 current_hash = output.split()[0]
72 ima_hash = "" 70 ima_hash = ""
73 71
74 while tries < maximum_tries: 72 while tries < maximum_tries:
75 status, output = self.target.run("cat %s | grep %s" \ 73 status, output = self.target.run("cat %s | grep -e '%s'" \
76 % (ima_measure_file, filename)) 74 % (ima_measure_file, filename))
77 # get last entry, 4th field 75 # get last entry, 4th field
78 if status == 0: 76 if status == 0: