Skip to content

Commit e76d512

Browse files
authored
Merge pull request volatilityfoundation#1253 from volatilityfoundation/issues/issue1252
CLI: Filter on rendered values
2 parents d238c59 + fd2c97e commit e76d512

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

volatility3/cli/text_renderer.py

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,14 @@ 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, column in enumerate(grid.columns):
184+
renderer = self._type_renderers.get(
185+
column.type, self._type_renderers["default"]
186+
)
187+
line.append(renderer(node.values[column_index]))
188+
189+
if self.filter and self.filter.filter(line):
183190
return accumulator
184191

185192
accumulator.write("\n")
@@ -188,13 +195,6 @@ def visitor(node: interfaces.renderers.TreeNode, accumulator):
188195
"*" * max(0, node.path_depth - 1)
189196
+ ("" if (node.path_depth <= 1) else " ")
190197
)
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]))
198198
accumulator.write("{}".format("\t".join(line)))
199199
accumulator.flush()
200200
return accumulator
@@ -259,12 +259,17 @@ def render(self, grid: interfaces.renderers.TreeGrid) -> None:
259259
def visitor(node: interfaces.renderers.TreeNode, accumulator):
260260
# Nodes always have a path value, giving them a path_depth of at least 1, we use max just in case
261261
row = {"TreeDepth": str(max(0, node.path_depth - 1))}
262-
for column_index in range(len(grid.columns)):
263-
column = grid.columns[column_index]
262+
line = []
263+
for column_index, column in enumerate(grid.columns):
264264
renderer = self._type_renderers.get(
265265
column.type, self._type_renderers["default"]
266266
)
267267
row[f"{column.name}"] = renderer(node.values[column_index])
268+
line.append(row[f"{column.name}"])
269+
270+
if self.filter and self.filter.filter(line):
271+
return accumulator
272+
268273
accumulator.writerow(row)
269274
return accumulator
270275

@@ -317,12 +322,9 @@ def visitor(
317322
max_column_widths.get(tree_indent_column, 0), node.path_depth
318323
)
319324

320-
if self.filter and self.filter.filter(node.values):
321-
return accumulator
322-
323325
line = {}
324-
for column_index in range(len(grid.columns)):
325-
column = grid.columns[column_index]
326+
rendered_line = []
327+
for column_index, column in enumerate(grid.columns):
326328
renderer = self._type_renderers.get(
327329
column.type, self._type_renderers["default"]
328330
)
@@ -334,6 +336,11 @@ def visitor(
334336
max_column_widths.get(column.name, len(column.name)), field_width
335337
)
336338
line[column] = data.split("\n")
339+
rendered_line.append(data)
340+
341+
if self.filter and self.filter.filter(rendered_line):
342+
return accumulator
343+
337344
accumulator.append((node.path_depth, line))
338345
return accumulator
339346

@@ -347,8 +354,7 @@ def visitor(
347354
format_string_list = [
348355
"{0:<" + str(max_column_widths.get(tree_indent_column, 0)) + "s}"
349356
]
350-
for column_index in range(len(grid.columns)):
351-
column = grid.columns[column_index]
357+
for column_index, column in enumerate(grid.columns):
352358
format_string_list.append(
353359
"{"
354360
+ str(column_index + 1)
@@ -437,15 +443,20 @@ def visitor(
437443
# Nodes always have a path value, giving them a path_depth of at least 1, we use max just in case
438444
acc_map, final_tree = accumulator
439445
node_dict: Dict[str, Any] = {"__children": []}
440-
for column_index in range(len(grid.columns)):
441-
column = grid.columns[column_index]
446+
line = []
447+
for column_index, column in enumerate(grid.columns):
442448
renderer = self._type_renderers.get(
443449
column.type, self._type_renderers["default"]
444450
)
445451
data = renderer(list(node.values)[column_index])
446452
if isinstance(data, interfaces.renderers.BaseAbsentValue):
447453
data = None
448454
node_dict[column.name] = data
455+
line.append(data)
456+
457+
if self.filter and self.filter.filter(line):
458+
return accumulator
459+
449460
if node.parent:
450461
acc_map[node.parent.path]["__children"].append(node_dict)
451462
else:

volatility3/framework/constants/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# We use the SemVer 2.0.0 versioning scheme
22
VERSION_MAJOR = 2 # Number of releases of the library with a breaking change
3-
VERSION_MINOR = 9 # Number of changes that only add to the interface
3+
VERSION_MINOR = 10 # Number of changes that only add to the interface
44
VERSION_PATCH = 0 # Number of changes that do not change the interface
55
VERSION_SUFFIX = ""
66

0 commit comments

Comments
 (0)