Beispiel #1
0
def _remove_unload_instances(name):
    """Helper cleanup function for when skills are unloaded."""
    # Does the skill have anything that should be auto unloaded?
    if name in AutoUnload._module_instances:
        # Call the PluginManager's method, so they get correctly removed
        PluginManager._unload_auto_unload_instances(AutoUnload._module_instances[name])
        # Remove the skill from the PluginManager
        del AutoUnload._module_instances[name]

    # Does the skill have anything that should be auto unloaded?
    if name in WeakAutoUnload._module_instances:
        # Call the PluginManager's method, so they get correctly removed
        PluginManager._unload_auto_unload_instances(WeakAutoUnload._module_instances[name].values())
        # Remove the skill from the PluginManager
        del WeakAutoUnload._module_instances[name]
Beispiel #2
0
    def __init__(self, args):
        self._original_excepthook = sys.excepthook

        self.args = args

        self._mappers_manager = MapperManager()

        self._model_controller = ModelController(self._mappers_manager)

        self._plugin_manager = PluginManager(
            os.path.join(CONF.getConfigPath(), "plugins"))

        self._workspace_manager = WorkspaceManager(self._mappers_manager)

        # Create a PluginController and send this to UI selected.
        self._plugin_controller = PluginController('PluginController',
                                                   self._plugin_manager,
                                                   self._mappers_manager)

        if self.args.cli:
            self.app = CliApp(self._workspace_manager, self._plugin_controller)
            CONF.setMergeStrategy("new")
        else:
            self.app = UiFactory.create(self._model_controller,
                                        self._plugin_manager,
                                        self._workspace_manager,
                                        self._plugin_controller, self.args.gui)

        self.timer = TimerClass()
        self.timer.start()
    def __init__(self):

        super(RawReportProcessor, self).__init__()
        from faraday import setupPlugins
        setupPlugins()

        self.pending_actions = Queue()

        try:
            plugin_manager = PluginManager(
                os.path.join(CONF.getConfigPath(), "plugins"))
        except AttributeError:
            get_logger().warning(
                "Upload reports in WEB-UI not configurated, run Faraday client and try again..."
            )
            self._stop = True
            return

        mappers_manager = MapperManager()

        self.model_controller = ModelController(mappers_manager,
                                                self.pending_actions)
        self.model_controller.start()
        self.end_event = Event()

        plugin_controller = PluginController('PluginController',
                                             plugin_manager, mappers_manager,
                                             self.pending_actions,
                                             self.end_event)

        self.processor = ReportProcessor(plugin_controller, None)
        self._stop = False
 def _is_related_module(base_name, module):
     """Check if a plugin's base name is related to a module name."""
     if module.split('.')[~0] in (
         'commands', 'configuration', 'custom_events', 'info', 'models',
         'rules', 'settings',
     ):
         return False
     return PluginManager._is_related_module(base_name, module)
Beispiel #5
0
    def __init__(self, args):
        self._original_excepthook = sys.excepthook

        self.args = args

        logger = getLogger(self)
        if args.creds_file:
            try:
                with open(args.creds_file, 'r') as fp:
                    creds = json.loads(fp.read())
                    username = creds.get('username')
                    password = creds.get('password')
                    session_cookie = login_user(CONF.getServerURI(), username,
                                                password)
                    if session_cookie:
                        logger.info('Login successful')
                        CONF.setDBUser(username)
                        CONF.setDBSessionCookies(session_cookie)
                    else:
                        logger.error('Login failed')
            except (IOError, ValueError):
                logger.error("Credentials file couldn't be loaded")

        self._mappers_manager = MapperManager()
        pending_actions = Queue()
        self._model_controller = ModelController(self._mappers_manager,
                                                 pending_actions)

        self._plugin_manager = PluginManager(
            os.path.join(CONF.getConfigPath(), "plugins"),
            pending_actions=pending_actions,
        )

        self._workspace_manager = WorkspaceManager(self._mappers_manager)

        # Create a PluginController and send this to UI selected.
        self._plugin_controller = PluginController('PluginController',
                                                   self._plugin_manager,
                                                   self._mappers_manager,
                                                   pending_actions)

        if self.args.cli:

            self.app = CliApp(self._workspace_manager, self._plugin_controller)

            if self.args.keep_old:
                CONF.setMergeStrategy("old")
            else:
                CONF.setMergeStrategy("new")

        else:
            self.app = UiFactory.create(self._model_controller,
                                        self._plugin_manager,
                                        self._workspace_manager,
                                        self._plugin_controller, self.args.gui)

        self.timer = TimerClass()
        self.timer.start()
Beispiel #6
0
def import_external_reports(workspace_name=None, disable_polling=False):
    plugins_path = os.path.join(CONF.getConfigPath(), "plugins")
    plugin_manager = PluginManager(plugins_path)
    mappers_manager = MapperManager()

    if workspace_name:
        query = Workspace.query.filter_by(name=workspace_name)
    else:
        query = Workspace.query

    process_workspaces(mappers_manager, plugin_manager, query, disable_polling)
Beispiel #7
0
 def _is_related_module(base_name, module):
     """Check if a plugin's base name is related to a module name."""
     if module.split(".")[~0] in ("commands", "configuration", "custom_events", "info", "rules", "settings"):
         return False
     return PluginManager._is_related_module(base_name, module)