Automagic: Change stackers to including an exclusion list

This commit is contained in:
Mike Auty
2020-07-02 19:33:32 +01:00
committed by ikelos
parent 33d1c696e5
commit 16c2ddb837
6 changed files with 13 additions and 25 deletions
+1 -1
View File
@@ -271,7 +271,7 @@ class CommandLine(interfaces.plugins.FileConsumerInterface):
# It should be up to the UI to determine which automagics to run, so this is before BACK TO THE FRAMEWORK
automagics = automagic.choose_automagic(automagics, plugin)
ctx.config['automagic.LayerStacker.stackers'] = stacker.choose_stackers(plugin)
ctx.config['automagic.LayerStacker.stackers'] = stacker.choose_os_stackers(plugin)
self.output_dir = args.output_dir
###
+1
View File
@@ -16,6 +16,7 @@ vollog = logging.getLogger(__name__)
class LinuxIntelStacker(interfaces.automagic.StackerLayerInterface):
stack_order = 45
exclusion_list = ['mac', 'windows']
@classmethod
def stack(cls,
+1
View File
@@ -16,6 +16,7 @@ vollog = logging.getLogger(__name__)
class MacIntelStacker(interfaces.automagic.StackerLayerInterface):
stack_order = 45
exclusion_list = ['windows', 'linux']
@classmethod
def stack(cls,
+6 -24
View File
@@ -245,32 +245,14 @@ class LayerStacker(interfaces.automagic.AutomagicInterface):
]
def choose_stackers(plugin):
"""Chooses the available stackers based on the plugin"""
plugin_module_components = plugin.__module__.split('.')
oses = ['windows', 'linux', 'mac']
operating_system = 'unknown'
lowest_index = len(plugin_module_components)
for os in oses:
try:
if plugin_module_components.index(os) < lowest_index:
lowest_index = plugin_module_components.index(os)
operating_system = os
except ValueError:
# The value wasn't found, try the next one
pass
def choose_os_stackers(plugin):
"""Identifies the stackers that should be run, based on the plugin (and thus os) provided"""
plugin_first_level = plugin.__module__.split('.')[0]
result = []
for stacker in sorted(framework.class_subclasses(interfaces.automagic.StackerLayerInterface),
key = lambda x: x.stack_order):
stacker_name = stacker.__name__.lower()
append = True
if 'intel' in stacker_name:
if operating_system in oses:
if not stacker_name.startswith(operating_system):
append = False
if append:
result.append(stacker.__name__)
if plugin_first_level in stacker.exclusion_list:
continue
result.append(stacker.__name__)
return result
@@ -288,6 +288,7 @@ class WintelHelper(interfaces.automagic.AutomagicInterface):
class WindowsIntelStacker(interfaces.automagic.StackerLayerInterface):
stack_order = 40
exclusion_list = ['mac', 'linux']
@classmethod
def stack(cls,
@@ -104,6 +104,9 @@ class StackerLayerInterface(metaclass = ABCMeta):
"""
stack_order = 0
"""The order in which to attempt stacking, the lower the earlier"""
exclusion_list = []
"""The list operating systems/first-level plugin hierarchy that should exclude this stacker"""
@classmethod
def stack(self,