From: krishjainx Date: Thu, 14 Mar 2024 09:53:19 +0000 (-0400) Subject: Improve JSON output format for enhanced processing X-Git-Tag: v0.6.10~93^2~3 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=d66b81885f5e8f69e5c5268e8a3fd22d07dbf03c;p=kconfig-hardened-check.git Improve JSON output format for enhanced processing --- 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