示例#1
0
    def testUserChangesToCopiedFlowAreRespected(self):
        args = flows_processes.ListProcessesArgs(filename_regex="test[a-z]*",
                                                 fetch_binaries=True)
        flow.GRRFlow.StartFlow(
            flow_name=flows_processes.ListProcesses.__name__,
            args=args,
            client_id=self.client_id,
            output_plugins=[self.email_descriptor],
            token=self.token)

        # Navigate to client and select newly created flow.
        self.Open("/#c=C.0000000000000001")
        self.Click("css=a[grrtarget='client.flows']")
        self.Click("css=td:contains('ListProcesses')")

        # Open wizard and change the arguments.
        self.Click("css=button[name=copy_flow]")

        self.Type("css=label:contains('Filename Regex') ~ * input",
                  "somethingElse*")

        self.Click(
            "css=label:contains('Fetch Binaries') ~ * input[type=checkbox]")

        # Change output plugin and add another one.
        self.Click("css=label:contains('Output Plugins') ~ * button")
        self.Select(
            "css=grr-output-plugin-descriptor-form "
            "label:contains('Plugin') ~ * select:eq(0)", "DummyOutputPlugin")
        self.Type(
            "css=grr-output-plugin-descriptor-form "
            "label:contains('Filename Regex'):eq(0) ~ * input:text", "foobar!")

        self.Click("css=button:contains('Launch')")

        # Check that flows list got updated and that the new flow is selected.
        self.WaitUntil(
            self.IsElementPresent,
            "css=grr-client-flows-list tr:contains('ListProcesses'):nth(1)")
        self.WaitUntil(
            self.IsElementPresent, "css=grr-client-flows-list "
            "tr:contains('ListProcesses'):nth(0).row-selected")

        # Now open the last flow and check that it has the changes we made.
        with self.ACLChecksDisabled():
            fd = aff4.FACTORY.Open(self.client_id.Add("flows"),
                                   token=self.token)
            flows = sorted(fd.ListChildren(), key=lambda x: x.age)
            fobj = aff4.FACTORY.Open(flows[-1], token=self.token)

            self.assertEqual(
                fobj.args,
                flows_processes.ListProcessesArgs(
                    filename_regex="somethingElse*", ))
            self.assertListEqual(list(fobj.runner_args.output_plugins), [
                output_plugin.OutputPluginDescriptor(
                    plugin_name=DummyOutputPlugin.__name__,
                    plugin_args=flows_processes.ListProcessesArgs(
                        filename_regex="foobar!")), self.email_descriptor
            ])
示例#2
0
    def testCopyingFlowUpdatesFlowListAndSelectsNewFlow(self):
        args = flows_processes.ListProcessesArgs(filename_regex="test[a-z]*",
                                                 fetch_binaries=True)
        flow.GRRFlow.StartFlow(
            flow_name=flows_processes.ListProcesses.__name__,
            args=args,
            client_id=self.client_id,
            token=self.token)

        # Navigate to client and select newly created flow.
        self.Open("/#c=C.0000000000000001")
        self.Click("css=a[grrtarget='client.flows']")
        self.Click("css=td:contains('ListProcesses')")

        # Check that there's only one ListProcesses flow.
        self.WaitUntilNot(
            self.IsElementPresent,
            "css=grr-client-flows-list tr:contains('ListProcesses'):nth(1)")

        # Open wizard and check if flow arguments are copied.
        self.Click("css=button[name=copy_flow]")
        self.Click("css=button:contains('Launch'):not([disabled])")

        # Check that flows list got updated and that the new flow is selected.
        self.WaitUntil(
            self.IsElementPresent,
            "css=grr-client-flows-list tr:contains('ListProcesses'):nth(1)")
        self.WaitUntil(
            self.IsElementPresent, "css=grr-client-flows-list "
            "tr:contains('ListProcesses'):nth(0).row-selected")
示例#3
0
    def testOriginalFlowArgsAreShownInCopyForm(self):
        args = flows_processes.ListProcessesArgs(filename_regex="test[a-z]*",
                                                 fetch_binaries=True)
        flow.GRRFlow.StartFlow(
            flow_name=flows_processes.ListProcesses.__name__,
            args=args,
            client_id=self.client_id,
            output_plugins=[self.email_descriptor],
            token=self.token)

        # Navigate to client and select newly created flow.
        self.Open("/#c=C.0000000000000001")
        self.Click("css=a[grrtarget='client.flows']")
        self.Click("css=td:contains('ListProcesses')")

        # Open wizard and check if flow arguments are copied.
        self.Click("css=button[name=copy_flow]")

        self.WaitUntil(self.IsTextPresent, "Copy ListProcesses flow")

        self.WaitUntilEqual("test[a-z]*", self.GetValue,
                            "css=label:contains('Filename Regex') ~ * input")

        self.WaitUntil(
            self.IsChecked, "css=label:contains('Fetch Binaries') "
            "~ * input[type=checkbox]")

        # Check that output plugin info is also copied.
        self.WaitUntilEqual("string:EmailOutputPlugin", self.GetValue,
                            "css=label:contains('Plugin') ~ * select")
        self.WaitUntilEqual("test@localhost", self.GetValue,
                            "css=label:contains('Email address') ~ * input")
        self.WaitUntilEqual("42", self.GetValue,
                            "css=label:contains('Emails limit') ~ * input")
示例#4
0
    def testCreateHuntFromFlow(self):
        email_descriptor = output_plugin.OutputPluginDescriptor(
            plugin_name=email_plugin.EmailOutputPlugin.__name__,
            plugin_args=email_plugin.EmailOutputPluginArgs(
                email_address="test@localhost", emails_limit=42))

        args = flows_processes.ListProcessesArgs(filename_regex="test[a-z]*",
                                                 fetch_binaries=True)

        flow.GRRFlow.StartFlow(
            flow_name=flows_processes.ListProcesses.__name__,
            args=args,
            client_id=self.client_id,
            output_plugins=[email_descriptor],
            token=self.token)

        # Navigate to client and select newly created flow.
        self.Open("/#c=C.0000000000000001")
        self.Click("css=a[grrtarget='client.flows']")
        self.Click("css=td:contains('ListProcesses')")

        # Open wizard and check if flow arguments are copied.
        self.Click("css=button[name=create_hunt]")

        self.WaitUntilEqual("test[a-z]*", self.GetValue,
                            "css=label:contains('Filename Regex') ~ * input")

        self.WaitUntil(
            self.IsChecked, "css=label:contains('Fetch Binaries') "
            "~ * input[type=checkbox]")

        # Go to next page and check that we did not copy the output plugins.
        self.Click("css=button:contains('Next')")

        self.WaitUntilNot(self.IsElementPresent,
                          "css=grr-output-plugin-descriptor-form")

        # Nothing else to check, so finish the hunt.
        self.Click("css=button:contains('Next')")
        self.Click("css=button:contains('Next')")
        self.Click("css=button:contains('Create Hunt')")
        self.Click("css=button:contains('Done')")

        # Check that we get redirected to ManageHunts.
        self.WaitUntilEqual(1, self.GetCssCount,
                            "css=grr-hunts-list table tbody tr")
        self.WaitUntilEqual(1, self.GetCssCount,
                            "css=grr-hunts-list table tbody tr.row-selected")
        self.WaitUntil(self.IsTextPresent, "GenericHunt")
        self.WaitUntil(self.IsTextPresent,
                       flows_processes.ListProcesses.__name__)
示例#5
0
  def testCreateFlowFromClientObject(self):
    client_urn = self.SetupClients(1)[0]
    args = processes.ListProcessesArgs(
        filename_regex="blah", fetch_binaries=True)

    children = aff4.FACTORY.Open(client_urn, token=self.token).ListChildren()
    self.assertEqual(len(list(children)), 0)

    client = self.api.Client(client_id=client_urn.Basename()).Get()
    result_flow = client.CreateFlow(
        name=processes.ListProcesses.__name__, args=args.AsPrimitiveProto())

    children = aff4.FACTORY.Open(client_urn, token=self.token).ListChildren()
    self.assertEqual(len(list(children)), 1)
    result_flow_obj = aff4.FACTORY.Open(result_flow.data.urn, token=self.token)
    self.assertEqual(result_flow_obj.args, args)
示例#6
0
    def Run(self):
        def ReplaceFlowId():
            flows_dir_fd = aff4.FACTORY.Open(self.client_id.Add("flows"),
                                             token=self.token)
            flow_urn = list(flows_dir_fd.ListChildren())[0]
            return {flow_urn.Basename(): "W:ABCDEF"}

        with test_lib.FakeTime(42):
            self.Check("CreateFlow",
                       args=flow_plugin.ApiCreateFlowArgs(
                           client_id=self.client_id.Basename(),
                           flow=flow_plugin.ApiFlow(
                               name=processes.ListProcesses.__name__,
                               args=processes.ListProcessesArgs(
                                   filename_regex=".", fetch_binaries=True),
                               runner_args=rdf_flows.FlowRunnerArgs(
                                   output_plugins=[],
                                   priority="HIGH_PRIORITY",
                                   notify_to_user=False))),
                       replace=ReplaceFlowId)
示例#7
0
    def testAddingOutputPluginToCopiedFlowWorks(self):
        args = flows_processes.ListProcessesArgs(filename_regex="test[a-z]*",
                                                 fetch_binaries=True)
        flow.GRRFlow.StartFlow(
            flow_name=flows_processes.ListProcesses.__name__,
            args=args,
            client_id=self.client_id,
            token=self.token)

        # Navigate to client and select newly created flow.
        self.Open("/#c=C.0000000000000001")
        self.Click("css=a[grrtarget='client.flows']")
        self.Click("css=td:contains('ListProcesses')")

        # Open wizard and check if flow arguments are copied.
        self.Click("css=button[name=copy_flow]")

        self.Click("css=label:contains('Output Plugins') ~ * button")
        self.WaitUntil(self.IsElementPresent,
                       "css=label:contains('Plugin') ~ * select")