Improve JSON output format for enhanced processing
authorkrishjainx <kjain7@u.rochester.edu>
Thu, 14 Mar 2024 09:53:19 +0000 (05:53 -0400)
committerkrishjainx <kjain7@u.rochester.edu>
Thu, 14 Mar 2024 09:53:19 +0000 (05:53 -0400)
kernel_hardening_checker/engine.py

index 268a142387b87940d1803adbb2fe72b6d6c71a24..b78b1013a2e84b2a2de0b12196b9093cfdc290bc 100644 (file)
@@ -104,9 +104,16 @@ class OptCheck:
             print(f'| {colorize_result(self.result)}', end='')
 
     def json_dump(self, with_results):
-        dump = [self.name, self.type, self.expected, self.decision, self.reason]
+        dump = {
+            "option_name": self.name,
+            "type": self.type,
+            "desired_val": self.expected,
+            "decision": self.decision,
+            "reason": self.reason,
+        }
         if with_results:
-            dump.append(self.result)
+            dump["check_result_text"] = self.result
+            dump["check_result"] = "FAIL" not in self.result
         return dump
 
 
@@ -219,7 +226,9 @@ class ComplexOptCheck:
     def json_dump(self, with_results):
         dump = self.opts[0].json_dump(False)
         if with_results:
-            dump.append(self.result)
+            # Add 'result_text' and 'result' keys to the dictionary
+            dump["check_result_text"] = self.result
+            dump["check_result"] = "FAIL" not in self.result
         return dump