Ejemplo n.º 1
0
    def Handle(self, args, token=None):
        flow_urn = args.flow_id.ResolveClientFlowURN(args.client_id,
                                                     token=token)
        flow_obj = aff4.FACTORY.Open(flow_urn,
                                     aff4_type=flow.GRRFlow,
                                     mode="r",
                                     token=token)

        output_plugins_states = flow_obj.GetRunner(
        ).context.output_plugins_states

        type_indices = {}
        result = []
        for output_plugin_state in output_plugins_states:
            plugin_descriptor = output_plugin_state.plugin_descriptor
            plugin_state = output_plugin_state.plugin_state
            type_index = type_indices.setdefault(plugin_descriptor.plugin_name,
                                                 0)
            type_indices[plugin_descriptor.plugin_name] += 1

            # Output plugins states are stored differently for hunts and for flows:
            # as a dictionary for hunts and as a simple list for flows.
            #
            # TODO(user): store output plugins states in the same way for flows
            # and hunts. Until this is done, we can emulate the same interface in
            # the HTTP API.
            api_plugin = api_output_plugin.ApiOutputPlugin(
                id=plugin_descriptor.plugin_name + "_%d" % type_index,
                plugin_descriptor=plugin_descriptor,
                state=plugin_state)
            result.append(api_plugin)

        return ApiListFlowOutputPluginsResult(items=result)
Ejemplo n.º 2
0
  def Handle(self, args, token=None):
    metadata = aff4.FACTORY.Create(
        args.hunt_id.ToURN().Add("ResultsMetadata"),
        mode="r",
        aff4_type=implementation.HuntResultsMetadata,
        token=token)

    plugins = metadata.Get(metadata.Schema.OUTPUT_PLUGINS, {})

    result = []
    for plugin_name, (plugin_descriptor, plugin_state) in plugins.items():
      api_plugin = api_output_plugin.ApiOutputPlugin(
          id=plugin_name,
          plugin_descriptor=plugin_descriptor,
          state=plugin_state)
      result.append(api_plugin)

    return ApiListHuntOutputPluginsResult(items=result, total_count=len(result))