Skip to content

Commit 882d7e2

Browse files
ceolinrado17
authored andcommitted
[nrf fromtree] build: kconfig: Add support for warning insecure features
Add a new promptless Kconfig symbol (INSECURE). This symbols must be selected by any setting which is used to enable an insecure feature. Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com> (cherry picked from commit 674fd09)
1 parent 258633a commit 882d7e2

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Kconfig.zephyr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,12 @@ config WARN_EXPERIMENTAL
10301030
Print a warning when the Kconfig tree is parsed if any experimental
10311031
features are enabled.
10321032

1033+
config NOT_SECURE
1034+
bool
1035+
help
1036+
Symbol to be selected by a feature to inidicate that feature is
1037+
not secure.
1038+
10331039
config TAINT
10341040
bool
10351041
help

scripts/kconfig/kconfig.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def main():
9393
if kconf.syms.get('WARN_EXPERIMENTAL', kconf.y).tri_value == 2:
9494
check_experimental(kconf)
9595

96+
check_not_secure(kconf)
97+
9698
# Hack: Force all symbols to be evaluated, to catch warnings generated
9799
# during evaluation. Wait till the end to write the actual output files, so
98100
# that we don't generate any output if there are warnings-turned-errors.
@@ -266,6 +268,16 @@ def check_experimental(kconf):
266268
selector_name = split_expr(selector, AND)[0].name
267269
warn(f'Experimental symbol {selector_name} is enabled.')
268270

271+
def check_not_secure(kconf):
272+
not_secure = kconf.syms.get('NOT_SECURE')
273+
dep_expr = kconf.n if not_secure is None else not_secure.rev_dep
274+
275+
if dep_expr is not kconf.n:
276+
selectors = [s for s in split_expr(dep_expr, OR) if expr_value(s) == 2]
277+
for selector in selectors:
278+
selector_name = split_expr(selector, AND)[0].name
279+
warn(f'Not secure symbol {selector_name} is enabled.')
280+
269281

270282
def promptless(sym):
271283
# Returns True if 'sym' has no prompt. Since the symbol might be defined in

share/sysbuild/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ config WARN_DEPRECATED
6969
Print a warning when the Kconfig tree is parsed if any deprecated
7070
features are enabled.
7171

72+
config NOT_SECURE
73+
bool
74+
help
75+
Symbol to be selected by a feature to inidicate that feature is
76+
not secure.
77+
7278
rsource "images/Kconfig"
7379

7480
menu "Build options"

0 commit comments

Comments
 (0)