mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-30 05:24:52 +02:00
Plugins: Allow None types in the configuration tree as values
This commit is contained in:
@@ -35,7 +35,7 @@ vollog = logging.getLogger(__name__)
|
||||
|
||||
BasicTypes = (int, bool, bytes, str)
|
||||
SimpleTypes = Union[int, bool, bytes, str]
|
||||
ConfigSimpleType = Union[SimpleTypes, List[SimpleTypes]]
|
||||
ConfigSimpleType = Optional[Union[SimpleTypes, List[SimpleTypes]]]
|
||||
|
||||
|
||||
def path_join(*args) -> str:
|
||||
@@ -184,6 +184,8 @@ class HierarchicalDict(collections.abc.Mapping):
|
||||
raise TypeError("Configuration list types cannot contain list types")
|
||||
new_list.append(element_value)
|
||||
return new_list
|
||||
elif value is None:
|
||||
return None
|
||||
else:
|
||||
raise TypeError("Invalid type stored in configuration")
|
||||
|
||||
@@ -296,7 +298,7 @@ class RequirementInterface(metaclass = ABCMeta):
|
||||
def __init__(self,
|
||||
name: str,
|
||||
description: str = None,
|
||||
default: Optional[ConfigSimpleType] = None,
|
||||
default: ConfigSimpleType = None,
|
||||
optional: bool = False) -> None:
|
||||
"""
|
||||
|
||||
@@ -334,7 +336,7 @@ class RequirementInterface(metaclass = ABCMeta):
|
||||
return self._description
|
||||
|
||||
@property
|
||||
def default(self) -> Optional[ConfigSimpleType]:
|
||||
def default(self) -> ConfigSimpleType:
|
||||
"""Returns the default value if one is set."""
|
||||
return self._default
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class PluginInterface(interfaces.configuration.ConfigurableInterface,
|
||||
raise exceptions.PluginRequirementException("The plugin configuration failed to validate")
|
||||
# Populate any optional defaults
|
||||
for requirement in self.get_requirements():
|
||||
if requirement.name not in self.config and requirement.default is not None:
|
||||
if requirement.name not in self.config:
|
||||
self.config[requirement.name] = requirement.default
|
||||
|
||||
self._file_consumer = None # type: Optional[FileConsumerInterface]
|
||||
|
||||
Reference in New Issue
Block a user