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
52216da1
Commit
52216da1
authored
Mar 26, 2020
by
Alexander Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add main() and clean up working with globals
parent
a7e40940
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
__init__.py
kconfig-hardened-check/__init__.py
+12
-4
No files found.
kconfig-hardened-check/__init__.py
View file @
52216da1
...
...
@@ -69,7 +69,7 @@ debug_mode = False
json_mode
=
False
supported_archs
=
[
'X86_64'
,
'X86_32'
,
'ARM64'
,
'ARM'
]
config_checklist
=
[]
kernel_version
=
None
...
...
@@ -525,7 +525,7 @@ def perform_checks(checklist, parsed_options):
opt
.
check
()
def
check_config_file
(
checklist
,
fname
):
def
check_config_file
(
checklist
,
fname
,
arch
):
with
open
(
fname
,
'r'
)
as
f
:
parsed_options
=
OrderedDict
()
opt_is_on
=
re
.
compile
(
"CONFIG_[a-zA-Z0-9_]*=[a-zA-Z0-9_
\"
]*"
)
...
...
@@ -568,8 +568,13 @@ def check_config_file(checklist, fname):
print_checklist
(
checklist
,
True
)
def
main
():
global
debug_mode
global
json_mode
global
kernel_version
config_checklist
=
[]
if
__name__
==
'__main__'
:
parser
=
ArgumentParser
(
description
=
'Checks the hardening options in the Linux kernel config'
)
parser
.
add_argument
(
'-p'
,
'--print'
,
choices
=
supported_archs
,
help
=
'print hardening preferences for selected architecture'
)
...
...
@@ -603,7 +608,7 @@ if __name__ == '__main__':
print
(
'[+] Detected kernel version: {}.{}'
.
format
(
kernel_version
[
0
],
kernel_version
[
1
]))
construct_checklist
(
config_checklist
,
arch
)
check_config_file
(
config_checklist
,
args
.
config
)
check_config_file
(
config_checklist
,
args
.
config
,
arch
)
error_count
=
len
(
list
(
filter
(
lambda
opt
:
opt
.
result
.
startswith
(
'FAIL'
),
config_checklist
)))
ok_count
=
len
(
list
(
filter
(
lambda
opt
:
opt
.
result
.
startswith
(
'OK'
),
config_checklist
)))
if
debug_mode
:
...
...
@@ -621,3 +626,6 @@ if __name__ == '__main__':
sys
.
exit
(
0
)
parser
.
print_help
()
if
__name__
==
'__main__'
:
main
()
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