Exemple #1
0
def CreateHunt(flow_name=None,
               flow_args=None,
               hunt_runner_args=None,
               context=None):
    """Creates a new hunt.

  Args:
    flow_name: String with a name of a flow that will run on all the clients
        in the hunt.
    flow_args: Flow arguments to be used. A proto, that depends on a flow.
    hunt_runner_args: flows_pb2.HuntRunnerArgs instance. Used to specify
        description, client_rule_set, output_plugins and other useful
        hunt attributes.
    context: API context.

  Raises:
    ValueError: if flow_name is empty.

  Returns:
    Hunt object corresponding to the created hunt.
  """
    if not flow_name:
        raise ValueError("flow_name can't be empty")

    request = hunt_pb2.ApiCreateHuntArgs(flow_name=flow_name)
    if flow_args:
        request.flow_args.value = flow_args.SerializeToString()
        request.flow_args.type_url = utils.GetTypeUrl(flow_args)

    if hunt_runner_args:
        request.hunt_runner_args.CopyFrom(hunt_runner_args)

    data = context.SendRequest("CreateHunt", request)
    return Hunt(data=data, context=context)
Exemple #2
0
    def CreateFlow(self, name=None, args=None, runner_args=None):
        """Create new flow on this client."""

        if not name:
            raise ValueError("name can't be empty")

        request = flow_pb2.ApiCreateFlowArgs(client_id=self.client_id)

        request.flow.name = name
        if runner_args:
            request.flow.runner_args.CopyFrom(runner_args)

        if args:
            request.flow.args.value = args.SerializeToString()
            request.flow.args.type_url = utils.GetTypeUrl(args)

        data = self._context.SendRequest("CreateFlow", request)
        return flow.Flow(data=data, context=self._context)