Skip to content

Commit

Permalink
Refactor check of BasicType
Browse files Browse the repository at this point in the history
The intention is either a BasicType or a list where each element is only a BasicType (and not a list).
  • Loading branch information
j-t-1 authored Dec 21, 2024
1 parent 0b2f4fd commit bed03df
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions volatility3/cli/volshell/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,15 @@ def create_configurable(
del kwargs[argname]

for keyword, val in kwargs.items():
if not isinstance(val, (interfaces.configuration.BasicTypes, list)):
if all(isinstance(x, interfaces.configuration.BasicTypes) for x in val):
raise TypeError(
"Configurable values must be simple types (int, bool, str, bytes)"
)
BasicType_or_list_of_BasicType = False # excludes list of lists
if isinstance(val, interfaces.configuration.BasicTypes):
BasicType_or_list_of_BasicType = True
if all(isinstance(x, interfaces.configuration.BasicTypes) for x in val):
BasicType_or_list_of_BasicType = True
if not BasicType_or_list_of_BasicType:
raise TypeError(
"Configurable values must be simple types (int, bool, str, bytes)"
)
self.context.config[config_path + "." + keyword] = val

constructed = clazz(self.context, config_path, **constructor_args)
Expand Down

0 comments on commit bed03df

Please sign in to comment.