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)
def Render(self, args, token=None): flow_urn = args.client_id.Add("flows").Add(args.flow_id.Basename()) flow_obj = aff4.FACTORY.Open(flow_urn, aff4_type="GRRFlow", mode="r", token=token) output_plugins_states = flow_obj.GetRunner( ).context.output_plugins_states type_indices = {} result = [] for plugin_descriptor, plugin_state in output_plugins_states: 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 dict(offset=0, count=len(result), total_count=len(result), items=api_value_renderers.RenderValue(result))
def Render(self, args, token=None): metadata = aff4.FACTORY.Create( HUNTS_ROOT_PATH.Add(args.hunt_id).Add("ResultsMetadata"), mode="r", aff4_type="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 dict(offset=0, count=len(result), total_count=len(result), items=api_value_renderers.RenderValue(result))
def Handle(self, args, token=None): metadata = aff4.FACTORY.Create( HUNTS_ROOT_PATH.Add(args.hunt_id).Add("ResultsMetadata"), mode="r", aff4_type="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))