Fix the fresh set_state() bug found by unittest
authorAlexander Popov <alex.popov@linux.com>
Sat, 9 Mar 2024 21:41:49 +0000 (00:41 +0300)
committerAlexander Popov <alex.popov@linux.com>
Sat, 9 Mar 2024 21:41:49 +0000 (00:41 +0300)
This function should write 'self.state' anyway.

Refers to #88, #89, #97

kernel_hardening_checker/engine.py

index 8ba34ef9a96949b392c1409eeef8966d42ad0c29..960f4f44c7278db7a2ee7ffe9e3e045fcb5bf7fc 100644 (file)
@@ -62,10 +62,9 @@ class OptCheck:
         return None
 
     def set_state(self, data):
-        if data:
-            assert(isinstance(data, str)), \
+        assert(data is None or isinstance(data, str)), \
                f'invalid state "{data}" for "{self.name}" check'
-            self.state = data
+        self.state = data
 
     def check(self):
         # handle the 'is present' check