Improve config.json handling, making single_location optional but bypasses the stacker automagic.

This commit is contained in:
Mike Auty
2017-04-21 00:53:08 +01:00
parent b6b984503f
commit ff41d4e5b0
2 changed files with 15 additions and 11 deletions
+10 -8
View File
@@ -98,6 +98,12 @@ class CommandLine(object):
plugin = plugin_list[args.plugin]
plugin_config_path = interfaces.configuration.path_join('plugins', plugin.__name__)
# UI fills in the config, here we load it from the config file and do it before we process the CL parameters
if args.config:
with open(args.config, "r") as f:
json_val = json.load(f)
ctx.config.splice(plugin_config_path, HierarchicalDict(json_val))
# Populate the context config based on the returned args
# We have already determined these elements must be descended from ConfigurableInterface
vargs = vars(args)
@@ -113,12 +119,6 @@ class CommandLine(object):
extended_path = interfaces.configuration.path_join(config_path, requirement.name)
ctx.config[extended_path] = value
# UI fills in the config:
if args.config:
with open(args.config, "r") as f:
json_val = json.load(f)
ctx.config.splice(plugin_config_path, HierarchicalDict(json_val))
###
# BACK TO THE FRAMEWORK
###
@@ -134,8 +134,10 @@ class CommandLine(object):
constructed = plugin(ctx, plugin_config_path)
with open("config.json", "w") as f:
json.dump(dict(constructed.build_configuration()), f, sort_keys = True, indent = 2)
if args.verbosity >= 2:
vollog.debug("Writing out configuration data to config.json")
with open("config.json", "w") as f:
json.dump(dict(constructed.build_configuration()), f, sort_keys = True, indent = 2)
# Construct and run the plugin
QuickTextRenderer().render(constructed.run())
+5 -3
View File
@@ -11,8 +11,7 @@ import logging
from urllib import parse
import volatility
from volatility.framework import configuration
from volatility.framework import interfaces
from volatility.framework import configuration, interfaces
from volatility.framework.automagic import construct_layers
from volatility.framework.configuration import requirements
from volatility.framework.layers import physical
@@ -48,6 +47,9 @@ class LayerStacker(interfaces.automagic.AutomagicInterface):
vollog.info("Unable to run LayerStacker, unsatisfied requirement: {}".format(unsatisfied))
return unsatisfied
location = self.config["single_location"]
if not location:
vollog.info("Unable to run LayerStacker, single_location parameter not provided")
return []
self._check_type(location, str)
self._check_type(requirement, interfaces.configuration.RequirementInterface)
location = parse.urlparse(location)
@@ -135,4 +137,4 @@ class LayerStacker(interfaces.automagic.AutomagicInterface):
# This is not optional for the stacker to run, so optional must be marked as False
return [requirements.StringRequirement("single_location",
description = "Specifies a base location on which to stack",
optional = False)]
optional = True)]