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
be0bde21
Commit
be0bde21
authored
Jul 15, 2023
by
Alexander Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Precise the Kconfig parsing
parent
822d781d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
__init__.py
kconfig_hardened_check/__init__.py
+6
-4
No files found.
kconfig_hardened_check/__init__.py
View file @
be0bde21
...
@@ -152,8 +152,8 @@ def print_checklist(mode, checklist, with_results):
...
@@ -152,8 +152,8 @@ def print_checklist(mode, checklist, with_results):
def
parse_kconfig_file
(
parsed_options
,
fname
):
def
parse_kconfig_file
(
parsed_options
,
fname
):
with
_open
(
fname
,
'rt'
,
encoding
=
'utf-8'
)
as
f
:
with
_open
(
fname
,
'rt'
,
encoding
=
'utf-8'
)
as
f
:
opt_is_on
=
re
.
compile
(
"CONFIG_[a-zA-Z0-9_]
*=[a-zA-Z0-9_
\"
]*
"
)
opt_is_on
=
re
.
compile
(
"CONFIG_[a-zA-Z0-9_]
+=.+$
"
)
opt_is_off
=
re
.
compile
(
"# CONFIG_[a-zA-Z0-9_]
* is not set
"
)
opt_is_off
=
re
.
compile
(
"# CONFIG_[a-zA-Z0-9_]
+ is not set$
"
)
for
line
in
f
.
readlines
():
for
line
in
f
.
readlines
():
line
=
line
.
strip
()
line
=
line
.
strip
()
...
@@ -166,8 +166,10 @@ def parse_kconfig_file(parsed_options, fname):
...
@@ -166,8 +166,10 @@ def parse_kconfig_file(parsed_options, fname):
sys
.
exit
(
f
'[!] ERROR: bad enabled Kconfig option "{line}"'
)
sys
.
exit
(
f
'[!] ERROR: bad enabled Kconfig option "{line}"'
)
elif
opt_is_off
.
match
(
line
):
elif
opt_is_off
.
match
(
line
):
option
,
value
=
line
[
2
:]
.
split
(
' '
,
1
)
option
,
value
=
line
[
2
:]
.
split
(
' '
,
1
)
if
value
!=
'is not set'
:
assert
(
value
==
'is not set'
),
\
sys
.
exit
(
f
'[!] ERROR: bad disabled Kconfig option "{line}"'
)
f
'unexpected value of disabled Kconfig option "{line}"'
elif
line
!=
''
and
not
line
.
startswith
(
'#'
):
print
(
f
'[!] WARNING: strange line in Kconfig file: "{line}"'
)
if
option
in
parsed_options
:
if
option
in
parsed_options
:
sys
.
exit
(
f
'[!] ERROR: Kconfig option "{line}" exists multiple times'
)
sys
.
exit
(
f
'[!] ERROR: Kconfig option "{line}" exists multiple times'
)
...
...
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