Beispiel #1
0
from __future__ import absolute_import
from __future__ import unicode_literals

from plugincode import CodebasePlugin
from plugincode import PluginManager
from plugincode import HookimplMarker
from plugincode import HookspecMarker

stage = 'post_scan'
entrypoint = 'scanengine_post_scan'

post_scan_spec = HookspecMarker(project_name=stage)
post_scan_impl = HookimplMarker(project_name=stage)


@post_scan_spec
class PostScanPlugin(CodebasePlugin):
    """
    A post-scan plugin base class that all post-scan plugins must extend.
    """
    pass


post_scan_plugins = PluginManager(
    stage=stage,
    module_qname=__name__,
    entrypoint=entrypoint,
    plugin_base_class=PostScanPlugin
)
Beispiel #2
0
        sys.stdout or a StringIO).

        Note: each subclass is using a differnt arg name for `output`
        """
        raise NotImplementedError

    @classmethod
    def get_files(cls, codebase, **kwargs):
        """
        Return an iterable of serialized files mapping from a codebase.
        Include "info", "timing" and strip root as needed.
        """
        # FIXME: serialization SHOULD NOT be needed: only some format need it
        # (e.g. JSON) and only these should serialize
        timing = kwargs.get('timing', False)
        info = bool(
            kwargs.get('info') or getattr(codebase, 'with_info', False))
        serializer = partial(Resource.to_dict,
                             with_info=info,
                             with_timing=timing)

        strip_root = kwargs.get('strip_root', False)
        resources = codebase.walk_filtered(topdown=True, skip_root=strip_root)
        return imap(serializer, resources)


output_plugins = PluginManager(stage=stage,
                               module_qname=__name__,
                               entrypoint=entrypoint,
                               plugin_base_class=OutputPlugin)