mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-13 21:27:39 +02:00
Initial attempt at the UI side of data renderers
This commit is contained in:
@@ -9,7 +9,7 @@ import random
|
||||
import string
|
||||
import sys
|
||||
from functools import wraps
|
||||
from typing import Any, Callable, Dict, List, Tuple, TypeVar, Union
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union
|
||||
from volatility3.cli import text_filter
|
||||
|
||||
from volatility3.framework import exceptions, interfaces, renderers
|
||||
@@ -149,12 +149,18 @@ class CLITypeRenderer(interfaces.renderers.TypeRendererInterface):
|
||||
class LayerDataRenderer(CLITypeRenderer):
|
||||
"""Renders a LayerData object into data/bytes"""
|
||||
|
||||
def __init__(self):
|
||||
self.context_byte_len = 0
|
||||
self.width = 16
|
||||
self.display_offset = False
|
||||
self.display_hex = True
|
||||
self.display_ascii = True
|
||||
def __init__(
|
||||
self,
|
||||
render_func: Optional[Callable] = None,
|
||||
options: Optional[dict[str, Any]] = None,
|
||||
):
|
||||
if options is None:
|
||||
options = {}
|
||||
self.context_byte_len = options.get("context_byte_len", 0)
|
||||
self.width = options.get("width", 16)
|
||||
self.display_offset = options.get("display_offset", False)
|
||||
self.display_hex = options.get("display_hex", True)
|
||||
self.display_ascii = options.get("display_ascii", True)
|
||||
|
||||
def render(data: Union[renderers.LayerData, BaseAbsentValue]):
|
||||
if isinstance(data, BaseAbsentValue):
|
||||
|
||||
@@ -51,6 +51,7 @@ class Column(NamedTuple):
|
||||
|
||||
|
||||
RenderOption = Any
|
||||
"""RenderOption is intentionally unrestricted to allow UIs to define whatever format they wish"""
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
@@ -64,6 +65,11 @@ class TypeRendererInterface:
|
||||
self._options = options or {}
|
||||
setattr(self, "render", func)
|
||||
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def get_render_options(cls) -> List[RenderOption]:
|
||||
"""Opaque method for TypeRenders to ask for options"""
|
||||
|
||||
@property
|
||||
def options(self):
|
||||
return self._options
|
||||
@@ -87,8 +93,9 @@ class Renderer(metaclass=ABCMeta):
|
||||
"""Accepts an options object to configure the renderers."""
|
||||
# FIXME: Once the config option objects are in place, put the _type_check in place
|
||||
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def get_render_options(self) -> List[RenderOption]:
|
||||
def get_render_options(cls) -> List[RenderOption]:
|
||||
"""Returns a list of rendering options."""
|
||||
|
||||
@abstractmethod
|
||||
|
||||
Reference in New Issue
Block a user