mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-07 02:07:39 +02:00
Correct issues with imports and pylint a little.
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import argparse
|
||||
|
||||
from volatility.cli import argparse_adapter
|
||||
|
||||
__author__ = 'mike'
|
||||
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from volatility.cli import argparse_adapter
|
||||
import volatility.framework
|
||||
import volatility.plugins
|
||||
from volatility.framework import plugins, configuration, contexts
|
||||
from volatility.framework import interfaces, plugins, configuration, contexts
|
||||
|
||||
__author__ = 'mike'
|
||||
|
||||
logging.basicConfig(filename = 'example.log', level = logging.DEBUG)
|
||||
logger = logging.getLogger("volatility")
|
||||
@@ -66,7 +64,7 @@ class CommandLine(object):
|
||||
context.config.add_item(req, plugin.__name__)
|
||||
if isinstance(req, configuration.TranslationLayerRequirement):
|
||||
# Choose an appropriate LayerFactory (add layer to the req.name so we don't blat the requirement itself
|
||||
namespace = configuration.namespace_join([plugin.__name__, req.name + "_layer"])
|
||||
namespace = interfaces.configuration.namespace_join([plugin.__name__, req.name + "_layer"])
|
||||
factory = self.construct_translation_layer_factory(namespace, req)
|
||||
for facreq in factory.requirements():
|
||||
context.config.add_item(facreq, namespace = namespace)
|
||||
|
||||
@@ -3,27 +3,29 @@ Created on 7 May 2013
|
||||
|
||||
@author: mike
|
||||
"""
|
||||
import re
|
||||
|
||||
from volatility.framework.interfaces.configuration import GenericRequirement, ConfigurationGroup
|
||||
from volatility.framework.interfaces.configuration import GenericRequirement
|
||||
|
||||
|
||||
# Intentionally reimport namespace_join so it's accessible from the main config module
|
||||
from volatility.framework.interfaces.configuration import namespace_join
|
||||
|
||||
class InstanceRequirement(GenericRequirement):
|
||||
instance_type = bool
|
||||
|
||||
def validate_input(self, value, context):
|
||||
if not isinstance(value, self.instance_type):
|
||||
raise TypeError(self.name + " input only accepts " + self.instance_type.__name__+ " type")
|
||||
raise TypeError(self.name + " input only accepts " + self.instance_type.__name__ + " type")
|
||||
|
||||
|
||||
class IntRequirement(InstanceRequirement):
|
||||
instance_type = int
|
||||
|
||||
|
||||
class StringRequirement(InstanceRequirement):
|
||||
#TODO: Maybe add string length limits?
|
||||
# TODO: Maybe add string length limits?
|
||||
instance_type = str
|
||||
|
||||
|
||||
class TranslationLayerRequirement(GenericRequirement):
|
||||
"""Class maintaining the limitations on what sort of address spaces are acceptable"""
|
||||
|
||||
@@ -38,12 +40,13 @@ class TranslationLayerRequirement(GenericRequirement):
|
||||
def validate_input(self, value, context):
|
||||
"""Validate that the value is a valid layer name and that the layer adheres to the requirements"""
|
||||
if value not in context.memory:
|
||||
raise IndexError(value + " is not memory layer")
|
||||
raise IndexError((value or "") + " is not a memory layer")
|
||||
|
||||
|
||||
class ChoiceRequirement(GenericRequirement):
|
||||
"""Allows one from a choice of strings
|
||||
"""
|
||||
|
||||
def __init__(self, choices, *args, **kwargs):
|
||||
GenericRequirement.__init__(self, *args, **kwargs)
|
||||
if not isinstance(choices, list) or any([not isinstance(choice, str) for choice in choices]):
|
||||
@@ -55,6 +58,7 @@ class ChoiceRequirement(GenericRequirement):
|
||||
if value not in self._choices:
|
||||
raise ValueError("Value is not within the set of available choices")
|
||||
|
||||
|
||||
class ListRequirement(GenericRequirement):
|
||||
def __init__(self, min_elements, max_elements, element_type, *args, **kwargs):
|
||||
GenericRequirement.__init__(self, *args, **kwargs)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from volatility.framework import validity, interfaces, symbols, layers, configuration
|
||||
from volatility.framework import validity, interfaces, symbols, layers
|
||||
from volatility.framework.interfaces.context import ContextModifierInterface
|
||||
from volatility.framework.symbols import native
|
||||
import volatility
|
||||
@@ -39,7 +39,7 @@ class LayerFactory(validity.ValidityRoutines, list):
|
||||
groups = []
|
||||
for index in range(len(self)):
|
||||
modifier = self[index]
|
||||
group = configuration.ConfigurationGroup(modifier.__name__ + str(index))
|
||||
group = interfaces.configuration.ConfigurationGroup(modifier.__name__ + str(index))
|
||||
for req in modifier.requirements():
|
||||
group.add_item(req)
|
||||
groups.append(group)
|
||||
@@ -52,7 +52,7 @@ class LayerFactory(validity.ValidityRoutines, list):
|
||||
"""
|
||||
for index in range(len(self)):
|
||||
print("TODO: update top level req based on modifier reqs being updated")
|
||||
modifier = self[index](configuration.namespace_join([self.name, self[index].__name__ + str(index)]))
|
||||
modifier = self[index](interfaces.configuration.namespace_join([self.name, self[index].__name__ + str(index)]))
|
||||
modifier(context = context)
|
||||
return context
|
||||
|
||||
@@ -77,7 +77,7 @@ class Context(interfaces.context.ContextInterface):
|
||||
interfaces.context.ContextInterface.__init__(self)
|
||||
self._symbol_space = symbols.SymbolSpace(natives)
|
||||
self._memory = layers.Memory()
|
||||
self._config = configuration.ConfigurationGroup(name = 'volatility')
|
||||
self._config = interfaces.configuration.ConfigurationGroup(name = 'volatility')
|
||||
|
||||
# ## Symbol Space Functions
|
||||
|
||||
@@ -88,7 +88,7 @@ class Context(interfaces.context.ContextInterface):
|
||||
|
||||
@config.setter
|
||||
def config(self, value):
|
||||
if not isinstance(value, configuration.ConfigurationGroup):
|
||||
if not isinstance(value, interfaces.configuration.ConfigurationGroup):
|
||||
raise TypeError("Configuration must of type ConfigurationGroup")
|
||||
self._config = value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user