From 180eee569f17d5cd778871e2bef02192bfd9507a Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Thu, 23 Jul 2020 17:24:01 +0100 Subject: [PATCH] Objects: Add a convenience function for validating enum values --- volatility/framework/objects/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/volatility/framework/objects/__init__.py b/volatility/framework/objects/__init__.py index 191eb5bbe..3d3fcd5b9 100644 --- a/volatility/framework/objects/__init__.py +++ b/volatility/framework/objects/__init__.py @@ -466,6 +466,11 @@ class Enumeration(interfaces.objects.ObjectInterface, int): def choices(self) -> Dict[str, int]: return self._vol['choices'] + @property + def legal(self) -> bool: + """Returns whether the value for the object is a valid choice""" + return self in self.choices.values() + def __getattr__(self, attr: str) -> str: """Returns the value for a specific name.""" if attr in self._vol['choices']: