def Run(self): acl_test_lib.CreateUser(self.token.username) with test_lib.FakeTime(42): client_id = self.SetupClient(0) with test_lib.FakeTime(43): flow_id_1 = flow_test_lib.StartFlow( discovery.Interrogate, client_id, creator=self.token.username) with test_lib.FakeTime(44): flow_id_2 = flow_test_lib.StartFlow( processes.ListProcesses, client_id, creator=self.token.username) replace = api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id_1, "F:ABCDEF10") replace.update( api_regression_test_lib.GetFlowTestReplaceDict(client_id, flow_id_2, "F:ABCDEF11")) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs(client_id=client_id), replace=replace) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs( client_id=client_id, top_flows_only=True, ), replace=replace) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs( client_id=client_id, min_started_at=rdfvalue.RDFDatetimeSeconds(44), top_flows_only=True, ), replace=replace) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs( client_id=client_id, max_started_at=rdfvalue.RDFDatetimeSeconds(43), top_flows_only=True, ), replace=replace)
def FlowHasBeenStarted(): handler = api_flow.ApiListFlowsHandler() flows = handler.Handle(api_flow.ApiListFlowsArgs( client_id=self.client_id, top_flows_only=True), context=api_call_context.ApiCallContext( username=self.test_username)).items return flows[0] if len(flows) == 1 else None
def testAllClientFlowsMethodsAreAccessChecked(self): args = api_flow.ApiListFlowsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.ListFlows, "CheckClientAccess", args=args) args = api_flow.ApiGetFlowArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.GetFlow, "CheckClientAccess", args=args) args = api_flow.ApiCreateFlowArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.CreateFlow, "CheckClientAccess", args=args) self.CheckMethodIsAccessChecked( self.router.CreateFlow, "CheckIfCanStartClientFlow", args=args) args = api_flow.ApiCancelFlowArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.CancelFlow, "CheckClientAccess", args=args) args = api_flow.ApiListFlowRequestsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.ListFlowRequests, "CheckClientAccess", args=args) args = api_flow.ApiListFlowResultsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.ListFlowResults, "CheckClientAccess", args=args) args = api_flow.ApiGetExportedFlowResultsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.GetExportedFlowResults, "CheckClientAccess", args=args) args = api_flow.ApiGetFlowResultsExportCommandArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.GetFlowResultsExportCommand, "CheckClientAccess", args=args) args = api_flow.ApiGetFlowFilesArchiveArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.GetFlowFilesArchive, "CheckClientAccess", args=args) args = api_flow.ApiListFlowOutputPluginsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.ListFlowOutputPlugins, "CheckClientAccess", args=args) args = api_flow.ApiListFlowOutputPluginLogsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.ListFlowOutputPluginLogs, "CheckClientAccess", args=args) args = api_flow.ApiListFlowOutputPluginErrorsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.ListFlowOutputPluginErrors, "CheckClientAccess", args=args) args = api_flow.ApiListFlowLogsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked( self.router.ListFlowLogs, "CheckClientAccess", args=args)
def Run(self): acl_test_lib.CreateUser(self.token.username) with test_lib.FakeTime(42): client_id = self.SetupClient(0).Basename() with test_lib.FakeTime(43): flow_id_1 = api_regression_test_lib.StartFlow( client_id, discovery.Interrogate, token=self.token) with test_lib.FakeTime(44): flow_id_2 = api_regression_test_lib.StartFlow( client_id, processes.ListProcesses, token=self.token) replace = api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id_1, "F:ABCDEF10") replace.update( api_regression_test_lib.GetFlowTestReplaceDict( client_id, flow_id_2, "F:ABCDEF11")) self.Check("ListFlows", args=flow_plugin.ApiListFlowsArgs(client_id=client_id), replace=replace)
def Run(self): acl_test_lib.CreateUser(self.token.username) with test_lib.FakeTime(42): client_urn = self.SetupClient(0) with test_lib.FakeTime(43): flow_id_1 = flow.StartAFF4Flow( flow_name=discovery.Interrogate.__name__, client_id=client_urn, token=self.token) with test_lib.FakeTime(44): flow_id_2 = flow.StartAFF4Flow( flow_name=processes.ListProcesses.__name__, client_id=client_urn, token=self.token) self.Check( "ListFlows", args=flow_plugin.ApiListFlowsArgs(client_id=client_urn.Basename()), replace={ flow_id_1.Basename(): "F:ABCDEF10", flow_id_2.Basename(): "F:ABCDEF11" })
def _ListFlows(client_id: str, creator: str): handler = api_flow.ApiListFlowsHandler() return handler.Handle( api_flow.ApiListFlowsArgs(client_id=client_id, top_flows_only=True), context=api_call_context.ApiCallContext(username=creator)).items