Skip to content

Commit bf000ff

Browse files
committed
Core: Add recursion protection to VersionRequirement check
1 parent ace590e commit bf000ff

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

volatility3/framework/configuration/requirements.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,13 +546,26 @@ def __init__(
546546
self._version = version
547547

548548
def unsatisfied(
549-
self, context: interfaces.context.ContextInterface, config_path: str
549+
self,
550+
context: interfaces.context.ContextInterface,
551+
config_path: str,
552+
accumulator: Optional[
553+
List[interfaces.configuration.VersionableInterface]
554+
] = None,
550555
) -> Dict[str, interfaces.configuration.RequirementInterface]:
551556
# Mypy doesn't appreciate our classproperty implementation, self._plugin.version has no type
552557
config_path = interfaces.configuration.path_join(config_path, self.name)
553558
if not self.matches_required(self._version, self._component.version):
554559
return {config_path: self}
555560

561+
if accumulator is None:
562+
accumulator = set([self._component])
563+
else:
564+
if self._component in accumulator:
565+
return {config_path: self}
566+
else:
567+
accumulator.add(self._component)
568+
556569
# Check for child requirements
557570
if issubclass(self._component, interfaces.configuration.ConfigurableInterface):
558571
result = {}
@@ -562,8 +575,7 @@ def unsatisfied(
562575
):
563576
result.update(
564577
requirement.unsatisfied(
565-
context,
566-
config_path,
578+
context, config_path, accumulator.copy()
567579
)
568580
)
569581

0 commit comments

Comments
 (0)