From cbce5c61846acc1283239db1492b6877535abfda Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Wed, 14 Mar 2018 01:07:58 +0000 Subject: [PATCH] Expose the sanitize method, since it's necessary for accessing columns. --- volatility/framework/interfaces/renderers.py | 5 +++++ volatility/framework/renderers/__init__.py | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/volatility/framework/interfaces/renderers.py b/volatility/framework/interfaces/renderers.py index 31deeb0f4..dcce61fda 100644 --- a/volatility/framework/interfaces/renderers.py +++ b/volatility/framework/interfaces/renderers.py @@ -127,6 +127,11 @@ class TreeGrid(object, metaclass = ABCMeta): :param generator: A generator that populates the tree/grid structure """ + @staticmethod + @abstractmethod + def sanitize_name(text: str) -> str: + """Method used to sanitize column names for TreeNodes""" + @abstractmethod def populate(self, func: VisitorSignature = None, diff --git a/volatility/framework/renderers/__init__.py b/volatility/framework/renderers/__init__.py index 09e14eb9f..3822d4ba3 100644 --- a/volatility/framework/renderers/__init__.py +++ b/volatility/framework/renderers/__init__.py @@ -150,7 +150,7 @@ class TreeGrid(interfaces.renderers.TreeGrid): "Column {}'s type is not a simple type: {}".format(name, column_type.__class__.__name__)) converted_columns.append(interfaces.renderers.Column(len(converted_columns), name, column_type)) self.RowStructure = collections.namedtuple("RowStructure", - [self._sanitize(column.name) for column in converted_columns]) + [self.sanitize_name(column.name) for column in converted_columns]) self._columns = converted_columns if generator is None: generator = [] @@ -159,11 +159,11 @@ class TreeGrid(interfaces.renderers.TreeGrid): self._generator = generator @staticmethod - def _sanitize(text: str) -> str: + def sanitize_name(text: str) -> str: output = "" for letter in text.lower(): if letter != ' ': - output += (letter if letter in 'abcdefghiljklmnopqrstuvwxyz_' else '_') + output += (letter if letter in 'abcdefghiljklmnopqrstuvwxyz_0123456789' else '_') return output def populate(self,