diff --git a/volatility/cli/text_renderer.py b/volatility/cli/text_renderer.py index d0e12b735..86c63454f 100644 --- a/volatility/cli/text_renderer.py +++ b/volatility/cli/text_renderer.py @@ -156,7 +156,10 @@ class QuickTextRenderer(CLIRenderer): accumulator.write("{}".format("\t".join(line))) return accumulator - grid.populate(visitor, outfd) + if not grid.populated: + grid.populate(visitor, outfd) + else: + grid.visit(node = None, function = visitor, initial_accumulator = outfd) outfd.write("\n") @@ -203,7 +206,10 @@ class CSVRenderer(CLIRenderer): accumulator.write("{}".format(",".join(line))) return accumulator - grid.populate(visitor, outfd) + if not grid.populated: + grid.populate(visitor, outfd) + else: + grid.visit(node = None, function = visitor, initial_accumulator = outfd) outfd.write("\n") @@ -251,7 +257,10 @@ class PrettyTextRenderer(CLIRenderer): return accumulator final_output = [] # type: List[Tuple[int, Dict[Column, bytes]]] - grid.populate(visitor, final_output) + if not grid.populated: + grid.populate(visitor, final_output) + else: + grid.visit(node = None, function = visitor, initial_accumulator = final_output) # Always align the tree to the left format_string_list = ["{0:<" + str(max_column_widths[tree_indent_column]) + "s}"] diff --git a/volatility/framework/interfaces/renderers.py b/volatility/framework/interfaces/renderers.py index 3cac324f7..23f96c077 100644 --- a/volatility/framework/interfaces/renderers.py +++ b/volatility/framework/interfaces/renderers.py @@ -149,7 +149,7 @@ class TreeGrid(object, metaclass = ABCMeta): """Method used to sanitize column names for TreeNodes.""" @abstractmethod - def populate(self, func: VisitorSignature = None, initial_accumulator: Any = None) -> None: + def populate(self, function: VisitorSignature = None, initial_accumulator: Any = None) -> None: """Populates the tree by consuming the TreeGrid's construction generator Func is called on every node, so can be used to create output on demand. diff --git a/volatility/framework/renderers/__init__.py b/volatility/framework/renderers/__init__.py index 4c3ab29eb..25e94f3c2 100644 --- a/volatility/framework/renderers/__init__.py +++ b/volatility/framework/renderers/__init__.py @@ -178,7 +178,7 @@ class TreeGrid(interfaces.renderers.TreeGrid): output += (letter if letter in 'abcdefghiljklmnopqrstuvwxyz_0123456789' else '_') return output - def populate(self, func: interfaces.renderers.VisitorSignature = None, initial_accumulator: Any = None) -> None: + def populate(self, function: interfaces.renderers.VisitorSignature = None, initial_accumulator: Any = None) -> None: """Populates the tree by consuming the TreeGrid's construction generator Func is called on every node, so can be used to create output on demand. @@ -186,9 +186,9 @@ class TreeGrid(interfaces.renderers.TreeGrid): This is equivalent to a one-time visit. """ accumulator = initial_accumulator - if func is None: + if function is None: - def func(_x: interfaces.renderers.TreeNode, _y: Any) -> Any: + def function(_x: interfaces.renderers.TreeNode, _y: Any) -> Any: return None if not self.populated: @@ -198,8 +198,8 @@ class TreeGrid(interfaces.renderers.TreeGrid): parent = prev_nodes[parent_index - 1] if parent_index > 0 else None treenode = self._append(parent, item) prev_nodes = prev_nodes[0:parent_index] + [treenode] - if func is not None: - accumulator = func(treenode, accumulator) + if function is not None: + accumulator = function(treenode, accumulator) self._row_count += 1 self._populated = True