コード例 #1
0
ファイル: post_scan.py プロジェクト: SmartsYoung/FenixscanX
#  ScanEngine is a free software code scanning tool from nexB Inc. and others.
#  Visit https://github.com/nexB/scanengine-toolkit/ for support and download.

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
コード例 #2
0
logger = logging.getLogger(__name__)

# uncomment to enable logging locally
# logging.basicConfig(stream=sys.stdout)
# logger.setLevel(logging.DEBUG)


def logger_debug(*args):
    return logger.debug(' '.join(isinstance(a, string_types) and a or repr(a) for a in args))


project_name = __name__
entrypoint = 'scanengine_location_provider'

location_provider_spec = HookspecMarker(project_name=project_name)
location_provider_impl = HookimplMarker(project_name=project_name)


@location_provider_spec
class LocationProviderPlugin(object):
    """
    Base plugin class for plugins that provide path locations for one or more
    keys such as the path location to a native binary executable or related
    system files.
    A plugin is configured as it own package with proper environemnt markers
    """

    # name string under which this plugin is registered.
    # This is set automatically when a plugin class is loaded in its manager.
    # Subclasses must not set this.
    name = None
コード例 #3
0
    import sys

    logger = logging.getLogger(__name__)
    logging.basicConfig(stream=sys.stdout)
    logger.setLevel(logging.DEBUG)

    def logger_debug(*args):
        return logger.debug(' '.join(
            isinstance(a, unicode) and a or repr(a) for a in args))


stage = 'output'
entrypoint = 'scancode_output'

output_spec = HookspecMarker(project_name=stage)
output_impl = HookimplMarker(project_name=stage)


@output_spec
class OutputPlugin(CodebasePlugin):
    """
    Base plugin class for scan output formatters all output plugins must extend.
    """
    def process_codebase(self, codebase, output, **kwargs):
        """
        Write `codebase` to the `output` file-like object (which could be a
        sys.stdout or a StringIO).

        Note: each subclass is using a differnt arg name for `output`
        """
        raise NotImplementedError
コード例 #4
0
#  ScanCode is a free software code scanning tool from nexB Inc. and others.
#  Visit https://github.com/nexB/scancode-toolkit/ for support and download.

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 = 'scan'
entrypoint = 'scancode_scan'

scan_spec = HookspecMarker(stage)
scan_impl = HookimplMarker(stage)


@scan_spec
class ScanPlugin(CodebasePlugin):
    """
    A scan plugin base class that all scan plugins must extend. A scan plugin
    provides a  `get_scanner()` method that returns a scanner function. This
    function must return an ordered mapping of attributes that will be attached
    to the resource. If a mapping key starts with "extra_data." the key value
    will be added instead ot the Resource.extra_data mapping.

    In addition to the get_scanner() method, a ScanPlugin is also a
    CodebasePlugin that can implement its own process_codebase() method. This
    method will be called after all the scans are completed and before the next
    stage (post-scans) plugins are called.