From d66b81885f5e8f69e5c5268e8a3fd22d07dbf03c Mon Sep 17 00:00:00 2001 From: krishjainx Date: Thu, 14 Mar 2024 05:53:19 -0400 Subject: [PATCH] Improve JSON output format for enhanced processing --- kernel_hardening_checker/engine.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel_hardening_checker/engine.py b/kernel_hardening_checker/engine.py index 268a142..b78b101 100644 --- a/kernel_hardening_checker/engine.py +++ b/kernel_hardening_checker/engine.py @@ -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 -- 2.31.1