Beispiel #1
0
    def collect(self):
        apis = []
        for plugin_api in self.generate_api():
            apis.append(plugin_api)
            yield dict(plugin=plugin_api["plugin"],
                       api=yaml_utils.safe_dump(plugin_api),
                       raw_api=plugin_api)

        if self.plugin_args.output_file:
            with open(self.plugin_args.output_file, "wb") as fd:
                fd.write(yaml_utils.safe_dump(apis))
Beispiel #2
0
    def collect(self):
        apis = []
        for plugin_api in self.generate_api():
            apis.append(plugin_api)
            yield dict(plugin=plugin_api["plugin"],
                       api=yaml_utils.safe_dump(plugin_api),
                       raw_api=plugin_api)

        if self.plugin_args.output_file:
            with open(self.plugin_args.output_file, "wb") as fd:
                fd.write(yaml_utils.safe_dump(apis))
Beispiel #3
0
    def write_manifest(self):
        yield dict(Message="Writing manifest file.")

        # Now upload the signed manifest to the bucket. Manifest must be
        # publicly accessible.
        upload_location = self._config.server.manifest_for_server()
        yield dict(Message="Writing manifest file to %s" % (
            upload_location.to_path()))

        upload_location.write_file(self._config.signed_manifest.to_json())

        print yaml_utils.safe_dump(self._config.manifest.to_primitive())
Beispiel #4
0
    def write_manifest(self):
        yield dict(Message="Writing manifest file.")

        # Now upload the signed manifest to the bucket. Manifest must be
        # publicly accessible.
        upload_location = self._config.server.manifest_for_server()
        yield dict(Message="Writing manifest file to %s" %
                   (upload_location.to_path()))

        upload_location.write_file(self._config.signed_manifest.to_json())

        print yaml_utils.safe_dump(self._config.manifest.to_primitive())
Beispiel #5
0
    def write_config(self):
        server_config_filename = os.path.join(
            self.config_dir, self.server_config_filename)

        if os.access(server_config_filename, os.R_OK):
            yield dict(
                Message="Server config at %s exists. Remove to regenerate." % (
                    server_config_filename))

            # Load existing server config.
            server_config_data = open(server_config_filename, "rb").read()
            config = agent.Configuration.from_primitive(
                yaml.safe_load(server_config_data), session=self.session)

        else:
            # Make a new configuration
            config = agent.Configuration(session=self.session)
            self.session.SetParameter("agent_config_obj", config)

            self._build_config(config)

            yield dict(Message="Writing server config file %s" %
                       server_config_filename)

            with open(server_config_filename, "wb") as fd:
                fd.write(yaml_utils.safe_dump(config.to_primitive()))

        # The client gets just the client part of the configuration.
        client_config = agent.Configuration(session=self.session)
        client_config.client = config.client
        client_config.ca_certificate = config.ca_certificate

        client_config_filename = os.path.join(
            self.config_dir, self.client_config_filename)

        yield dict(
            Message="Writing client config file %s" % (
                client_config_filename))

        with open(client_config_filename, "wb") as fd:
            fd.write(self.client_config_warning +
                     yaml_utils.safe_dump(client_config.to_primitive()))

        # Now load the server config file to make sure it is validly written.
        self.session.SetParameter("agent_configuration", server_config_filename)
        self._config = self.session.GetParameter(
            "agent_config_obj", cached=False)

        if self._config == None:
            raise RuntimeError("Unable to parse provided configuration.")
Beispiel #6
0
    def write_config(self):
        server_config_filename = os.path.join(self.config_dir,
                                              self.server_config_filename)

        if os.access(server_config_filename, os.R_OK):
            yield dict(
                Message="Server config at %s exists. Remove to regenerate." %
                (server_config_filename))

            # Load existing server config.
            server_config_data = open(server_config_filename, "rb").read()
            config = agent.Configuration.from_primitive(
                yaml.safe_load(server_config_data), session=self.session)

        else:
            # Make a new configuration
            config = agent.Configuration(session=self.session)
            self.session.SetParameter("agent_config_obj", config)

            self._build_config(config)

            yield dict(Message="Writing server config file %s" %
                       server_config_filename)

            with open(server_config_filename, "wb") as fd:
                fd.write(yaml_utils.safe_dump(config.to_primitive()))

        # The client gets just the client part of the configuration.
        client_config = agent.Configuration(session=self.session)
        client_config.client = config.client
        client_config.ca_certificate = config.ca_certificate

        client_config_filename = os.path.join(self.config_dir,
                                              self.client_config_filename)

        yield dict(Message="Writing client config file %s" %
                   (client_config_filename))

        with open(client_config_filename, "wb") as fd:
            fd.write(self.client_config_warning +
                     yaml_utils.safe_dump(client_config.to_primitive()))

        # Now load the server config file to make sure it is validly written.
        self.session.SetParameter("agent_configuration",
                                  server_config_filename)
        self._config = self.session.GetParameter("agent_config_obj",
                                                 cached=False)

        if self._config == None:
            raise RuntimeError("Unable to parse provided configuration.")
Beispiel #7
0
    def collect(self):
        apis = []
        for option, api in six.iteritems(config.OPTIONS.args):
            for k, v in list(api.items()):
                if callable(v):
                    api[k] = v()

            apis.append(api)
            yield dict(option=option,
                       api=yaml_utils.safe_dump(api),
                       raw_api=api)

        if self.plugin_args.output_file:
            with open(self.plugin_args.output_file, "wb") as fd:
                fd.write(yaml_utils.safe_dump(apis))
Beispiel #8
0
    def collect(self):
        apis = []
        for option, api in config.OPTIONS.args.items():
            for k, v in api.items():
                if callable(v):
                    api[k] = v()

            apis.append(api)
            yield dict(option=option,
                       api=yaml_utils.safe_dump(api),
                       raw_api=api)

        if self.plugin_args.output_file:
            with open(self.plugin_args.output_file, "wb") as fd:
                fd.write(yaml_utils.safe_dump(apis))
 def collect(self):
     artifact_profile = self.session.LoadProfile("artifacts")
     for artifact in self.plugin_args.artifacts:
         definition = artifact_profile.definitions_by_name.get(artifact)
         if definition:
             yield dict(divider=artifact)
             yield dict(Message=yaml_utils.safe_dump(definition))
Beispiel #10
0
 def collect(self):
     artifact_profile = self.session.LoadProfile("artifacts")
     for artifact in self.plugin_args.artifacts:
         definition = artifact_profile.definitions_by_name.get(artifact)
         if definition:
             yield dict(divider=artifact)
             yield dict(Message=yaml_utils.safe_dump(definition))
Beispiel #11
0
def CreateDefaultConfigFile(session):
    """Creates a default config file."""
    homedir = GetHomeDir(session)
    if homedir:
        try:
            filename = "%s/.rekallrc" % homedir
            with open(filename, "wt") as fd:
                fd.write(yaml_utils.safe_dump(DEFAULT_CONFIGURATION))

            logging.info("Created new configuration file %s", filename)
            cache_dir = os.path.join(
                homedir, DEFAULT_CONFIGURATION["cache_dir"])

            os.makedirs(cache_dir)
            logging.info("Created new cache directory %s", cache_dir)

            return DEFAULT_CONFIGURATION
        except (IOError, OSError):
            pass

    # Can not write it anywhere but at least we start with something sensible.
    return DEFAULT_CONFIGURATION