Exemplo n.º 1
0
Arquivo: flow.py Projeto: tkuennen/grr
    def Handle(self, args, token=None):
        if not args.client_id:
            raise ValueError("client_id must be provided")

        flow_name = args.flow.name
        if not flow_name:
            flow_name = args.flow.runner_args.flow_name
        if not flow_name:
            raise RuntimeError("Flow name is not specified.")

        # Clear all fields marked with HIDDEN, except for output_plugins - they are
        # marked HIDDEN, because we have a separate UI for them, not because they
        # shouldn't be shown to the user at all.
        #
        # TODO(user): Refactor the code to remove the HIDDEN label from
        # FlowRunnerArgs.output_plugins.
        args.flow.runner_args.ClearFieldsWithLabel(
            rdf_structs.SemanticDescriptor.Labels.HIDDEN,
            exceptions="output_plugins")

        if args.original_flow:
            args.flow.runner_args.original_flow = rdf_flows.FlowReference(
                flow_id=utils.SmartStr(args.original_flow.flow_id),
                client_id=utils.SmartStr(args.original_flow.client_id))

        flow_id = flow.GRRFlow.StartFlow(
            client_id=args.client_id.ToClientURN(),
            flow_name=flow_name,
            token=token,
            args=args.flow.args,
            runner_args=args.flow.runner_args)

        fd = aff4.FACTORY.Open(flow_id, aff4_type=flow.GRRFlow, token=token)
        return ApiFlow().InitFromAff4Object(fd, flow_id=flow_id.Basename())
Exemplo n.º 2
0
    def Run(self):
        with test_lib.FakeTime(42):
            ref = rdf_hunts.FlowLikeObjectReference(
                object_type="FLOW_REFERENCE",
                flow_reference=rdf_flows.FlowReference(
                    flow_id="F:332211", client_id="C.1111111111111111"))
            with self.CreateHunt(description="the hunt",
                                 original_object=ref) as hunt_obj:
                hunt_urn = hunt_obj.urn

                hunt_stats = hunt_obj.context.usage_stats
                hunt_stats.user_cpu_stats.sum = 5000
                hunt_stats.network_bytes_sent_stats.sum = 1000000

        self.Check(
            "GetHunt",
            args=hunt_plugin.ApiGetHuntArgs(hunt_id=hunt_urn.Basename()),
            replace={hunt_urn.Basename(): "H:123456"})
Exemplo n.º 3
0
 def FromFlowIdAndClientId(cls, flow_id, client_id):
     res = FlowLikeObjectReference()
     res.object_type = "FLOW_REFERENCE"
     res.flow_reference = flows.FlowReference(flow_id=flow_id,
                                              client_id=client_id)
     return res