Exemple #1
0
    def testClientFileFinder(self):
        paths = [os.path.join(self.base_path, "**/*.plist")]
        action = rdf_file_finder.FileFinderAction.Action.STAT
        for s in test_lib.TestFlowHelper(
                "ClientFileFinder",
                action_mocks.ClientFileFinderClientMock(),
                client_id=self.client_id,
                paths=paths,
                pathtype=rdf_paths.PathSpec.PathType.OS,
                action=rdf_file_finder.FileFinderAction(action_type=action),
                process_non_regular_files=True,
                token=self.token):
            session_id = s

        collection = flow.GRRFlow.ResultCollectionForFID(session_id,
                                                         token=self.token)
        results = list(collection)
        self.assertEqual(len(results), 4)
        relpaths = [
            os.path.relpath(p.stat_entry.pathspec.path, self.base_path)
            for p in results
        ]
        self.assertItemsEqual(relpaths, [
            "History.plist", "History.xml.plist", "test.plist",
            "parser_test/com.google.code.grr.plist"
        ])
Exemple #2
0
  def _RunClientFileFinder(self,
                           paths,
                           action,
                           network_bytes_limit=None,
                           client_id=None):
    client_id = client_id or self.SetupClients(1)[0]
    with test_lib.ConfigOverrider({"Client.server_urls": [self.base_url]}):
      client = comms.GRRHTTPClient(
          ca_cert=config.CONFIG["CA.certificate"],
          private_key=config.CONFIG.Get("Client.private_key", default=None))
      client.client_worker = worker_mocks.FakeThreadedWorker(client=client)
      client.server_certificate = config.CONFIG["Frontend.certificate"]

      for s in flow_test_lib.TestFlowHelper(
          file_finder.ClientFileFinder.__name__,
          action_mocks.ClientFileFinderClientMock(
              client_worker=client.client_worker),
          client_id=client_id,
          paths=paths,
          pathtype=rdf_paths.PathSpec.PathType.OS,
          action=action,
          process_non_regular_files=True,
          network_bytes_limit=network_bytes_limit,
          token=self.token):
        session_id = s

      return session_id