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
759ed4e9
Commit
759ed4e9
authored
Nov 09, 2022
by
Alexander Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add assertions to check arguments of the Class constructors
parent
03908fad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
__init__.py
kconfig_hardened_check/__init__.py
+23
-3
No files found.
kconfig_hardened_check/__init__.py
View file @
759ed4e9
...
...
@@ -77,12 +77,30 @@ SIMPLE_OPTION_TYPES = ('kconfig', 'version', 'cmdline')
class
OptCheck
:
# Constructor without the 'expected' parameter is for option presence checks (any value is OK)
def
__init__
(
self
,
reason
,
decision
,
name
,
expected
=
None
):
assert
(
reason
and
decision
and
name
),
\
'invalid
{} check for "{}"'
.
format
(
self
.
__class__
.
__name__
,
name
)
assert
(
name
and
name
==
name
.
strip
()
and
len
(
name
.
split
())
==
1
),
\
'invalid
name "{}" for {}'
.
format
(
name
,
self
.
__class__
.
__name__
)
self
.
name
=
name
self
.
expected
=
expected
assert
(
decision
and
decision
==
decision
.
strip
()
and
len
(
decision
.
split
())
==
1
),
\
'invalid decision "{}" for "{}" check'
.
format
(
decision
,
name
)
self
.
decision
=
decision
assert
(
reason
and
reason
==
reason
.
strip
()
and
len
(
reason
.
split
())
==
1
),
\
'invalid reason "{}" for "{}" check'
.
format
(
reason
,
name
)
self
.
reason
=
reason
if
expected
:
assert
(
expected
==
expected
.
strip
()),
\
'invalid expected value "{}" for "{}" check (1)'
.
format
(
expected
,
name
)
val_len
=
len
(
expected
.
split
())
if
val_len
==
3
:
assert
(
expected
==
'is not set'
),
\
'invalid expected value "{}" for "{}" check (2)'
.
format
(
expected
,
name
)
else
:
assert
(
val_len
==
1
),
\
'invalid expected value "{}" for "{}" check (3)'
.
format
(
expected
,
name
)
self
.
expected
=
expected
self
.
state
=
None
self
.
result
=
None
...
...
@@ -144,6 +162,8 @@ class CmdlineCheck(OptCheck):
class
VersionCheck
:
def
__init__
(
self
,
ver_expected
):
assert
(
ver_expected
and
isinstance
(
ver_expected
,
tuple
)
and
len
(
ver_expected
)
==
2
),
\
'invalid version "{}" for VersionCheck'
.
format
(
ver_expected
)
self
.
ver_expected
=
ver_expected
self
.
ver
=
()
self
.
result
=
None
...
...
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