Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kernel-hardening-checker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
kernel-hardening-checker
Commits
bb2cacde
Commit
bb2cacde
authored
Mar 31, 2020
by
Alexander Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create polymorphism for printing, add table_print() method for each class
That makes print_checklist() much better.
parent
80ade834
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
23 deletions
+26
-23
__init__.py
kconfig_hardened_check/__init__.py
+26
-23
No files found.
kconfig_hardened_check/__init__.py
View file @
bb2cacde
...
...
@@ -98,6 +98,12 @@ class OptCheck:
else
:
return
False
,
self
.
result
def
table_print
(
self
,
with_results
):
print
(
'CONFIG_{:<38}|{:^13}|{:^10}|{:^20}'
.
format
(
self
.
name
,
self
.
expected
,
self
.
decision
,
self
.
reason
),
end
=
''
)
if
with_results
:
print
(
'| {}'
.
format
(
self
.
result
),
end
=
''
)
print
()
class
VerCheck
:
def
__init__
(
self
,
ver_expected
):
...
...
@@ -118,6 +124,13 @@ class VerCheck:
self
.
result
=
'FAIL: version < '
+
str
(
self
.
ver_expected
[
0
])
+
'.'
+
str
(
self
.
ver_expected
[
1
])
return
False
,
self
.
result
def
table_print
(
self
,
with_results
):
ver_req
=
'kernel version >= '
+
str
(
self
.
ver_expected
[
0
])
+
'.'
+
str
(
self
.
ver_expected
[
1
])
print
(
'{:<91}'
.
format
(
ver_req
),
end
=
''
)
if
with_results
:
print
(
'| {}'
.
format
(
self
.
result
),
end
=
''
)
print
()
class
ComplexOptCheck
:
def
__init__
(
self
,
*
opts
):
...
...
@@ -144,6 +157,18 @@ class ComplexOptCheck:
def
reason
(
self
):
return
self
.
opts
[
0
]
.
reason
def
table_print
(
self
,
with_results
):
if
debug_mode
:
print
(
' {:87}'
.
format
(
'<<< '
+
self
.
__class__
.
__name__
+
' >>>'
),
end
=
''
)
if
with_results
:
print
(
'| {}'
.
format
(
self
.
result
),
end
=
''
)
print
()
for
o
in
self
.
opts
:
o
.
table_print
(
with_results
)
else
:
o
=
self
.
opts
[
0
]
o
.
table_print
(
with_results
)
class
OR
(
ComplexOptCheck
):
# self.opts[0] is the option that this OR-check is about.
...
...
@@ -458,13 +483,6 @@ def construct_checklist(checklist, arch):
# checklist.append(OptCheck('LKDTM', 'm', 'my', 'feature_test'))
def
print_opt
(
opt
,
with_results
):
print
(
'CONFIG_{:<38}|{:^13}|{:^10}|{:^20}'
.
format
(
opt
.
name
,
opt
.
expected
,
opt
.
decision
,
opt
.
reason
),
end
=
''
)
if
with_results
:
print
(
'| {}'
.
format
(
opt
.
result
),
end
=
''
)
print
()
def
print_checklist
(
checklist
,
with_results
):
if
json_mode
:
opts
=
[]
...
...
@@ -489,22 +507,7 @@ def print_checklist(checklist, with_results):
# table contents
for
opt
in
checklist
:
if
debug_mode
and
hasattr
(
opt
,
'opts'
):
print
(
' {:87}'
.
format
(
'<<< '
+
opt
.
__class__
.
__name__
+
' >>>'
),
end
=
''
)
if
with_results
:
print
(
'| {}'
.
format
(
opt
.
result
),
end
=
''
)
print
()
for
o
in
opt
.
opts
:
if
hasattr
(
o
,
'ver_expected'
):
ver_req
=
'kernel version >= '
+
str
(
o
.
ver_expected
[
0
])
+
'.'
+
str
(
o
.
ver_expected
[
1
])
print
(
'{:<91}'
.
format
(
ver_req
),
end
=
''
)
if
with_results
:
print
(
'| {}'
.
format
(
o
.
result
),
end
=
''
)
print
()
else
:
print_opt
(
o
,
with_results
)
else
:
print_opt
(
opt
,
with_results
)
opt
.
table_print
(
with_results
)
if
debug_mode
:
print
(
'-'
*
sep_line_len
)
print
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment