Пример #1
0
    def Run(self):
        with test_lib.FakeTime(42):
            with self.CreateHunt(description="the hunt") as hunt_obj:

                with test_lib.FakeTime(52):
                    hunt_obj.LogClientError(
                        rdf_client.ClientURN("C.0000111122223333"),
                        "Error foo.")

                with test_lib.FakeTime(55):
                    hunt_obj.LogClientError(
                        rdf_client.ClientURN("C.1111222233334444"),
                        "Error bar.", "<some backtrace>")

        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(
                       hunt_id=hunt_obj.urn.Basename()),
                   replace={hunt_obj.urn.Basename(): "H:123456"})
        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(
                       hunt_id=hunt_obj.urn.Basename(), count=1),
                   replace={hunt_obj.urn.Basename(): "H:123456"})
        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(
                       hunt_id=hunt_obj.urn.Basename(), offset=1, count=1),
                   replace={hunt_obj.urn.Basename(): "H:123456"})
Пример #2
0
    def Run(self):
        client_id_1 = self.SetupClient(0)
        client_id_2 = self.SetupClient(1)

        with test_lib.FakeTime(42):
            hunt_id = self.CreateHunt(description="the hunt",
                                      creator=self.test_username)

        with test_lib.FakeTime(52):
            flow_id = flow_test_lib.StartFlow(
                flows_processes.ListProcesses,
                client_id=client_id_1,
                parent=flow.FlowParent.FromHuntID(hunt_id))
            flow_obj = data_store.REL_DB.ReadFlowObject(client_id_1, flow_id)
            flow_obj.flow_state = flow_obj.FlowState.ERROR
            flow_obj.error_message = "Error foo."
            data_store.REL_DB.UpdateFlow(client_id_1,
                                         flow_id,
                                         flow_obj=flow_obj)

        with test_lib.FakeTime(55):
            flow_id = flow_test_lib.StartFlow(
                flows_processes.ListProcesses,
                client_id=client_id_2,
                parent=flow.FlowParent.FromHuntID(hunt_id))
            flow_obj = data_store.REL_DB.ReadFlowObject(client_id_2, flow_id)
            flow_obj.flow_state = flow_obj.FlowState.ERROR
            flow_obj.error_message = "Error bar."
            flow_obj.backtrace = "<some backtrace>"
            data_store.REL_DB.UpdateFlow(client_id_2,
                                         flow_id,
                                         flow_obj=flow_obj)

        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(hunt_id=hunt_id),
                   replace={hunt_id: "H:123456"})
        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(hunt_id=hunt_id,
                                                          count=1),
                   replace={hunt_id: "H:123456"})
        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(hunt_id=hunt_id,
                                                          offset=1,
                                                          count=1),
                   replace={hunt_id: "H:123456"})
Пример #3
0
    def Run(self):
        client_id_1 = self.SetupClient(0).Basename()
        client_id_2 = self.SetupClient(1).Basename()

        if data_store.RelationalDBEnabled():
            with test_lib.FakeTime(42):
                hunt_id = self.CreateHunt(description="the hunt")

            with test_lib.FakeTime(52):
                flow_id = flow_test_lib.StartFlow(
                    flows_processes.ListProcesses,
                    client_id=client_id_1,
                    parent_hunt_id=hunt_id)
                flow_obj = data_store.REL_DB.ReadFlowObject(
                    client_id_1, flow_id)
                flow_obj.flow_state = flow_obj.FlowState.ERROR
                flow_obj.error_message = "Error foo."
                data_store.REL_DB.UpdateFlow(client_id_1,
                                             flow_id,
                                             flow_obj=flow_obj)

            with test_lib.FakeTime(55):
                flow_id = flow_test_lib.StartFlow(
                    flows_processes.ListProcesses,
                    client_id=client_id_2,
                    parent_hunt_id=hunt_id)
                flow_obj = data_store.REL_DB.ReadFlowObject(
                    client_id_2, flow_id)
                flow_obj.flow_state = flow_obj.FlowState.ERROR
                flow_obj.error_message = "Error bar."
                flow_obj.backtrace = "<some backtrace>"
                data_store.REL_DB.UpdateFlow(client_id_2,
                                             flow_id,
                                             flow_obj=flow_obj)

        else:
            with test_lib.FakeTime(42):
                with self.CreateHunt(description="the hunt") as hunt_obj:
                    hunt_id = hunt_obj.urn.Basename()

                    with test_lib.FakeTime(52):
                        hunt_obj.LogClientError(
                            rdf_client.ClientURN(client_id_1), "Error foo.")

                    with test_lib.FakeTime(55):
                        hunt_obj.LogClientError(
                            rdf_client.ClientURN(client_id_2), "Error bar.",
                            "<some backtrace>")

        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(hunt_id=hunt_id),
                   replace={hunt_id: "H:123456"})
        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(hunt_id=hunt_id,
                                                          count=1),
                   replace={hunt_id: "H:123456"})
        self.Check("ListHuntErrors",
                   args=hunt_plugin.ApiListHuntErrorsArgs(hunt_id=hunt_id,
                                                          offset=1,
                                                          count=1),
                   replace={hunt_id: "H:123456"})