Beispiel #1
0
    def GenerateTests(self, config, flags):
        """Generates test classes for all the plugins.

        Each plugin must have at least one test. Plugin tests are subclasses of
        the testlib.RekallBaseUnitTestCase class,
        """
        result = self.GenerateInlineTests(config)

        # Pull the profile path etc from the rekall config file.
        kwargs = rekall_config.GetConfigFile(session.Session())

        # Get the disabled tests.
        disabled = config.pop("disabled", [])

        for x, y in flags.items():
            if x.startswith("--"):
                kwargs[x[2:]] = y

        s = session.InteractiveSession(**kwargs)

        # A map of all the specialized tests which are defined. Only include
        # those classes which are active for the currently selected profile.
        plugins_with_test = set()
        for _, cls in testlib.RekallBaseUnitTestCase.classes.items():
            if cls.is_active(s):
                result.append(cls)

                plugin_name = cls.CommandName()
                if plugin_name:
                    plugins_with_test.add(plugin_name)

        # Now generate tests automatically for all other plugins.
        for cls in plugin.Command.classes.values():
            if cls.name in plugins_with_test:
                continue

            # We can not test interactive plugins in this way.
            if cls.interactive:
                continue

            # Remove classes which are not active.
            if not cls.is_active(s):
                continue

            # Automatically create a new test based on testlib.SimpleTestCase.
            try:
                result.append(type(
                    "Test%s" % cls.__name__, (testlib.SimpleTestCase,),
                    dict(PARAMETERS=dict(commandline=cls.name))))
            except RuntimeError:
                pass

        # Remove the disabled tests.
        return [x for x in result if x.__name__ not in disabled]
Beispiel #2
0
    def GenerateTests(self, config):
        """Generates test classes for all the plugins.

        Each plugin must have at least one test. Plugin tests are subclasses of
        the testlib.RekallBaseUnitTestCase class,
        """
        result = []

        # Pull the profile path etc from the rekall config file.
        kwargs = rekall_config.GetConfigFile()
        for x, y in config.items():
            if x.startswith("--"):
                kwargs[x[2:]] = y

        s = session.Session(**kwargs)

        # A map of all the specialized tests which are defined. Only include
        # those classes which are active for the currently selected profile.
        plugins_with_test = set()
        for _, cls in testlib.RekallBaseUnitTestCase.classes.items():
            if cls.is_active(s):
                plugin_name = cls.PARAMETERS.get("commandline", "").split()
                if plugin_name:
                    plugins_with_test.add(plugin_name[0])
                    result.append(cls)

        # Now generate tests automatically for all other plugins.
        for cls in plugin.Command.classes.values():
            if cls.name in plugins_with_test:
                continue

            # We can not test interactive plugins in this way.
            if cls.interactive:
                continue

            # Remove classes which are not active.
            if not cls.is_active(s):
                continue

            # Automatically create a new test based on testlib.SimpleTestCase.
            result.append(type(
                    "Test%s" % cls.__name__, (testlib.SimpleTestCase,),
                    dict(PARAMETERS=dict(commandline=cls.name))))

        return result
Beispiel #3
0
def NotebookSupport(_):

    # The following only reveals hidden imports to pyinstaller.
    if False:
        # pylint: disable=unused-variable
        import IPython.html.auth.login
        import IPython.html.auth.logout
        import IPython.html.base.handlers
        import IPython.html.nbconvert.handlers
        import IPython.html.notebook.handlers
        import IPython.html.notebookapp
        import IPython.html.services.clusters.handlers
        import IPython.html.services.kernels.handlers
        import IPython.html.services.nbconvert.handlers
        import IPython.html.services.notebooks.handlers
        import IPython.html.services.sessions.handlers
        import IPython.html.tree.handlers
        import IPython.kernel.ioloop
        import IPython.kernel.zmq.kernelapp

        import rekall.interactive

        import zmq.backend.cython
        import zmq.eventloop.ioloop

    argv = ["notebook", "-c",
            "from rekall import interactive; "
            "interactive.ImportEnvironment();", "--autocall", "2",
            "--notebook-dir",
            config.GetConfigFile().get("notebook_dir",
                                       config.GetHomeDir())
            ]

    import IPython

    IPython.start_ipython(argv=argv)
    return True