projects
/
kconfig-hardened-check.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add more typing annotations to checks.py
[kconfig-hardened-check.git]
/
kernel_hardening_checker
/
engine.py
diff --git
a/kernel_hardening_checker/engine.py
b/kernel_hardening_checker/engine.py
index 0bf0ad560f09ccd0950e14f12dd4f625d31a391c..f6282fe540382895fa30f28f2c62dfa9c868475f 100644
(file)
--- a/
kernel_hardening_checker/engine.py
+++ b/
kernel_hardening_checker/engine.py
@@
-11,9
+11,12
@@
This module is the engine of checks.
# pylint: disable=missing-class-docstring,missing-function-docstring
# pylint: disable=line-too-long,invalid-name,too-many-branches
# pylint: disable=missing-class-docstring,missing-function-docstring
# pylint: disable=line-too-long,invalid-name,too-many-branches
-from typing import Dict, Tuple
import sys
import sys
+from typing import Optional, Dict, Tuple
+StrOrNone = Optional[str]
+TupleOrNone = Optional[Tuple]
+
GREEN_COLOR = '\x1b[32m'
RED_COLOR = '\x1b[31m'
COLOR_END = '\x1b[0m'
GREEN_COLOR = '\x1b[32m'
RED_COLOR = '\x1b[31m'
COLOR_END = '\x1b[0m'
@@
-115,6
+118,7
@@
class OptCheck:
"reason": self.reason,
}
if with_results:
"reason": self.reason,
}
if with_results:
+ assert self.result, f'unexpected empty result in {self.name}'
dump["check_result"] = self.result
dump["check_result_bool"] = self.result.startswith('OK')
return dump
dump["check_result"] = self.result
dump["check_result_bool"] = self.result.startswith('OK')
return dump
@@
-230,6
+234,7
@@
class ComplexOptCheck:
dump = self.opts[0].json_dump(False)
if with_results:
# Add the 'check_result' and 'check_result_bool' keys to the dictionary
dump = self.opts[0].json_dump(False)
if with_results:
# Add the 'check_result' and 'check_result_bool' keys to the dictionary
+ assert self.result, f'unexpected empty result in {self.name}'
dump["check_result"] = self.result
dump["check_result_bool"] = self.result.startswith('OK')
return dump
dump["check_result"] = self.result
dump["check_result_bool"] = self.result.startswith('OK')
return dump