Beispiel #1
0
    def setUp(self):
        """Make sure things are initialized."""
        super(TestArtifactCollectors, self).setUp()

        self._patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
        self._patcher.start()

        test_artifacts_file = os.path.join(config.CONFIG["Test.data_dir"],
                                           "artifacts", "test_artifacts.json")
        artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)

        self.fakeartifact = artifact_registry.REGISTRY.GetArtifact(
            "FakeArtifact")
        self.fakeartifact2 = artifact_registry.REGISTRY.GetArtifact(
            "FakeArtifact2")

        self.output_count = 0

        self.client_id = self.SetupClient(0)

        with aff4.FACTORY.Open(self.client_id, token=self.token,
                               mode="rw") as fd:
            fd.Set(fd.Schema.SYSTEM("Linux"))
            kb = fd.Schema.KNOWLEDGE_BASE()
            artifact.SetCoreGRRKnowledgeBaseValues(kb, fd)
            fd.Set(kb)
Beispiel #2
0
  def setUp(self):
    super(GRRSeleniumTest, self).setUp()

    # Used by InstallACLChecks/UninstallACLChecks
    self.config_override = None

    self.token.username = "******"
    webauth.WEBAUTH_MANAGER.SetUserName(self.token.username)

    # Make the user use the advanced gui so we can test it.
    with aff4.FACTORY.Create(
        aff4.ROOT_URN.Add("users/%s" % self.token.username),
        aff4_type=users.GRRUser,
        mode="w",
        token=self.token) as user_fd:
      user_fd.Set(user_fd.Schema.GUI_SETTINGS(mode="ADVANCED"))

    if data_store.RelationalDBReadEnabled():
      data_store.REL_DB.WriteGRRUser(
          self.token.username, ui_mode=users.GUISettings.UIMode.ADVANCED)

    self._artifact_patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
    self._artifact_patcher.start()

    self.InstallACLChecks()
Beispiel #3
0
    def setUp(self):
        super(TestArtifactCollectorsInteractions, self).setUp()

        self._patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
        self._patcher.start()

        test_artifacts_file = os.path.join(config.CONFIG["Test.data_dir"],
                                           "artifacts", "test_artifacts.json")
        artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)
    def setUp(self):
        super().setUp()

        patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
        patcher.start()
        self.addCleanup(patcher.stop)

        test_artifacts_file = os.path.join(config.CONFIG["Test.data_dir"],
                                           "artifacts", "test_artifacts.json")
        artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)
Beispiel #5
0
    def setUp(self):
        super(ClientArtifactCollectorFlowTest, self).setUp()

        self._patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
        self._patcher.start()

        test_artifacts_file = os.path.join(config.CONFIG["Test.data_dir"],
                                           "artifacts", "test_artifacts.json")
        artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)

        self.client_id = self.SetupClient(0)
Beispiel #6
0
    def setUp(self):
        """Make sure things are initialized."""
        super(ArtifactTest, self).setUp()
        # Common group of mocks used by lots of tests.
        self.client_mock = action_mocks.ActionMock(
            searching.Find,
            searching.Grep,
            standard.HashBuffer,
            standard.HashFile,
            standard.ListDirectory,
            standard.GetFileStat,
            standard.TransferBuffer,
        )

        patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
        patcher.start()
        self.addCleanup(patcher.stop)
Beispiel #7
0
  def setUp(self):
    """Make sure things are initialized."""
    super(ArtifactCollectorsTestMixin, self).setUp()

    self._patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
    self._patcher.start()

    test_artifacts_file = os.path.join(config.CONFIG["Test.data_dir"],
                                       "artifacts", "test_artifacts.json")
    artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)

    self.fakeartifact = artifact_registry.REGISTRY.GetArtifact("FakeArtifact")
    self.fakeartifact2 = artifact_registry.REGISTRY.GetArtifact("FakeArtifact2")

    self.output_count = 0

    self.client_id = self.SetupClient(0, system="Linux")
Beispiel #8
0
  def setUp(self):
    """Make sure things are initialized."""
    super(ArtifactCollectorsTestMixin, self).setUp()

    patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
    patcher.start()
    self.addCleanup(patcher.stop)

    artifact_registry.REGISTRY.ClearSources()
    artifact_registry.REGISTRY.ClearRegistry()

    test_artifacts_file = os.path.join(config.CONFIG["Test.data_dir"],
                                       "artifacts", "test_artifacts.json")
    artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)

    self.fakeartifact = artifact_registry.REGISTRY.GetArtifact("FakeArtifact")
    self.fakeartifact2 = artifact_registry.REGISTRY.GetArtifact("FakeArtifact2")

    self.output_count = 0
Beispiel #9
0
    def setUp(self):
        """Make sure things are initialized."""
        super(ArtifactTest, self).setUp()
        # Common group of mocks used by lots of tests.
        self.client_mock = action_mocks.ActionMock(
            file_fingerprint.FingerprintFile,
            searching.Find,
            searching.Grep,
            server_stubs.WmiQuery,
            standard.HashBuffer,
            standard.HashFile,
            standard.ListDirectory,
            standard.StatFile,
            standard.TransferBuffer,
        )

        self._artifact_patcher = artifact_test_lib.PatchDefaultArtifactRegistry(
        )
        self._artifact_patcher.start()
Beispiel #10
0
  def setUp(self):
    super(GRRSeleniumTest, self).setUp()

    # Used by InstallACLChecks/UninstallACLChecks
    self.config_override = None
    # Used by CheckHttpErrors
    self.ignore_http_errors = False

    self.token.username = "******"
    webauth.WEBAUTH_MANAGER.SetUserName(self.token.username)

    # Make the user use the advanced gui so we can test it.
    with aff4.FACTORY.Create(
        aff4.ROOT_URN.Add("users/%s" % self.token.username),
        aff4_type=users.GRRUser,
        mode="w",
        token=self.token) as user_fd:
      user_fd.Set(user_fd.Schema.GUI_SETTINGS(mode="ADVANCED"))

    if data_store.RelationalDBReadEnabled():
      data_store.REL_DB.WriteGRRUser(
          self.token.username, ui_mode=users.GUISettings.UIMode.ADVANCED)

    self._artifact_patcher = artifact_test_lib.PatchDefaultArtifactRegistry()
    self._artifact_patcher.start()

    self.InstallACLChecks()

    if flags.FLAGS.use_headless_chrome:
      params = {
          "cmd": "Page.setDownloadBehavior",
          "params": {
              "behavior": "allow",
              "downloadPath": self.temp_dir
          }
      }
      result = self.driver.execute("send_command", params)
      if result["status"] != 0:
        raise RuntimeError("can't set Page.setDownloadBehavior: %s" % result)