Skip to content

Commit 26cd731

Browse files
committed
CLI: Filter on rendered values
1 parent d56cd83 commit 26cd731

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

volatility3/cli/text_renderer.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,15 @@ def render(self, grid: interfaces.renderers.TreeGrid) -> None:
179179
outfd.write("\n{}\n".format("\t".join(line)))
180180

181181
def visitor(node: interfaces.renderers.TreeNode, accumulator):
182-
if self.filter and self.filter.filter(node.values):
182+
line = []
183+
for column_index in range(len(grid.columns)):
184+
column = grid.columns[column_index]
185+
renderer = self._type_renderers.get(
186+
column.type, self._type_renderers["default"]
187+
)
188+
line.append(renderer(node.values[column_index]))
189+
190+
if self.filter and self.filter.filter(line):
183191
return accumulator
184192

185193
accumulator.write("\n")
@@ -188,13 +196,6 @@ def visitor(node: interfaces.renderers.TreeNode, accumulator):
188196
"*" * max(0, node.path_depth - 1)
189197
+ ("" if (node.path_depth <= 1) else " ")
190198
)
191-
line = []
192-
for column_index in range(len(grid.columns)):
193-
column = grid.columns[column_index]
194-
renderer = self._type_renderers.get(
195-
column.type, self._type_renderers["default"]
196-
)
197-
line.append(renderer(node.values[column_index]))
198199
accumulator.write("{}".format("\t".join(line)))
199200
accumulator.flush()
200201
return accumulator
@@ -259,12 +260,18 @@ def render(self, grid: interfaces.renderers.TreeGrid) -> None:
259260
def visitor(node: interfaces.renderers.TreeNode, accumulator):
260261
# Nodes always have a path value, giving them a path_depth of at least 1, we use max just in case
261262
row = {"TreeDepth": str(max(0, node.path_depth - 1))}
263+
line = []
262264
for column_index in range(len(grid.columns)):
263265
column = grid.columns[column_index]
264266
renderer = self._type_renderers.get(
265267
column.type, self._type_renderers["default"]
266268
)
267269
row[f"{column.name}"] = renderer(node.values[column_index])
270+
line.append(row[f"{column.name}"])
271+
272+
if self.filter and self.filter.filter(line):
273+
return accumulator
274+
268275
accumulator.writerow(row)
269276
return accumulator
270277

@@ -317,10 +324,8 @@ def visitor(
317324
max_column_widths.get(tree_indent_column, 0), node.path_depth
318325
)
319326

320-
if self.filter and self.filter.filter(node.values):
321-
return accumulator
322-
323327
line = {}
328+
rendered_line = []
324329
for column_index in range(len(grid.columns)):
325330
column = grid.columns[column_index]
326331
renderer = self._type_renderers.get(
@@ -334,6 +339,11 @@ def visitor(
334339
max_column_widths.get(column.name, len(column.name)), field_width
335340
)
336341
line[column] = data.split("\n")
342+
rendered_line.append(data)
343+
344+
if self.filter and self.filter.filter(rendered_line):
345+
return accumulator
346+
337347
accumulator.append((node.path_depth, line))
338348
return accumulator
339349

@@ -437,6 +447,7 @@ def visitor(
437447
# Nodes always have a path value, giving them a path_depth of at least 1, we use max just in case
438448
acc_map, final_tree = accumulator
439449
node_dict: Dict[str, Any] = {"__children": []}
450+
line = []
440451
for column_index in range(len(grid.columns)):
441452
column = grid.columns[column_index]
442453
renderer = self._type_renderers.get(
@@ -446,6 +457,11 @@ def visitor(
446457
if isinstance(data, interfaces.renderers.BaseAbsentValue):
447458
data = None
448459
node_dict[column.name] = data
460+
line.append(data)
461+
462+
if self.filter and self.filter.filter(line):
463+
return accumulator
464+
449465
if node.parent:
450466
acc_map[node.parent.path]["__children"].append(node_dict)
451467
else:

0 commit comments

Comments
 (0)