Introduce format hints for renderers.

This commit is contained in:
Mike Auty
2017-01-05 00:39:03 +00:00
parent 3a2cc24e2a
commit 2ccc62f921
2 changed files with 15 additions and 1 deletions
@@ -0,0 +1,10 @@
"""The official list of format hints that text renderers and plugins can rely upon existing within the framework
These hints allow a plugin to indicate how they'd like a particular column's data to be represented.
Text renderers should attempt to honour all hints provided in this module where possible
"""
class Hex(int):
"""A class to indicate that the integer value should be represented as a hexidecimal value"""
+5 -1
View File
@@ -1,6 +1,7 @@
import sys
from volatility.framework import interfaces
from volatility.framework.renderers import format_hints
class TextRenderer(interfaces.renderers.Renderer):
@@ -21,7 +22,10 @@ class TextRenderer(interfaces.renderers.Renderer):
def visitor(node, accumulator):
for column in grid.columns:
accumulator.write("\t{}".format(node.values[column.index]))
text_format = "\t{}"
if column.type == format_hints.Hex:
text_format = "\t{:x}"
accumulator.write(text_format.format(node.values[column.index]))
accumulator.write("\n")
return accumulator