From 90641befd236f5682bb6f87d5aa8ea504361261f Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Thu, 12 Apr 2018 15:43:02 +0100 Subject: [PATCH] Remove the TZ*Values and rely on datetime.datetime directly. --- volatility/framework/interfaces/renderers.py | 14 +++----------- volatility/framework/renderers/__init__.py | 15 +++------------ 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/volatility/framework/interfaces/renderers.py b/volatility/framework/interfaces/renderers.py index b1486abf3..810f351b6 100644 --- a/volatility/framework/interfaces/renderers.py +++ b/volatility/framework/interfaces/renderers.py @@ -2,11 +2,12 @@ or in some other form. This module defines both the output format (:class:`TreeGrid`) and the renderer interface which can interact with a TreeGrid to produce suitable output.""" -import collections import datetime import typing from abc import abstractmethod, ABCMeta +import collections + from volatility.framework import validity Column = collections.namedtuple('Column', ['index', 'name', 'type']) @@ -81,22 +82,13 @@ class BaseAbsentValue(object): # We don't class these off a shared base, because the SimpleTypes must only # contain the types that the validator will accept (which would not include the base) -class TZAwareValue(datetime.datetime): - """Class for TZ-aware datetimes""" - - -class TZNaiveValue(datetime.datetime): - """Class for TZ-aware datetimes""" - - _Type = typing.TypeVar("_Type") ColumnsType = typing.List[typing.Tuple[str, typing.Type]] SimpleTypes = typing.Union[typing.Type[int], typing.Type[str], typing.Type[float], typing.Type[bytes], - typing.Type[TZAwareValue], - typing.Type[TZNaiveValue], + typing.Type[datetime.datetime], typing.Type[BaseAbsentValue]] VisitorSignature = typing.Callable[[TreeNode, _Type], _Type] diff --git a/volatility/framework/renderers/__init__.py b/volatility/framework/renderers/__init__.py index 78cdd2b03..4a10d4985 100644 --- a/volatility/framework/renderers/__init__.py +++ b/volatility/framework/renderers/__init__.py @@ -61,18 +61,9 @@ class TreeNode(interfaces.renderers.TreeNode): column.name, type(val), column.type)) - if isinstance(val, (interfaces.renderers.TZAwareValue, interfaces.renderers.TZNaiveValue)): - tznaive = val.tzinfo is None or val.tzinfo.utcoffset(val) is None - if isinstance(val, interfaces.renderers.TZAwareValue) and tznaive: - raise TypeError( - "Values item with index {} is not a timezone aware datetime object as required by column {}".format( - index, - column.name)) - elif isinstance(val, interfaces.renderers.TZNaiveValue) and not tznaive: - raise TypeError( - "Values item with index {} is not a timezone naive datetime object as required by column {}".format( - index, - column.name)) + # TODO: Consider how to deal with timezone naive/aware datetimes (and alert plugin uses to be precise) + # if isinstance(val, datetime.datetime): + # tznaive = val.tzinfo is None or val.tzinfo.utcoffset(val) is None @property def values(self) -> typing.Iterable[interfaces.renderers.SimpleTypes]: