Ejemplo n.º 1
0
    async def load_plugins(self):
        """
        Store all plugins in the data store
        :return:
        """
        for plug in os.listdir('plugins'):
            if plug.startswith('.'):
                continue
            if not os.path.isdir('plugins/%s' % plug) or not os.path.isfile(
                    'plugins/%s/hook.py' % plug):
                self.log.error(
                    'Problem locating the "%s" plugin. Ensure CALDERA was cloned recursively.'
                    % plug)
                exit(0)
            plugin = Plugin(name=plug)
            if await plugin.load():
                await self.get_service('data_svc').store(plugin)
                if plugin.name in self.config['plugins']:
                    plugin.enabled = True
        for plugin in self.config['plugins']:
            plug = await self._services.get('data_svc').locate(
                'plugins', match=dict(name=plugin))
            [await p.enable(self.get_services()) for p in plug]
            self.log.debug('Enabling %s plugin' % plugin)

        templates = [
            'plugins/%s/templates' % p.name.lower()
            for p in await self.get_service('data_svc').locate('plugins')
        ]
        templates.append('templates')
        aiohttp_jinja2.setup(self.application,
                             loader=jinja2.FileSystemLoader(templates))
Ejemplo n.º 2
0
    async def load_plugins(self):
        """
        Store all plugins in the data store
        :return:
        """
        for plug in os.listdir('plugins'):
            if not os.path.isdir('plugins/%s' % plug) or not os.path.isfile(
                    'plugins/%s/hook.py' % plug):
                self.log.error(
                    'Problem validating the "%s" plugin. Ensure CALDERA was cloned recursively.'
                    % plug)
                exit(0)
            self.log.debug('Loading plugin: %s' % plug)
            plugin = Plugin(name=plug)
            await self.get_service('data_svc').store(plugin)
            if plugin.name in self.config['enabled_plugins']:
                plugin.enabled = True
        for plug in await self._services.get('data_svc').locate('plugins'):
            if plug.name in self.config['enabled_plugins'] or plug.enabled:
                await plug.enable(self.get_services())

        templates = [
            'plugins/%s/templates' % p.name.lower()
            for p in await self.get_service('data_svc').locate('plugins')
        ]
        aiohttp_jinja2.setup(self.application,
                             loader=jinja2.FileSystemLoader(templates))
Ejemplo n.º 3
0
    async def load_plugins(self, enabled):
        """
        Store all plugins in the data store
        :param enabled: a list of all plugins to enable right away
        :return:
        """
        for plug in os.listdir('plugins'):
            if not os.path.isdir('plugins/%s' % plug) or not os.path.isfile(
                    'plugins/%s/hook.py' % plug):
                self.log.error(
                    'Problem validating the "%s" plugin. Ensure CALDERA was cloned recursively.'
                    % plug)
                exit(0)
            self.log.debug('Loading plugin: %s' % plug)
            if os.path.isfile('plugins/%s/requirements.txt' % plug):
                self.log.warning(
                    'Ensure you have installed the PIP requirements for plugin=%s'
                    % plug)
            plugin = Plugin(name=plug)
            await self.get_service('data_svc').store(plugin)
            if plugin.name in enabled:
                plugin.enabled = True
        for plug in await self._services.get('data_svc').locate(
                'plugins', match=dict(enabled=True)):
            await plug.enable(self.application, self.get_services())

        templates = [
            'plugins/%s/templates' % p.name.lower()
            for p in await self.get_service('data_svc').locate('plugins')
        ]
        aiohttp_jinja2.setup(self.application,
                             loader=jinja2.FileSystemLoader(templates))