Skip to contentSkip to conversation

oeqa: fix hash test to match new changes

PATCH In review Armin Kuster 2 participants 4 messages May 2, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 oeqa: fix hash test to match new changes

---
 meta-integrity/lib/oeqa/runtime/cases/ima.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
meta-integrity/lib/oeqa/runtime/cases/ima.py +4 -6
index 0c8617a..6b361ca 100644
@@ -58,21 +58,19 @@ class IMACheck(OERuntimeTestCase):
     @OETestDepends(['ima.IMACheck.test_ima_enabled'])
     def test_ima_hash(self):
         ''' Test if IMA stores correct file hash '''
-        filename = "/etc/filetest"
+        filename = "/etc/ld.so.cache"
         ima_measure_file = "/sys/kernel/security/ima/ascii_runtime_measurements"
-        status, output = self.target.run("echo test > %s" % filename)
-        self.assertEqual(status, 0, "Cannot create file %s on target" % filename)
 
         # wait for the IMA system to update the entry
-        maximum_tries = 30
+        maximum_tries = 3 
         tries = 0
-        status, output = self.target.run("sha1sum %s" %filename)
+        status, output = self.target.run("sha256sum %s" %filename)
         sleep(2)
         current_hash = output.split()[0]
         ima_hash = ""
 
         while tries < maximum_tries:
-            status, output = self.target.run("cat %s | grep %s" \
+            status, output = self.target.run("cat %s | grep -e '%s'" \
                 % (ima_measure_file, filename))
             # get last entry, 4th field
             if status == 0:
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 integrity-image-minimal: adapt QEMU cmdline to new changes

---
 meta-integrity/recipes-core/images/integrity-image-minimal.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-integrity/recipes-core/images/integrity-image-minimal.bb +1 -1
index f40e867..5022170 100644
@@ -18,4 +18,4 @@ export IMAGE_BASENAME = "integrity-image-minimal"
 
 INHERIT += "ima-evm-rootfs"
 
-QB_KERNEL_CMDLINE_APPEND:append = " ima_appraise=fix ima_policy=tcb ima_policy=appraise_tcb"
+QB_KERNEL_CMDLINE_APPEND:append = " ima_policy=tcb ima_appraise=fix"
Signature · 1 line
2.25.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [yocto] [meta-security][PATCH 2/2] integrity-image-minimal: adapt QEMU cmdline to new changes

Quoted 10 lines · Armin Kuster
---
  meta-integrity/recipes-core/images/integrity-image-minimal.bb | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meta-integrity/recipes-core/images/integrity-image-minimal.bb +0 -0
index f40e867..5022170 100644

meta-integrity/recipes-core/images/integrity-image-minimal.bb export IMAGE_BASENAME = "integrity-image-minimal" · line 21

Quoted 5 lines
meta-integrity/recipes-core/images/integrity-image-minimal.bb +1 -1
@@ -18,4 +18,4 @@ export IMAGE_BASENAME = "integrity-image-minimal"
 
  INHERIT += "ima-evm-rootfs"
 
-QB_KERNEL_CMDLINE_APPEND:append = " ima_appraise=fix ima_policy=tcb ima_policy=appraise_tcb"
+QB_KERNEL_CMDLINE_APPEND:append = " ima_policy=tcb ima_appraise=fix"
Quoted 11 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#59836): https://lists.yoctoproject.org/g/yocto/message/59836
Mute This Topic: https://lists.yoctoproject.org/mt/98636144/1792208
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reviewed-by on v1 1/2
#3 lore raw
In reply to Armin Kuster
Quoted 1 line · Armin Kuster
Quoted 45 lines
---
  meta-integrity/lib/oeqa/runtime/cases/ima.py | 10 ++++------
  1 file changed, 4 insertions(+), 6 deletions(-)
meta-integrity/lib/oeqa/runtime/cases/ima.py +4 -7
index 0c8617a..6b361ca 100644
@@ -58,21 +58,19 @@ class IMACheck(OERuntimeTestCase):
      @OETestDepends(['ima.IMACheck.test_ima_enabled'])
      def test_ima_hash(self):
          ''' Test if IMA stores correct file hash '''
-        filename = "/etc/filetest"
+        filename = "/etc/ld.so.cache"
          ima_measure_file = "/sys/kernel/security/ima/ascii_runtime_measurements"
-        status, output = self.target.run("echo test > %s" % filename)
-        self.assertEqual(status, 0, "Cannot create file %s on target" % filename)
 
          # wait for the IMA system to update the entry
-        maximum_tries = 30
+        maximum_tries = 3
          tries = 0
-        status, output = self.target.run("sha1sum %s" %filename)
+        status, output = self.target.run("sha256sum %s" %filename)
          sleep(2)
          current_hash = output.split()[0]
          ima_hash = ""
 
          while tries < maximum_tries:
-            status, output = self.target.run("cat %s | grep %s" \
+            status, output = self.target.run("cat %s | grep -e '%s'" \
                  % (ima_measure_file, filename))
              # get last entry, 4th field
              if status == 0:
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#59835): https://lists.yoctoproject.org/g/yocto/message/59835
Mute This Topic: https://lists.yoctoproject.org/mt/98636143/1792208
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-